-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
410 lines (399 loc) · 13 KB
/
Copy pathplaywright.config.ts
File metadata and controls
410 lines (399 loc) · 13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
/*
* Copyright 2024 Collate.
* Licensed 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 {
defineConfig,
devices,
type ReporterDescription,
} from '@playwright/test';
import dotenv from 'dotenv';
import { readFileSync } from 'fs';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
dotenv.config();
/**
* HTTP/2 (TLS) mode is opt-in via PW_PROTOCOL=h2. When set, the suite runs
* against the h2 connector configured in conf/openmetadata-h2-test.yaml on
* https://localhost:8585 with the self-signed cert under
* openmetadata-service/src/test/resources/localhost-h2.p12. The default
* `yarn playwright:run` flow is unaffected and still targets HTTP/1.1.
*/
const isH2Mode = process.env.PW_PROTOCOL === 'h2';
const defaultBaseURL = isH2Mode
? 'https://localhost:8585'
: 'http://localhost:8585';
const shardPlan = process.env.PW_SHARD_PLAN
? JSON.parse(readFileSync(process.env.PW_SHARD_PLAN, 'utf8'))
: undefined;
const hasDedicatedIngestionLane =
Boolean(shardPlan) || process.env.PW_DEDICATED_INGESTION === 'true';
const hasDedicatedImportExportLane =
Boolean(shardPlan) || process.env.PW_DEDICATED_IMPORT_EXPORT === 'true';
const isPlannedShard = Boolean(shardPlan);
const hasPreseededState = process.env.PW_PRESEEDED_STATE === 'true';
const authDependencies = hasPreseededState ? [] : ['setup'];
const entityDependencies = hasPreseededState
? []
: ['setup', 'entity-data-setup'];
const entityTeardown = hasPreseededState ? undefined : 'entity-data-teardown';
const shardGrep = shardPlan?.grep ? new RegExp(shardPlan.grep) : undefined;
const dedicatedStateTestIgnore = hasDedicatedIngestionLane
? [
'**/SearchSettings.spec.ts',
'**/SearchSeparation/**',
'**/*AfterReindex.spec.ts',
]
: [];
const combineGrep = (base?: RegExp) => {
if (!base) {
return shardGrep;
}
if (!shardGrep) {
return base;
}
return new RegExp(
`(?=.*(?:${base.source}))(?=.*(?:${shardGrep.source}))`,
[...new Set(`${base.flags}${shardGrep.flags}`)].join('')
);
};
const reporters: ReporterDescription[] = [
['list'],
...(!isPlannedShard
? [['html', { outputFolder: './playwright/output/playwright-report' }]]
: []),
[
'@estruyf/github-actions-reporter',
{
useDetails: true,
showError: true,
includeResults: ['skipped', 'fail', 'flaky'],
showArtifactsLink: true,
},
],
...(isPlannedShard
? [
[
'blob',
{
outputDir: './playwright/output/blob-report',
fileName: `report-${process.env.PW_SHARD_ID ?? 'local'}.zip`,
},
],
]
: [['blob']]),
['json', { outputFile: './playwright/output/results.json' }],
...(isPlannedShard
? [
[
'./playwright/reporters/PerformanceReporter.ts',
{ outputFile: './playwright/output/playwright-timings.json' },
],
]
: []),
];
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './playwright/e2e',
outputDir: './playwright/output/test-results',
// Omit {projectName} and {platform} from snapshot filenames so a single
// reference image works on both macOS dev machines and Linux CI runners.
// Edge lines in the lineage PNG are pure bezier geometry (no text/fonts)
// and render identically across platforms; the threshold in toMatchSnapshot
// absorbs any minor anti-aliasing differences in the node-card text areas.
snapshotPathTemplate:
'{testDir}/{testFileDir}/__snapshots__/{testFileName}-snapshots/{arg}{ext}',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 1 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI
? Number(process.env.PW_WORKERS ?? shardPlan?.workers ?? 3)
: undefined,
// Stop catastrophically broken shards after enough failures to establish
// that the run cannot be useful. Healthy runs never approach this limit.
maxFailures: 50,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: reporters,
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL || defaultBaseURL,
/* Self-signed cert in h2 mode — accept it. No effect on HTTP/1.1 runs. */
ignoreHTTPSErrors: isH2Mode,
/* Collect trace and video on every failure (not just retries) for debugging */
trace: 'on-first-retry',
screenshot: 'only-on-failure',
/* Add navigation timeout to prevent infinite hangs on networkidle waits.
* This ensures page.goto() and waitForLoadState() calls timeout after 60s
* instead of hanging indefinitely under resource pressure. */
navigationTimeout: 60000,
},
/* Configure projects for major browsers */
projects: [
{
name: 'bundle-smoke',
testMatch: '**/bundle.smoke.ts',
dependencies: authDependencies,
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/admin.json',
},
},
// Admin authentication setup doc: https://playwright.dev/docs/auth#multiple-signed-in-roles
{
name: 'setup',
testMatch: '**/auth.setup.ts',
},
{
name: 'entity-data-setup',
testMatch: '**/entity-data.setup.ts',
dependencies: ['setup'],
},
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
grep: shardGrep,
// Added admin setup as a dependency. This will authorize the page with an admin user before running the test. doc: https://playwright.dev/docs/auth#multiple-signed-in-roles
dependencies: entityDependencies,
grepInvert: [
/@data-insight/,
/@basic/,
...(hasDedicatedIngestionLane ? [/@ingestion/] : []),
...(hasDedicatedImportExportLane ? [/@import-export/] : []),
/@knowledge-graph/,
/@ontology-rdf/,
],
teardown: entityTeardown,
testIgnore: [
'**/nightly/**',
'**/Search/**',
'**/Auth/**',
'**/Http2/**',
'**/DataAssetRulesEnabled.spec.ts',
'**/DataAssetRulesDisabled.spec.ts',
'**/SystemCertificationTags.spec.ts',
'**/SearchRBAC.spec.ts',
'**/SSOLogin.spec.ts',
'**/IntakeForm.spec.ts',
...dedicatedStateTestIgnore,
'**/DomainIsolation/**',
],
},
// Only register the h2 project when explicitly opted in. Always-on registration would force
// Playwright to do discovery for it on every default run even though its spec files are
// skipped — small cost, but pointless when the h2 server isn't running.
...(isH2Mode
? [
{
name: 'chromium-h2',
testMatch: '**/Http2/**',
use: { ...devices['Desktop Chrome'] },
fullyParallel: true,
},
]
: []),
{
name: 'sso-auth',
testMatch: [
'**/OktaSelfSignupClaims.spec.ts',
'**/SSOLogin.spec.ts',
'**/SSORenewal.spec.ts',
],
use: { ...devices['Desktop Chrome'] },
fullyParallel: false,
workers: 1,
},
{
name: 'search-nightly',
testMatch: ['**/Search/**'],
grep: shardGrep,
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/admin.json',
},
dependencies: authDependencies,
},
{
name: 'entity-data-teardown',
testMatch: '**/entity-data.teardown.ts',
},
{
name: 'data-insight-application',
dependencies: ['setup', 'entity-data-setup'],
testMatch: '**/dataInsightApp.ts',
},
{
name: 'Data Insight',
use: { ...devices['Desktop Chrome'] },
dependencies: ['data-insight-application'],
grep: /data-insight/,
teardown: 'entity-data-teardown',
},
{
name: 'Knowledge Graph',
use: { ...devices['Desktop Chrome'] },
dependencies: ['setup', 'entity-data-setup'],
grep: /knowledge-graph/,
teardown: 'entity-data-teardown',
},
{
name: 'Ontology RDF',
use: { ...devices['Desktop Chrome'] },
dependencies: ['setup', 'entity-data-setup'],
grep: /ontology-rdf/,
teardown: 'entity-data-teardown',
},
{
name: 'DataAssetRulesEnabled',
testMatch: '**/DataAssetRulesEnabled.spec.ts',
grep: shardGrep,
use: { ...devices['Desktop Chrome'] },
dependencies: authDependencies,
fullyParallel: true,
},
{
name: 'DataAssetRulesDisabled',
testMatch: '**/DataAssetRulesDisabled.spec.ts',
grep: shardGrep,
use: { ...devices['Desktop Chrome'] },
dependencies: ['DataAssetRulesEnabled'],
fullyParallel: true,
},
{
name: 'search-rbac-setup',
testMatch: '**/search-rbac.setup.ts',
dependencies: authDependencies,
teardown: 'search-rbac-teardown',
},
{
name: 'search-rbac-teardown',
testMatch: '**/search-rbac.teardown.ts',
},
{
name: 'Basic',
grep: combineGrep(/@basic/),
testIgnore: dedicatedStateTestIgnore,
use: { ...devices['Desktop Chrome'] },
dependencies: entityDependencies,
fullyParallel: true,
},
...(hasDedicatedIngestionLane
? [
{
name: 'Ingestion',
grep: combineGrep(/@ingestion/),
testIgnore: '**/nightly/**',
use: { ...devices['Desktop Chrome'] },
dependencies: entityDependencies,
fullyParallel: false,
workers: 1,
teardown: entityTeardown,
},
]
: []),
...(hasDedicatedImportExportLane
? [
{
name: 'ImportExport',
grep: combineGrep(/@import-export/),
testIgnore: '**/nightly/**',
use: { ...devices['Desktop Chrome'] },
dependencies: entityDependencies,
fullyParallel: true,
workers: 2,
teardown: entityTeardown,
},
]
: []),
{
name: 'SearchRBAC',
testMatch: '**/SearchRBAC.spec.ts',
grep: shardGrep,
dependencies: ['search-rbac-setup'],
use: { ...devices['Desktop Chrome'] },
fullyParallel: false,
workers: 1,
},
// Domain isolation E2E suite (issue #24180). Runs in its own shard because several specs
// toggle the global `enableAccessControl` search setting; serial execution (workers: 1)
// prevents cross-file races on that shared setting.
{
name: 'DomainIsolation',
testMatch: '**/DomainIsolation/**',
grep: shardGrep,
use: { ...devices['Desktop Chrome'] },
dependencies: authDependencies,
fullyParallel: false,
workers: 1,
},
...(hasDedicatedIngestionLane
? [
{
name: 'Reindex',
testMatch: [
'**/SearchSeparation/*.spec.ts',
'**/*AfterReindex.spec.ts',
],
grep: shardGrep,
use: { ...devices['Desktop Chrome'] },
dependencies: authDependencies,
fullyParallel: false,
workers: 1,
},
{
name: 'GlobalSettings',
testMatch: '**/SearchSettings.spec.ts',
grep: shardGrep,
use: { ...devices['Desktop Chrome'] },
dependencies: authDependencies,
fullyParallel: false,
workers: 1,
},
]
: []),
// Each planned matrix job restores its own database/search clone. These projects
// share one single-worker job, while legacy runs retain the Chromium dependency
// because they share one mutable environment.
{
name: 'SystemCertificationTags',
testMatch: '**/SystemCertificationTags.spec.ts',
use: { ...devices['Desktop Chrome'] },
dependencies: isPlannedShard ? authDependencies : ['setup', 'chromium'],
grep: shardGrep,
fullyParallel: false,
},
{
name: 'IntakeForm',
testMatch: '**/IntakeForm.spec.ts',
use: { ...devices['Desktop Chrome'] },
dependencies: isPlannedShard ? authDependencies : ['setup', 'chromium'],
grep: shardGrep,
fullyParallel: false,
},
],
// Increase timeout for the test
timeout: 60000,
expect: { timeout: 15_000 },
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});