mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-31 22:10:42 +02:00
Increase e2e test timeouts on CI to fix flaky tests (#37053)
Introduce a `GITEA_TEST_E2E_TIMEOUT_FACTOR` env var (3 on CI, 1 locally, overridable) to scale Playwright e2e timeouts, fixing flaky tests like `logout propagation` that timed out waiting for SSE event propagation on slow CI runners. | Timeout | Before (local) | After (local) | Before (CI) | After (CI) | |---|---|---|---|---| | expect | 3000 | 5000 | 6000 | 15000 | | action | 3000 | 5000 | 6000 | 15000 | | test | 6000 | 10000 | 12000 | 30000 | | navigation | 6000 | 10000 | 12000 | 30000 | --- This PR was written with the help of Claude Opus 4.6 --------- Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com>
This commit is contained in:
parent
d288b4529b
commit
f8d14b77eb
@ -198,10 +198,11 @@ Here's how to run the test suite:
|
||||
|
||||
- E2E test environment variables
|
||||
|
||||
| Variable | Description |
|
||||
| :------------------------ | :---------------------------------------------------------------- |
|
||||
| ``GITEA_TEST_E2E_DEBUG`` | When set, show Gitea server output |
|
||||
| ``GITEA_TEST_E2E_FLAGS`` | Additional flags passed to Playwright, for example ``--ui`` |
|
||||
| Variable | Description |
|
||||
| :-------------------------------- | :---------------------------------------------------------- |
|
||||
| ``GITEA_TEST_E2E_DEBUG`` | When set, show Gitea server output |
|
||||
| ``GITEA_TEST_E2E_FLAGS`` | Additional flags passed to Playwright, for example ``--ui`` |
|
||||
| ``GITEA_TEST_E2E_TIMEOUT_FACTOR`` | Timeout multiplier (default: 3 on CI, 1 locally) |
|
||||
|
||||
## Translation
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import {env} from 'node:process';
|
||||
import {defineConfig, devices} from '@playwright/test';
|
||||
const timeoutFactor = Number(env.GITEA_TEST_E2E_TIMEOUT_FACTOR) || 1;
|
||||
const timeout = 5000 * timeoutFactor;
|
||||
|
||||
export default defineConfig({
|
||||
testDir: './tests/e2e/',
|
||||
@ -7,15 +9,15 @@ export default defineConfig({
|
||||
testMatch: /.*\.test\.ts/,
|
||||
forbidOnly: Boolean(env.CI),
|
||||
reporter: 'list',
|
||||
timeout: env.CI ? 12000 : 6000,
|
||||
timeout: 2 * timeout,
|
||||
expect: {
|
||||
timeout: env.CI ? 6000 : 3000,
|
||||
timeout,
|
||||
},
|
||||
use: {
|
||||
baseURL: env.GITEA_TEST_E2E_URL?.replace?.(/\/$/g, ''),
|
||||
locale: 'en-US',
|
||||
actionTimeout: env.CI ? 6000 : 3000,
|
||||
navigationTimeout: env.CI ? 12000 : 6000,
|
||||
actionTimeout: timeout,
|
||||
navigationTimeout: 2 * timeout,
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {test, expect} from '@playwright/test';
|
||||
import {loginUser, baseUrl, apiUserHeaders, apiCreateUser, apiDeleteUser, apiCreateRepo, apiCreateIssue, apiStartStopwatch} from './utils.ts';
|
||||
import {loginUser, baseUrl, apiUserHeaders, apiCreateUser, apiDeleteUser, apiCreateRepo, apiCreateIssue, apiStartStopwatch, timeoutFactor} from './utils.ts';
|
||||
|
||||
// These tests rely on a short EVENT_SOURCE_UPDATE_TIME in the e2e server config.
|
||||
test.describe('events', () => {
|
||||
@ -23,7 +23,7 @@ test.describe('events', () => {
|
||||
await apiCreateIssue(request, owner, repoName, {title: 'events notification test', headers: apiUserHeaders(commenter)});
|
||||
|
||||
// Wait for the notification badge to appear via server event
|
||||
await expect(badge).toBeVisible({timeout: 15000});
|
||||
await expect(badge).toBeVisible({timeout: 15000 * timeoutFactor});
|
||||
|
||||
// Cleanup
|
||||
await Promise.all([apiDeleteUser(request, commenter), apiDeleteUser(request, owner)]);
|
||||
|
||||
@ -3,6 +3,8 @@ import {env} from 'node:process';
|
||||
import {expect} from '@playwright/test';
|
||||
import type {APIRequestContext, Locator, Page} from '@playwright/test';
|
||||
|
||||
export const timeoutFactor = Number(env.GITEA_TEST_E2E_TIMEOUT_FACTOR) || 1;
|
||||
|
||||
export function baseUrl() {
|
||||
return env.GITEA_TEST_E2E_URL?.replace(/\/$/g, '');
|
||||
}
|
||||
|
||||
@ -88,10 +88,20 @@ GITEA_TEST_E2E_EMAIL="$GITEA_TEST_E2E_USER@$GITEA_TEST_E2E_DOMAIN"
|
||||
--must-change-password=false \
|
||||
--admin
|
||||
|
||||
# timeout multiplier, CI runners are slower
|
||||
if [ -z "${GITEA_TEST_E2E_TIMEOUT_FACTOR:-}" ]; then
|
||||
if [ -n "${CI:-}" ]; then
|
||||
GITEA_TEST_E2E_TIMEOUT_FACTOR=3
|
||||
else
|
||||
GITEA_TEST_E2E_TIMEOUT_FACTOR=1
|
||||
fi
|
||||
fi
|
||||
|
||||
export GITEA_TEST_E2E_URL="$E2E_URL"
|
||||
export GITEA_TEST_E2E_DOMAIN
|
||||
export GITEA_TEST_E2E_USER
|
||||
export GITEA_TEST_E2E_PASSWORD
|
||||
export GITEA_TEST_E2E_EMAIL
|
||||
export GITEA_TEST_E2E_TIMEOUT_FACTOR
|
||||
|
||||
pnpm exec playwright test "$@"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user