Skip to content

Commit

Permalink
perf: Parallelize non ledger operation tests (#568)
Browse files Browse the repository at this point in the history
* perf: Parallelize non ledger operation tests

* fix testDir

* Run in different ports

* Debug

* Run sequential

* Fully parallel

* Use one playwright config file
  • Loading branch information
DaevMithran authored Aug 7, 2024
1 parent 9601174 commit 4d3ad9d
Show file tree
Hide file tree
Showing 27 changed files with 86 additions and 242 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"lint": "eslint --max-warnings=0 src && prettier --check '**/*.{js,ts,cjs,mjs,json}'",
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:e2e": "npx playwright test -c playwright.config.ts",
"test:e2e": "TEST_MODE_PARALLEL=true npx playwright test -c playwright.config.ts && npx playwright test -c playwright.config.ts",
"typeorm": "typeorm-ts-node-esm -d ./dist/database/ormconfig.js",
"generate": "npm run typeorm migration:generate .",
"migrate": "npm run typeorm migration:run"
Expand Down
95 changes: 60 additions & 35 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,53 +49,78 @@ export default defineConfig({

// Whether to run tests in parallel
// Docs: https://playwright.dev/docs/api/class-testconfig#test-config-fully-parallel
fullyParallel: false,
fullyParallel: process.env.TEST_MODE_PARALLEL === 'true' ? true : false,

// Number of parallel workers OR %age of logical CPUs to use
// Github Actions runners have 2 logical CPU cores
// Defaults to half of the logical CPU cores available
// Docs: https://playwright.dev/docs/api/class-testconfig#test-config-workers
workers: process.env.CI ? 1 : undefined,
workers: process.env.TEST_MODE_PARALLEL ? 4 : 1,

// Limit the numbers of failures to set a fail-fast strategy on CI
// Docs: https://playwright.dev/docs/api/class-testconfig#test-config-max-failures
maxFailures: process.env.CI ? 5 : undefined,

// Configure project specific settings
// Docs: https://playwright.dev/docs/test-projects
projects: [
{
name: 'Setup unauthenticated user',
testMatch: /no-auth\.setup\.ts/,
},
{
name: 'Setup authenticated user',
testMatch: /auth\.setup\.ts/,
},
{
name: 'Logged In User Tests',
...(process.env.RELEASE === 'true' ? {} : { testIgnore: /.*\.release\.spec\.ts/ }),
use: {
...devices['Desktop Chrome'],
// Use prepared auth state.
storageState: STORAGE_STATE_AUTHENTICATED,
extraHTTPHeaders: {
// Add x-api-key token to all authenticated requests.
'x-api-key': `${process.env.TEST_USER_API_KEY}`,
},
},
dependencies: ['Setup authenticated user'],
},
{
name: 'Non-Logged In User Tests',
testMatch: /.*\.no-auth.spec.ts/,
use: {
...devices['Desktop Chrome'],
storageState: STORAGE_STATE_UNAUTHENTICATED,
},
dependencies: ['Setup unauthenticated user'],
},
],
projects:
process.env.TEST_MODE_PARALLEL === 'true'
? [
{
name: 'Setup unauthenticated user',
testMatch: /no-auth\.setup\.ts/,
},
{
name: 'Setup authenticated user',
testMatch: /auth\.setup\.ts/,
},
{
name: 'Parallel Logged In User Tests',
...(process.env.RELEASE === 'true' ? {} : { testIgnore: /.*\.release\.spec\.ts/ }),
use: {
...devices['Desktop Chrome'],
// Use prepared auth state.
storageState: STORAGE_STATE_AUTHENTICATED,
extraHTTPHeaders: {
// Add x-api-key token to all authenticated requests.
'x-api-key': `${process.env.TEST_USER_API_KEY}`,
},
},
testDir: './tests/e2e/parallel',
dependencies: ['Setup authenticated user'],
},
{
name: 'Non-Logged In User Tests',
testMatch: /.*\.no-auth.spec.ts/,
use: {
...devices['Desktop Chrome'],
storageState: STORAGE_STATE_UNAUTHENTICATED,
},
testDir: './tests/e2e/parallel',
dependencies: ['Setup unauthenticated user'],
},
]
: [
{
name: 'Setup authenticated user',
testMatch: /auth\.setup\.ts/,
},
{
name: 'Logged In User Tests',
...(process.env.RELEASE === 'true' ? {} : { testIgnore: /.*\.release\.spec\.ts/ }),
use: {
...devices['Desktop Chrome'],
// Use prepared auth state.
storageState: STORAGE_STATE_AUTHENTICATED,
extraHTTPHeaders: {
// Add x-api-key token to all authenticated requests.
'x-api-key': `${process.env.TEST_USER_API_KEY}`,
},
},
testDir: './tests/e2e/sequential',
dependencies: ['Setup authenticated user'],
},
],

// Timeout for each test in milliseconds
// Docs: https://playwright.dev/docs/test-timeouts
Expand Down
25 changes: 0 additions & 25 deletions tests/e2e/credential/issue-negative.spec.ts

This file was deleted.

130 changes: 0 additions & 130 deletions tests/e2e/credential/issue-verify-flow.spec.ts

This file was deleted.

25 changes: 0 additions & 25 deletions tests/e2e/credential/reinstate-negative.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
NOT_EXISTENT_STATUS_LIST_NAME,
DEFAULT_STATUS_LIST_UNENCRYPTED_NAME,
STORAGE_STATE_AUTHENTICATED,
} from '../constants';
} from '../../constants';
import { test, expect } from '@playwright/test';
import { StatusCodes } from 'http-status-codes';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PAYLOADS_PATH,
STORAGE_STATE_AUTHENTICATED,
DEFAULT_DOES_NOT_HAVE_PERMISSIONS,
} from '../constants';
} from '../../constants';
import * as fs from 'fs';
import { test, expect } from '@playwright/test';
import { StatusCodes } from 'http-status-codes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PAYLOADS_PATH,
STORAGE_STATE_AUTHENTICATED,
DEFAULT_DOES_NOT_HAVE_PERMISSIONS,
} from '../constants';
} from '../../constants';
import * as fs from 'fs';
import { test, expect } from '@playwright/test';
import { StatusCodes } from 'http-status-codes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
STORAGE_STATE_UNAUTHENTICATED,
DEFAULT_STATUS_LIST_UNENCRYPTED_NAME,
DEFAULT_TESTNET_DID_IDENTIFIER,
} from '../constants';
} from '../../constants';
import { test, expect } from '@playwright/test';
import { StatusCodes } from 'http-status-codes';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PAYLOADS_PATH,
STORAGE_STATE_AUTHENTICATED,
DEFAULT_DOES_NOT_HAVE_PERMISSIONS,
} from '../constants';
} from '../../constants';
import * as fs from 'fs';
import { test, expect } from '@playwright/test';
import { StatusCodes } from 'http-status-codes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PAYLOADS_PATH,
STORAGE_STATE_AUTHENTICATED,
DEFAULT_DOES_NOT_HAVE_PERMISSIONS,
} from '../constants';
} from '../../constants';
import * as fs from 'fs';
import { test, expect } from '@playwright/test';
import { StatusCodes } from 'http-status-codes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PAYLOADS_PATH,
STORAGE_STATE_AUTHENTICATED,
DEFAULT_DOES_NOT_HAVE_PERMISSIONS,
} from '../constants';
} from '../../constants';
import * as fs from 'fs';
import { test, expect } from '@playwright/test';
import { StatusCodes } from 'http-status-codes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
PAYLOADS_PATH,
STORAGE_STATE_AUTHENTICATED,
DEFAULT_DOES_NOT_HAVE_PERMISSIONS,
} from '../constants';
} from '../../constants';
import * as fs from 'fs';
import { test, expect } from '@playwright/test';
import { StatusCodes } from 'http-status-codes';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CONTENT_TYPE, INVALID_JWT_TOKEN, GENERATED_PATH, STORAGE_STATE_UNAUTHENTICATED } from '../constants';
import { CONTENT_TYPE, INVALID_JWT_TOKEN, GENERATED_PATH, STORAGE_STATE_UNAUTHENTICATED } from '../../constants';
import * as fs from 'fs';
import { test, expect } from '@playwright/test';
import { StatusCodes } from 'http-status-codes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
NOT_SUPPORTED_VERIFICATION_METHOD_TYPE,
PAYLOADS_PATH,
CONTENT_TYPE,
} from '../constants';
} from '../../constants';
import * as fs from 'fs';
import { v4 } from 'uuid';
import { test, expect } from '@playwright/test';
Expand Down
Loading

0 comments on commit 4d3ad9d

Please sign in to comment.