You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "DSingh0304 (via GitHub)" <gi...@apache.org> on 2025/11/15 06:39:36 UTC
[PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
DSingh0304 opened a new pull request, #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255
**Why submit this pull request?**
- [ ] Bugfix
- [x] New feature provided
- [ ] Improve performance
- [ ] Backport patches
**What changes will this PR take into?**
This PR adds comprehensive E2E test coverage for Stream Routes, which was previously missing from the test suite.
**Changes:**
- Add `stream_routes.crud-required-fields.spec.ts` for minimal CRUD operations testing
- Add `stream_routes.crud-all-fields.spec.ts` for extended CRUD with optional fields (server_addr, remote_addr, SNI, labels)
- Add `stream_routes.list.spec.ts` for pagination testing
- Create `e2e/utils/ui/stream_routes.ts` helper module for stream route form interactions
- Update stream_routes POM with `isIndexPage`, `isAddPage`, `isDetailPage` assertions and navigation helpers
**Test Flow:**
All CRUD operations now use the detail page for edit/delete workflows instead of relying on non-existent list-page Edit buttons. Tests verify:
- Creation automatically lands on detail page (read-only view)
- Editing works via detail page Edit button
- Deletion happens through detail page dialog with proper list verification
- Pagination and list view functionality works correctly
**Related issues**
fix #3085
**Checklist:**
- [x] Did you explain what problem does this PR solve? Or what new features have been added?
- [x] Have you added corresponding test cases?
- [ ] Have you modified the corresponding document?
- [x] Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "DSingh0304 (via GitHub)" <gi...@apache.org>.
DSingh0304 commented on code in PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255#discussion_r2622038782
##########
src/apis/stream_routes.ts:
##########
@@ -77,7 +77,14 @@ export const deleteAllStreamRoutes = async (req: AxiosInstance) => {
page_size: PAGE_SIZE_MAX,
});
await Promise.all(
- res.list.map((d) => req.delete(`${API_STREAM_ROUTES}/${d.value.id}`))
+ res.list.map((d) =>
+ req.delete(`${API_STREAM_ROUTES}/${d.value.id}`).catch((err) => {
+ // Ignore 404 errors - resource already deleted
Review Comment:
This ensures the test cleanup is robust against race conditions or inconsistent states. If a resource is deleted by another process (or a previous test step) between the time we `list` the resources and the time we try to [delete](cci:1://file:///home/deep/Desktop/Code/Organizations/apisix-dashboard/src/apis/stream_routes.ts:66:0-89:2) them, the server returns a 404. Ignoring 404s prevents the [deleteAllStreamRoutes](cci:1://file:///home/deep/Desktop/Code/Organizations/apisix-dashboard/src/apis/stream_routes.ts:66:0-89:2) helper from crashing the test suite when the resource is already gone, which is the desired state anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "DSingh0304 (via GitHub)" <gi...@apache.org>.
DSingh0304 commented on code in PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255#discussion_r2548611708
##########
e2e/utils/ui/stream_routes.ts:
##########
@@ -0,0 +1,299 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import type { Locator, Page } from '@playwright/test';
+import { expect } from '@playwright/test';
+
+import type { APISIXType } from '@/types/schema/apisix';
+
+export const uiFillStreamRouteRequiredFields = async (
+ page: Page,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ }
+) => {
+ if (data.server_addr) {
+ await page
+ .getByLabel('Server Address', { exact: true })
+ .fill(data.server_addr);
+ }
+
+ if (data.server_port) {
+ await page
+ .getByLabel('Server Port', { exact: true })
+ .fill(data.server_port.toString());
+ }
+
+ if (data.remote_addr) {
+ await page.getByLabel('Remote Address').fill(data.remote_addr);
+ }
+
+ if (data.sni) {
+ await page.getByLabel('SNI').fill(data.sni);
+ }
+
+ if (data.desc) {
+ await page.getByLabel('Description').first().fill(data.desc);
+ }
+
+ if (data.labels) {
+ const labelsField = page.getByPlaceholder('Input text like `key:value`,').first();
+ for (const [key, value] of Object.entries(data.labels)) {
+ await labelsField.fill(`${key}:${value}`);
+ await labelsField.press('Enter');
+ }
+ }
+};
+
+export const uiCheckStreamRouteRequiredFields = async (
+ page: Page,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ }
+) => {
+ if (data.server_addr) {
+ await expect(page.getByLabel('Server Address', { exact: true })).toHaveValue(
+ data.server_addr
+ );
+ }
+
+ if (data.server_port) {
+ await expect(page.getByLabel('Server Port', { exact: true })).toHaveValue(
+ data.server_port.toString()
+ );
+ }
+
+ if (data.remote_addr) {
+ await expect(page.getByLabel('Remote Address')).toHaveValue(
+ data.remote_addr
+ );
+ }
+
+ if (data.sni) {
+ await expect(page.getByLabel('SNI')).toHaveValue(data.sni);
+ }
+
+ if (data.desc) {
+ await expect(page.getByLabel('Description').first()).toHaveValue(data.desc);
+ }
+
+ if (data.labels) {
+ // Labels are displayed as tags, check if the tags exist
+ for (const [key, value] of Object.entries(data.labels)) {
+ const labelTag = page.getByText(`${key}:${value}`, { exact: true });
+ await expect(labelTag).toBeVisible();
+ }
+ }
+};
+
+export const uiFillStreamRouteAllFields = async (
+ page: Page,
+ upstreamSection: Locator,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ upstream?: {
+ nodes?: APISIXType['UpstreamNode'][];
+ retries?: number;
+ timeout?: {
+ connect?: number;
+ send?: number;
+ read?: number;
+ };
+ };
+ protocol?: {
+ name?: string;
+ superior_id?: string;
+ };
+ }
+) => {
+ // Fill basic fields
+ await uiFillStreamRouteRequiredFields(page, {
+ server_addr: data.server_addr,
+ server_port: data.server_port,
+ remote_addr: data.remote_addr,
+ sni: data.sni,
+ desc: data.desc,
+ labels: data.labels,
+ });
+
+ // Fill upstream nodes
+ if (data.upstream?.nodes && data.upstream.nodes.length > 0) {
+ for (let i = 0; i < data.upstream.nodes.length; i++) {
+ const node = data.upstream.nodes[i];
+ const nodeRow = upstreamSection
+ .locator('section')
+ .filter({ hasText: 'Nodes' })
+ .getByRole('row')
+ .nth(i + 1);
+
+ await nodeRow.getByPlaceholder('Host').fill(node.host);
+ await nodeRow.getByPlaceholder('Port').fill(node.port.toString());
+ await nodeRow.getByPlaceholder('Weight').fill(node.weight.toString());
+
+ // Click add if there are more nodes to add
+ if (i < data.upstream.nodes.length - 1) {
+ await upstreamSection
+ .locator('section')
+ .filter({ hasText: 'Nodes' })
+ .getByRole('button', { name: 'Add' })
+ .click();
+ }
+ }
+ }
+
+ // Fill upstream retries
+ if (data.upstream?.retries !== undefined) {
+ await upstreamSection.getByLabel('Retries').fill(data.upstream.retries.toString());
+ }
+
+ // Fill upstream timeout
+ if (data.upstream?.timeout) {
+ if (data.upstream.timeout.connect !== undefined) {
+ await upstreamSection
+ .getByLabel('Connect', { exact: true })
+ .fill(data.upstream.timeout.connect.toString());
+ }
+ if (data.upstream.timeout.send !== undefined) {
+ await upstreamSection
+ .getByLabel('Send', { exact: true })
+ .fill(data.upstream.timeout.send.toString());
+ }
+ if (data.upstream.timeout.read !== undefined) {
+ await upstreamSection
+ .getByLabel('Read', { exact: true })
+ .fill(data.upstream.timeout.read.toString());
+ }
+ }
+
+ // Fill protocol fields
+ if (data.protocol?.name) {
+ await page.getByLabel('Protocol Name').fill(data.protocol.name);
+ }
+
+ if (data.protocol?.superior_id) {
+ await page.getByLabel('Superior ID').fill(data.protocol.superior_id);
+ }
+};
+
+export const uiCheckStreamRouteAllFields = async (
+ page: Page,
+ upstreamSection: Locator,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ upstream?: {
+ nodes?: APISIXType['UpstreamNode'][];
+ retries?: number;
+ timeout?: {
+ connect?: number;
+ send?: number;
+ read?: number;
+ };
+ };
+ protocol?: {
+ name?: string;
+ superior_id?: string;
+ };
+ }
Review Comment:
fixed...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "DSingh0304 (via GitHub)" <gi...@apache.org>.
DSingh0304 commented on code in PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255#discussion_r2626393036
##########
src/apis/stream_routes.ts:
##########
@@ -77,7 +77,14 @@ export const deleteAllStreamRoutes = async (req: AxiosInstance) => {
page_size: PAGE_SIZE_MAX,
});
await Promise.all(
- res.list.map((d) => req.delete(`${API_STREAM_ROUTES}/${d.value.id}`))
+ res.list.map((d) =>
+ req.delete(`${API_STREAM_ROUTES}/${d.value.id}`).catch((err) => {
+ // Ignore 404 errors - resource already deleted
Review Comment:
You're right I've removed the global cleanup approach: reverted the .catch() error suppression in
deleteAllStreamRoutes, eliminated beforeAll cleanup from CRUD tests (they now create unique resources with
randomId() and delete only their own via UI), and ensured each test is fully isolated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on code in PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255#discussion_r2625793908
##########
src/apis/stream_routes.ts:
##########
@@ -77,7 +77,14 @@ export const deleteAllStreamRoutes = async (req: AxiosInstance) => {
page_size: PAGE_SIZE_MAX,
});
await Promise.all(
- res.list.map((d) => req.delete(`${API_STREAM_ROUTES}/${d.value.id}`))
+ res.list.map((d) =>
+ req.delete(`${API_STREAM_ROUTES}/${d.value.id}`).catch((err) => {
+ // Ignore 404 errors - resource already deleted
Review Comment:
I don't think this is a good approach. Resources created by each test should be independent; different tests shouldn't use the same resources.
When cleaning up resources, each test should only clean up the resources created by that specific test, not all resources.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop merged PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "SkyeYoung (via GitHub)" <gi...@apache.org>.
SkyeYoung commented on PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255#issuecomment-3560991548
Also pls fix tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on code in PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255#discussion_r2621961191
##########
src/apis/upstreams.ts:
##########
@@ -55,19 +55,56 @@ export const putUpstreamReq = (
};
export const deleteAllUpstreams = async (req: AxiosInstance) => {
- const totalRes = await getUpstreamListReq(req, {
- page: 1,
- page_size: PAGE_SIZE_MIN,
- });
+ // Retry wrapper to handle potential transient failures (e.g., 500 Internal Server Error) when fetching upstream list.
+ // This is particularly useful in E2E tests where rapid creation/deletion might cause temporary instability.
Review Comment:
I believe that testing should simulate real-world scenarios as closely as possible, and we shouldn't rely on retries to guarantee a test pass.
##########
src/apis/stream_routes.ts:
##########
@@ -77,7 +77,14 @@ export const deleteAllStreamRoutes = async (req: AxiosInstance) => {
page_size: PAGE_SIZE_MAX,
});
await Promise.all(
- res.list.map((d) => req.delete(`${API_STREAM_ROUTES}/${d.value.id}`))
+ res.list.map((d) =>
+ req.delete(`${API_STREAM_ROUTES}/${d.value.id}`).catch((err) => {
+ // Ignore 404 errors - resource already deleted
Review Comment:
Why is it necessary to add this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "DSingh0304 (via GitHub)" <gi...@apache.org>.
DSingh0304 commented on code in PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255#discussion_r2548611159
##########
e2e/utils/ui/stream_routes.ts:
##########
@@ -0,0 +1,299 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import type { Locator, Page } from '@playwright/test';
+import { expect } from '@playwright/test';
+
+import type { APISIXType } from '@/types/schema/apisix';
+
+export const uiFillStreamRouteRequiredFields = async (
+ page: Page,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ }
+) => {
+ if (data.server_addr) {
+ await page
+ .getByLabel('Server Address', { exact: true })
+ .fill(data.server_addr);
+ }
+
+ if (data.server_port) {
+ await page
+ .getByLabel('Server Port', { exact: true })
+ .fill(data.server_port.toString());
+ }
+
+ if (data.remote_addr) {
+ await page.getByLabel('Remote Address').fill(data.remote_addr);
+ }
+
+ if (data.sni) {
+ await page.getByLabel('SNI').fill(data.sni);
+ }
+
+ if (data.desc) {
+ await page.getByLabel('Description').first().fill(data.desc);
+ }
+
+ if (data.labels) {
+ const labelsField = page.getByPlaceholder('Input text like `key:value`,').first();
+ for (const [key, value] of Object.entries(data.labels)) {
+ await labelsField.fill(`${key}:${value}`);
+ await labelsField.press('Enter');
+ }
+ }
+};
+
+export const uiCheckStreamRouteRequiredFields = async (
+ page: Page,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ }
+) => {
+ if (data.server_addr) {
+ await expect(page.getByLabel('Server Address', { exact: true })).toHaveValue(
+ data.server_addr
+ );
+ }
+
+ if (data.server_port) {
+ await expect(page.getByLabel('Server Port', { exact: true })).toHaveValue(
+ data.server_port.toString()
+ );
+ }
+
+ if (data.remote_addr) {
+ await expect(page.getByLabel('Remote Address')).toHaveValue(
+ data.remote_addr
+ );
+ }
+
+ if (data.sni) {
+ await expect(page.getByLabel('SNI')).toHaveValue(data.sni);
+ }
+
+ if (data.desc) {
+ await expect(page.getByLabel('Description').first()).toHaveValue(data.desc);
+ }
+
+ if (data.labels) {
+ // Labels are displayed as tags, check if the tags exist
+ for (const [key, value] of Object.entries(data.labels)) {
+ const labelTag = page.getByText(`${key}:${value}`, { exact: true });
+ await expect(labelTag).toBeVisible();
+ }
+ }
+};
+
+export const uiFillStreamRouteAllFields = async (
+ page: Page,
+ upstreamSection: Locator,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ upstream?: {
+ nodes?: APISIXType['UpstreamNode'][];
+ retries?: number;
+ timeout?: {
+ connect?: number;
+ send?: number;
+ read?: number;
+ };
+ };
+ protocol?: {
+ name?: string;
+ superior_id?: string;
+ };
+ }
Review Comment:
fixed...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "DSingh0304 (via GitHub)" <gi...@apache.org>.
DSingh0304 commented on PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255#issuecomment-3550549300
Fixed e2e flakiness: added retry to [src/apis/upstreams.ts::deleteAllUpstreams](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) and increased timeouts in [stream_routes.ts](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html). I ran [CI=true pnpm e2e](vscode-file://vscode-app/usr/share/code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) locally all 27 tests passed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "DSingh0304 (via GitHub)" <gi...@apache.org>.
DSingh0304 commented on code in PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255#discussion_r2622055319
##########
src/apis/upstreams.ts:
##########
@@ -55,19 +55,56 @@ export const putUpstreamReq = (
};
export const deleteAllUpstreams = async (req: AxiosInstance) => {
- const totalRes = await getUpstreamListReq(req, {
- page: 1,
- page_size: PAGE_SIZE_MIN,
- });
+ // Retry wrapper to handle potential transient failures (e.g., 500 Internal Server Error) when fetching upstream list.
+ // This is particularly useful in E2E tests where rapid creation/deletion might cause temporary instability.
Review Comment:
I understand. I've removed the retry logic as requested, keeping only the 404 error handling to manage race conditions during parallel test execution cleanup.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "DSingh0304 (via GitHub)" <gi...@apache.org>.
DSingh0304 commented on PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255#issuecomment-3561550125
The CI is fixed; all tests are passing locally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "DSingh0304 (via GitHub)" <gi...@apache.org>.
DSingh0304 commented on code in PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255#discussion_r2548619489
##########
src/apis/upstreams.ts:
##########
@@ -55,17 +55,36 @@ export const putUpstreamReq = (
};
export const deleteAllUpstreams = async (req: AxiosInstance) => {
- const totalRes = await getUpstreamListReq(req, {
- page: 1,
- page_size: PAGE_SIZE_MIN,
- });
+ const retry = async <T>(fn: () => Promise<T>, times = 3, delay = 500) => {
+ let lastErr: unknown;
+ for (let i = 0; i < times; i++) {
+ try {
+ return await fn();
+ } catch (err) {
+ lastErr = err;
+ // small backoff
+
+ await new Promise((r) => setTimeout(r, delay));
+ }
+ }
+ throw lastErr;
+ };
+
+ const totalRes = await retry(() =>
+ getUpstreamListReq(req, {
+ page: 1,
+ page_size: PAGE_SIZE_MIN,
+ })
+ );
Review Comment:
Added retry logic to handle transient 500 errors during E2E test cleanup in CI. When tests rapidly create/delete resources, the backend can temporarily fail. The retry wrapper (with backoff) and 404 handling ensure cleanup doesn't fail due to these transient issues or race conditions in parallel test execution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: add stream route E2E tests with detail page flows [apisix-dashboard]
Posted by "SkyeYoung (via GitHub)" <gi...@apache.org>.
SkyeYoung commented on code in PR #3255:
URL: https://github.com/apache/apisix-dashboard/pull/3255#discussion_r2548279538
##########
package.json:
##########
@@ -97,5 +97,12 @@
"pnpm lint:fix"
]
},
- "packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
+ "packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39",
+ "pnpm": {
+ "onlyBuiltDependencies": [
+ "@swc/core",
+ "esbuild",
+ "unrs-resolver"
+ ]
Review Comment:
Do not modify parts unrelated to this PR.
##########
src/apis/upstreams.ts:
##########
@@ -55,17 +55,36 @@ export const putUpstreamReq = (
};
export const deleteAllUpstreams = async (req: AxiosInstance) => {
- const totalRes = await getUpstreamListReq(req, {
- page: 1,
- page_size: PAGE_SIZE_MIN,
- });
+ const retry = async <T>(fn: () => Promise<T>, times = 3, delay = 500) => {
+ let lastErr: unknown;
+ for (let i = 0; i < times; i++) {
+ try {
+ return await fn();
+ } catch (err) {
+ lastErr = err;
+ // small backoff
+
+ await new Promise((r) => setTimeout(r, delay));
+ }
+ }
+ throw lastErr;
+ };
+
+ const totalRes = await retry(() =>
+ getUpstreamListReq(req, {
+ page: 1,
+ page_size: PAGE_SIZE_MIN,
+ })
+ );
Review Comment:
Why? add comments pls.
##########
e2e/utils/ui/stream_routes.ts:
##########
@@ -0,0 +1,299 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import type { Locator, Page } from '@playwright/test';
+import { expect } from '@playwright/test';
+
+import type { APISIXType } from '@/types/schema/apisix';
+
+export const uiFillStreamRouteRequiredFields = async (
+ page: Page,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ }
+) => {
+ if (data.server_addr) {
+ await page
+ .getByLabel('Server Address', { exact: true })
+ .fill(data.server_addr);
+ }
+
+ if (data.server_port) {
+ await page
+ .getByLabel('Server Port', { exact: true })
+ .fill(data.server_port.toString());
+ }
+
+ if (data.remote_addr) {
+ await page.getByLabel('Remote Address').fill(data.remote_addr);
+ }
+
+ if (data.sni) {
+ await page.getByLabel('SNI').fill(data.sni);
+ }
+
+ if (data.desc) {
+ await page.getByLabel('Description').first().fill(data.desc);
+ }
+
+ if (data.labels) {
+ const labelsField = page.getByPlaceholder('Input text like `key:value`,').first();
+ for (const [key, value] of Object.entries(data.labels)) {
+ await labelsField.fill(`${key}:${value}`);
+ await labelsField.press('Enter');
+ }
+ }
+};
+
+export const uiCheckStreamRouteRequiredFields = async (
+ page: Page,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ }
+) => {
+ if (data.server_addr) {
+ await expect(page.getByLabel('Server Address', { exact: true })).toHaveValue(
+ data.server_addr
+ );
+ }
+
+ if (data.server_port) {
+ await expect(page.getByLabel('Server Port', { exact: true })).toHaveValue(
+ data.server_port.toString()
+ );
+ }
+
+ if (data.remote_addr) {
+ await expect(page.getByLabel('Remote Address')).toHaveValue(
+ data.remote_addr
+ );
+ }
+
+ if (data.sni) {
+ await expect(page.getByLabel('SNI')).toHaveValue(data.sni);
+ }
+
+ if (data.desc) {
+ await expect(page.getByLabel('Description').first()).toHaveValue(data.desc);
+ }
+
+ if (data.labels) {
+ // Labels are displayed as tags, check if the tags exist
+ for (const [key, value] of Object.entries(data.labels)) {
+ const labelTag = page.getByText(`${key}:${value}`, { exact: true });
+ await expect(labelTag).toBeVisible();
+ }
+ }
+};
+
+export const uiFillStreamRouteAllFields = async (
+ page: Page,
+ upstreamSection: Locator,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ upstream?: {
+ nodes?: APISIXType['UpstreamNode'][];
+ retries?: number;
+ timeout?: {
+ connect?: number;
+ send?: number;
+ read?: number;
+ };
+ };
+ protocol?: {
+ name?: string;
+ superior_id?: string;
+ };
+ }
+) => {
+ // Fill basic fields
+ await uiFillStreamRouteRequiredFields(page, {
+ server_addr: data.server_addr,
+ server_port: data.server_port,
+ remote_addr: data.remote_addr,
+ sni: data.sni,
+ desc: data.desc,
+ labels: data.labels,
+ });
+
+ // Fill upstream nodes
+ if (data.upstream?.nodes && data.upstream.nodes.length > 0) {
+ for (let i = 0; i < data.upstream.nodes.length; i++) {
+ const node = data.upstream.nodes[i];
+ const nodeRow = upstreamSection
+ .locator('section')
+ .filter({ hasText: 'Nodes' })
+ .getByRole('row')
+ .nth(i + 1);
+
+ await nodeRow.getByPlaceholder('Host').fill(node.host);
+ await nodeRow.getByPlaceholder('Port').fill(node.port.toString());
+ await nodeRow.getByPlaceholder('Weight').fill(node.weight.toString());
+
+ // Click add if there are more nodes to add
+ if (i < data.upstream.nodes.length - 1) {
+ await upstreamSection
+ .locator('section')
+ .filter({ hasText: 'Nodes' })
+ .getByRole('button', { name: 'Add' })
+ .click();
+ }
+ }
+ }
+
+ // Fill upstream retries
+ if (data.upstream?.retries !== undefined) {
+ await upstreamSection.getByLabel('Retries').fill(data.upstream.retries.toString());
+ }
+
+ // Fill upstream timeout
+ if (data.upstream?.timeout) {
+ if (data.upstream.timeout.connect !== undefined) {
+ await upstreamSection
+ .getByLabel('Connect', { exact: true })
+ .fill(data.upstream.timeout.connect.toString());
+ }
+ if (data.upstream.timeout.send !== undefined) {
+ await upstreamSection
+ .getByLabel('Send', { exact: true })
+ .fill(data.upstream.timeout.send.toString());
+ }
+ if (data.upstream.timeout.read !== undefined) {
+ await upstreamSection
+ .getByLabel('Read', { exact: true })
+ .fill(data.upstream.timeout.read.toString());
+ }
+ }
+
+ // Fill protocol fields
+ if (data.protocol?.name) {
+ await page.getByLabel('Protocol Name').fill(data.protocol.name);
+ }
+
+ if (data.protocol?.superior_id) {
+ await page.getByLabel('Superior ID').fill(data.protocol.superior_id);
+ }
+};
+
+export const uiCheckStreamRouteAllFields = async (
+ page: Page,
+ upstreamSection: Locator,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ upstream?: {
+ nodes?: APISIXType['UpstreamNode'][];
+ retries?: number;
+ timeout?: {
+ connect?: number;
+ send?: number;
+ read?: number;
+ };
+ };
+ protocol?: {
+ name?: string;
+ superior_id?: string;
+ };
+ }
Review Comment:
ditto
##########
e2e/utils/ui/stream_routes.ts:
##########
@@ -0,0 +1,299 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import type { Locator, Page } from '@playwright/test';
+import { expect } from '@playwright/test';
+
+import type { APISIXType } from '@/types/schema/apisix';
+
+export const uiFillStreamRouteRequiredFields = async (
+ page: Page,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ }
+) => {
+ if (data.server_addr) {
+ await page
+ .getByLabel('Server Address', { exact: true })
+ .fill(data.server_addr);
+ }
+
+ if (data.server_port) {
+ await page
+ .getByLabel('Server Port', { exact: true })
+ .fill(data.server_port.toString());
+ }
+
+ if (data.remote_addr) {
+ await page.getByLabel('Remote Address').fill(data.remote_addr);
+ }
+
+ if (data.sni) {
+ await page.getByLabel('SNI').fill(data.sni);
+ }
+
+ if (data.desc) {
+ await page.getByLabel('Description').first().fill(data.desc);
+ }
+
+ if (data.labels) {
+ const labelsField = page.getByPlaceholder('Input text like `key:value`,').first();
+ for (const [key, value] of Object.entries(data.labels)) {
+ await labelsField.fill(`${key}:${value}`);
+ await labelsField.press('Enter');
+ }
+ }
+};
+
+export const uiCheckStreamRouteRequiredFields = async (
+ page: Page,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ }
+) => {
+ if (data.server_addr) {
+ await expect(page.getByLabel('Server Address', { exact: true })).toHaveValue(
+ data.server_addr
+ );
+ }
+
+ if (data.server_port) {
+ await expect(page.getByLabel('Server Port', { exact: true })).toHaveValue(
+ data.server_port.toString()
+ );
+ }
+
+ if (data.remote_addr) {
+ await expect(page.getByLabel('Remote Address')).toHaveValue(
+ data.remote_addr
+ );
+ }
+
+ if (data.sni) {
+ await expect(page.getByLabel('SNI')).toHaveValue(data.sni);
+ }
+
+ if (data.desc) {
+ await expect(page.getByLabel('Description').first()).toHaveValue(data.desc);
+ }
+
+ if (data.labels) {
+ // Labels are displayed as tags, check if the tags exist
+ for (const [key, value] of Object.entries(data.labels)) {
+ const labelTag = page.getByText(`${key}:${value}`, { exact: true });
+ await expect(labelTag).toBeVisible();
+ }
+ }
+};
+
+export const uiFillStreamRouteAllFields = async (
+ page: Page,
+ upstreamSection: Locator,
+ data: {
+ server_addr?: string;
+ server_port?: number;
+ remote_addr?: string;
+ sni?: string;
+ desc?: string;
+ labels?: Record<string, string>;
+ upstream?: {
+ nodes?: APISIXType['UpstreamNode'][];
+ retries?: number;
+ timeout?: {
+ connect?: number;
+ send?: number;
+ read?: number;
+ };
+ };
+ protocol?: {
+ name?: string;
+ superior_id?: string;
+ };
+ }
Review Comment:
better use type from https://github.com/apache/apisix-dashboard/tree/master/src/types/schema
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org