|
| 1 | +/** |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +/* eslint-disable playwright/no-wait-for-timeout -- regression test stabilization */ |
| 18 | + |
| 19 | +// Bulk D-03: with 1000 routes the list page must: |
| 20 | +// - render the first page within a reasonable budget |
| 21 | +// - allow URL-driven jump to a far page (e.g. ?page=50) |
| 22 | +// - not flood the Admin API with per-row requests |
| 23 | +// |
| 24 | +// Marked as `bulk` — exclude from default CI runs. |
| 25 | + |
| 26 | +import { routesPom } from '@e2e/pom/routes'; |
| 27 | +import { |
| 28 | + bulkCreateRoutes, |
| 29 | + bulkDeleteRoutesByPrefix, |
| 30 | +} from '@e2e/utils/bulk'; |
| 31 | +import { test } from '@e2e/utils/test'; |
| 32 | +import { expect } from '@playwright/test'; |
| 33 | + |
| 34 | +const PREFIX = 'bulk1k'; |
| 35 | +const COUNT = 1000; |
| 36 | + |
| 37 | +test.describe.configure({ mode: 'serial', timeout: 300_000 }); |
| 38 | + |
| 39 | +test.beforeAll(async () => { |
| 40 | + await bulkDeleteRoutesByPrefix(PREFIX); |
| 41 | + await bulkCreateRoutes({ count: COUNT, prefix: PREFIX }); |
| 42 | +}); |
| 43 | + |
| 44 | +test.afterAll(async () => { |
| 45 | + await bulkDeleteRoutesByPrefix(PREFIX); |
| 46 | +}); |
| 47 | + |
| 48 | +test('first page renders within 5s with 1000 rows in etcd', async ({ |
| 49 | + page, |
| 50 | +}) => { |
| 51 | + const t0 = Date.now(); |
| 52 | + await routesPom.toIndex(page); |
| 53 | + await routesPom.isIndexPage(page); |
| 54 | + |
| 55 | + await expect( |
| 56 | + page |
| 57 | + .getByRole('row', { name: new RegExp(`${PREFIX}-\\d+`) }) |
| 58 | + .first() |
| 59 | + ).toBeVisible({ timeout: 8000 }); |
| 60 | + const ms = Date.now() - t0; |
| 61 | + test |
| 62 | + .info() |
| 63 | + .annotations.push({ type: 'perf', description: `first-page render: ${ms}ms` }); |
| 64 | + expect(ms).toBeLessThan(8000); |
| 65 | +}); |
| 66 | + |
| 67 | +test('admin API call volume on list page load is bounded (≤ 5 GETs)', async ({ |
| 68 | + page, |
| 69 | +}) => { |
| 70 | + const adminCalls: string[] = []; |
| 71 | + page.on('request', (req) => { |
| 72 | + if (req.method() === 'GET' && req.url().includes('/apisix/admin/routes')) { |
| 73 | + adminCalls.push(req.url()); |
| 74 | + } |
| 75 | + }); |
| 76 | + |
| 77 | + await routesPom.toIndex(page); |
| 78 | + await routesPom.isIndexPage(page); |
| 79 | + await expect( |
| 80 | + page |
| 81 | + .getByRole('row', { name: new RegExp(`${PREFIX}-\\d+`) }) |
| 82 | + .first() |
| 83 | + ).toBeVisible({ timeout: 8000 }); |
| 84 | + // Settle for any deferred queries. |
| 85 | + await page.waitForTimeout(800); |
| 86 | + |
| 87 | + test.info().annotations.push({ |
| 88 | + type: 'perf', |
| 89 | + description: `admin /routes GETs: ${adminCalls.length}`, |
| 90 | + }); |
| 91 | + expect( |
| 92 | + adminCalls.length, |
| 93 | + 'list page should not issue per-row GETs (≤ 5 total)' |
| 94 | + ).toBeLessThanOrEqual(5); |
| 95 | +}); |
0 commit comments