mirror of
https://github.com/civitai/civitai.git
synced 2026-09-20 22:08:18 +08:00
8942b54f8c
* test(preview): pre-warm all heavy pages + 2 retries (kill the slow-window flake) The dominant smoke flake is a cold/slow-window page.goto timeout on a heavy SSR page — the offender rotates (/, /models, /user/membership, /generate, /purchase/buzz, /moderator/*) depending on which page the slow window hits. Two-pronged: - Pre-warm EVERY heavy page the suite navigates in preview-auth.setup.ts (was only /, /models, /images). Each route JIT-compiles on first hit, so warming them up front (gold cookie for member pages, mod cookie for /moderator/*) removes the cold-start cost that caused most flakes. Sequential + best-effort (a slow warm GET still triggers the server-side compile). - retries 1 -> 2: a 2nd retry covers the residual mid-run slow window so it flakes-and-recovers instead of surfacing as a failure. Pairs with the 60s->90s timeout raise (#2480). Together these target a consistently-clean run — a prerequisite for eventually flipping smoke to gating. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(preview): raise setup timeout for cold-pod sequential warm-up (pr-review) Addresses the pr-reviewer finding on this PR: the 8+ sequential warm-up GETs (each 60s-capped) can, on a genuinely cold pod, cumulatively exceed the suite's 90s per-test timeout → the setup test times out → ALL dependent smoke tests are SKIPPED (worse than the flake this PR fixes). The passing run only saw 1.7s because the pod was already warm from verify-preview. Fix: setup.setTimeout(480_000) — a ceiling for worst-case cold sequential warm-up. Kept sequential (parallel heavy SSR renders OOM the single-replica pod, per the config comment — the OOM is about concurrent renders, not specifically playwright workers, so concurrent HTTP GETs are NOT a safe alternative here). The ceiling doesn't slow the normal path: the setup still finishes as fast as the warm-ups actually take. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
69 lines
3.4 KiB
TypeScript
69 lines
3.4 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
|
|
/**
|
|
* Playwright config for smoke-testing a DEPLOYED PR preview environment.
|
|
*
|
|
* Used by the datapacket-talos `pr-smoke-test` Tekton task, not local dev. Unlike
|
|
* playwright.config.ts there is no `webServer` — we hit the live preview at
|
|
* PREVIEW_URL (e.g. https://pr-1234.civitaic.com). Auth is minted by
|
|
* tests/preview-auth.setup.ts (no /testing/testing-login, which is dead under a
|
|
* production build). Requires env: PREVIEW_URL, NEXTAUTH_SECRET.
|
|
*
|
|
* Run: PREVIEW_URL=… NEXTAUTH_SECRET=… npx playwright test -c playwright.preview.config.ts
|
|
*/
|
|
|
|
const PREVIEW_URL = process.env.PREVIEW_URL;
|
|
if (!PREVIEW_URL) {
|
|
throw new Error('PREVIEW_URL is required for playwright.preview.config.ts');
|
|
}
|
|
|
|
export default defineConfig({
|
|
testDir: './tests',
|
|
// Anchor to the FILENAME (after a path separator) — an unanchored /preview-…/
|
|
// also matches a parent dir named like a worktree (…/civitai-preview-x/), which
|
|
// would wrongly pull in the non-preview specs (auction/generation/example).
|
|
testMatch: /(^|\/)preview-.*\.(setup|spec)\.ts$/,
|
|
fullyParallel: false,
|
|
forbidOnly: !!process.env.CI,
|
|
// 2 retries (was 1): the preview pod can hit a transient CPU-throttle window on a
|
|
// contended node; with pre-warm (preview-auth.setup.ts) covering cold-start, the
|
|
// residual flake is a mid-run slow window. A 2nd retry gives it another recovery
|
|
// chance so a slow window flakes-and-recovers instead of surfacing as a failure.
|
|
retries: process.env.CI ? 2 : 0,
|
|
// Run SERIALLY. The preview is a single-replica, cold, resource-modest pod.
|
|
// Concurrent loads of the heavy pages (/models, /images, /purchase/buzz,
|
|
// /pricing, model detail) across multiple workers segfaulted it (exit 139),
|
|
// which cascaded fast failures into unrelated tests. One page at a time lets
|
|
// the pod cope; the suite is small + report-only, so serial (~2-3 min) is fine.
|
|
workers: 1,
|
|
// A freshly-deployed preview is cold: the first SSR render of a heavy page (the
|
|
// homepage especially) can take 30-40s while the Next server warms, JIT-compiles,
|
|
// and opens DB pools. The default 30s per-test timeout is too tight for that cold
|
|
// first hit, so raise both the per-test and navigation timeouts. The setup project
|
|
// also fires a warm-up request before the suite (preview-auth.setup.ts).
|
|
// 90s (was 60s): on a contended preview node the single-replica pod gets CPU-
|
|
// throttled and the heaviest SSR pages (/user/membership, /models) intermittently
|
|
// crossed the 60s ceiling (observed ~66s) — a slow window should flake-and-recover
|
|
// on retry, not hard-fail. 90s gives comfortable margin without masking a real hang.
|
|
timeout: 90_000,
|
|
reporter: [['list'], ['html', { open: 'never', outputFolder: 'playwright-report' }]],
|
|
use: {
|
|
baseURL: PREVIEW_URL,
|
|
trace: 'on-first-retry',
|
|
screenshot: 'only-on-failure',
|
|
// Align with the per-test timeout: a cold heavy-page (/models) goto can need
|
|
// most of the budget, and a tighter nav cap would fail it even though the test
|
|
// has 90s. The setup project also pre-warms /models + /images authenticated.
|
|
navigationTimeout: 90_000,
|
|
},
|
|
projects: [
|
|
{ name: 'preview-setup', testMatch: /(^|\/)preview-auth\.setup\.ts$/ },
|
|
{
|
|
name: 'preview-smoke',
|
|
testMatch: /(^|\/)preview-.*\.spec\.ts$/,
|
|
dependencies: ['preview-setup'],
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
],
|
|
});
|