chore: remove worker isolation options (#20176)

This commit is contained in:
Pavel Feldman 2023-01-17 17:38:44 -08:00 committed by GitHub
parent d9d4070520
commit 3fd0530076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 11 additions and 31 deletions

View File

@ -483,7 +483,6 @@ export const baseFullConfig: FullConfigInternal = {
_storeDir: '', _storeDir: '',
_maxConcurrentTestGroups: 0, _maxConcurrentTestGroups: 0,
_ignoreSnapshots: false, _ignoreSnapshots: false,
_workerIsolation: 'isolate-pools',
_globalScripts: null, _globalScripts: null,
_globalProject: { } as FullProjectInternal, _globalProject: { } as FullProjectInternal,
}; };

View File

@ -439,7 +439,7 @@ export class Dispatcher {
} }
_createWorker(testGroup: TestGroup, parallelIndex: number, loaderData: SerializedLoaderData) { _createWorker(testGroup: TestGroup, parallelIndex: number, loaderData: SerializedLoaderData) {
const worker = new WorkerHost(testGroup, parallelIndex, this._configLoader.fullConfig()._workerIsolation, loaderData); const worker = new WorkerHost(testGroup, parallelIndex, loaderData);
const handleOutput = (params: TestOutputPayload) => { const handleOutput = (params: TestOutputPayload) => {
const chunk = chunkFromParams(params); const chunk = chunkFromParams(params);
if (worker.didFail()) { if (worker.didFail()) {

View File

@ -29,11 +29,6 @@ export type TtyParams = {
colorDepth: number; colorDepth: number;
}; };
export type WorkerIsolation =
'isolate-projects' | // create new worker for new project type
'isolate-pools'; // create new worker for new worker fixture pool digest
export type ProcessInitParams = { export type ProcessInitParams = {
stdoutParams: TtyParams; stdoutParams: TtyParams;
stderrParams: TtyParams; stderrParams: TtyParams;
@ -41,7 +36,6 @@ export type ProcessInitParams = {
}; };
export type WorkerInitParams = { export type WorkerInitParams = {
workerIsolation: WorkerIsolation;
workerIndex: number; workerIndex: number;
parallelIndex: number; parallelIndex: number;
repeatEachIndex: number; repeatEachIndex: number;

View File

@ -18,7 +18,6 @@ import * as path from 'path';
import { calculateSha1 } from 'playwright-core/lib/utils'; import { calculateSha1 } from 'playwright-core/lib/utils';
import { FixturePool, isFixtureOption } from './fixtures'; import { FixturePool, isFixtureOption } from './fixtures';
import { setCurrentlyLoadingFileSuite } from './globals'; import { setCurrentlyLoadingFileSuite } from './globals';
import type { WorkerIsolation } from './ipc';
import { Suite, type TestCase } from './test'; import { Suite, type TestCase } from './test';
import type { TestTypeImpl } from './testType'; import type { TestTypeImpl } from './testType';
import { requireOrImport } from './transform'; import { requireOrImport } from './transform';
@ -86,7 +85,7 @@ export class TestLoader {
if (!this._projectSuiteBuilders.has(project)) if (!this._projectSuiteBuilders.has(project))
this._projectSuiteBuilders.set(project, new ProjectSuiteBuilder(project)); this._projectSuiteBuilders.set(project, new ProjectSuiteBuilder(project));
const builder = this._projectSuiteBuilders.get(project)!; const builder = this._projectSuiteBuilders.get(project)!;
return builder.cloneFileSuite(suite, 'isolate-pools', repeatEachIndex, filter); return builder.cloneFileSuite(suite, repeatEachIndex, filter);
} }
} }
@ -133,14 +132,14 @@ class ProjectSuiteBuilder {
return this._testPools.get(test)!; return this._testPools.get(test)!;
} }
private _cloneEntries(from: Suite, to: Suite, workerIsolation: WorkerIsolation, repeatEachIndex: number, filter: (test: TestCase) => boolean): boolean { private _cloneEntries(from: Suite, to: Suite, repeatEachIndex: number, filter: (test: TestCase) => boolean): boolean {
for (const entry of from._entries) { for (const entry of from._entries) {
if (entry instanceof Suite) { if (entry instanceof Suite) {
const suite = entry._clone(); const suite = entry._clone();
suite._fileId = to._fileId; suite._fileId = to._fileId;
to._addSuite(suite); to._addSuite(suite);
// Ignore empty titles, similar to Suite.titlePath(). // Ignore empty titles, similar to Suite.titlePath().
if (!this._cloneEntries(entry, suite, workerIsolation, repeatEachIndex, filter)) { if (!this._cloneEntries(entry, suite, repeatEachIndex, filter)) {
to._entries.pop(); to._entries.pop();
to.suites.pop(); to.suites.pop();
} }
@ -166,10 +165,7 @@ class ProjectSuiteBuilder {
to.tests.pop(); to.tests.pop();
} else { } else {
const pool = this._buildPool(entry); const pool = this._buildPool(entry);
if (this._project._fullConfig._workerIsolation === 'isolate-pools') test._workerHash = `run${this._project._id}-${pool.digest}-repeat${repeatEachIndex}`;
test._workerHash = `run${this._project._id}-${pool.digest}-repeat${repeatEachIndex}`;
else
test._workerHash = `run${this._project._id}-repeat${repeatEachIndex}`;
test._pool = pool; test._pool = pool;
} }
} }
@ -179,11 +175,11 @@ class ProjectSuiteBuilder {
return true; return true;
} }
cloneFileSuite(suite: Suite, workerIsolation: WorkerIsolation, repeatEachIndex: number, filter: (test: TestCase) => boolean): Suite | undefined { cloneFileSuite(suite: Suite, repeatEachIndex: number, filter: (test: TestCase) => boolean): Suite | undefined {
const result = suite._clone(); const result = suite._clone();
const relativeFile = path.relative(this._project.testDir, suite.location!.file).split(path.sep).join('/'); const relativeFile = path.relative(this._project.testDir, suite.location!.file).split(path.sep).join('/');
result._fileId = calculateSha1(relativeFile).slice(0, 20); result._fileId = calculateSha1(relativeFile).slice(0, 20);
return this._cloneEntries(suite, result, workerIsolation, repeatEachIndex, filter) ? result : undefined; return this._cloneEntries(suite, result, repeatEachIndex, filter) ? result : undefined;
} }
private _applyConfigUseOptions(testType: TestTypeImpl, configUse: Fixtures): FixturesWithLocation[] { private _applyConfigUseOptions(testType: TestTypeImpl, configUse: Fixtures): FixturesWithLocation[] {

View File

@ -229,7 +229,7 @@ export async function requireOrImport(file: string) {
} }
} }
export function installTransform(): () => void { function installTransform(): () => void {
let reverted = false; let reverted = false;
const originalResolveFilename = (Module as any)._resolveFilename; const originalResolveFilename = (Module as any)._resolveFilename;

View File

@ -16,7 +16,6 @@
import type { Fixtures, TestInfoError, Project } from '../types/test'; import type { Fixtures, TestInfoError, Project } from '../types/test';
import type { Location, Reporter } from '../types/testReporter'; import type { Location, Reporter } from '../types/testReporter';
import type { WorkerIsolation } from './ipc';
import type { FullConfig as FullConfigPublic, FullProject as FullProjectPublic } from './types'; import type { FullConfig as FullConfigPublic, FullProject as FullProjectPublic } from './types';
export * from '../types/test'; export * from '../types/test';
export type { Location } from '../types/testReporter'; export type { Location } from '../types/testReporter';
@ -48,7 +47,6 @@ export interface FullConfigInternal extends FullConfigPublic {
_storeDir: string; _storeDir: string;
_maxConcurrentTestGroups: number; _maxConcurrentTestGroups: number;
_ignoreSnapshots: boolean; _ignoreSnapshots: boolean;
_workerIsolation: WorkerIsolation;
/** /**
* If populated, this should also be the first/only entry in _webServers. Legacy singleton `webServer` as well as those provided via an array in the user-facing playwright.config.{ts,js} will be in `_webServers`. The legacy field (`webServer`) field additionally stores the backwards-compatible singleton `webServer` since it had been showing up in globalSetup to the user. * If populated, this should also be the first/only entry in _webServers. Legacy singleton `webServer` as well as those provided via an array in the user-facing playwright.config.{ts,js} will be in `_webServers`. The legacy field (`webServer`) field additionally stores the backwards-compatible singleton `webServer` since it had been showing up in globalSetup to the user.
*/ */

View File

@ -15,7 +15,7 @@
*/ */
import type { TestGroup } from './dispatcher'; import type { TestGroup } from './dispatcher';
import type { RunPayload, SerializedLoaderData, WorkerInitParams, WorkerIsolation } from './ipc'; import type { RunPayload, SerializedLoaderData, WorkerInitParams } from './ipc';
import { ProcessHost } from './processHost'; import { ProcessHost } from './processHost';
let lastWorkerIndex = 0; let lastWorkerIndex = 0;
@ -27,7 +27,7 @@ export class WorkerHost extends ProcessHost<WorkerInitParams> {
currentTestId: string | null = null; currentTestId: string | null = null;
private _params: WorkerInitParams; private _params: WorkerInitParams;
constructor(testGroup: TestGroup, parallelIndex: number, workerIsolation: WorkerIsolation, loader: SerializedLoaderData) { constructor(testGroup: TestGroup, parallelIndex: number, loader: SerializedLoaderData) {
const workerIndex = lastWorkerIndex++; const workerIndex = lastWorkerIndex++;
super(require.resolve('./workerRunner.js'), `worker-${workerIndex}`); super(require.resolve('./workerRunner.js'), `worker-${workerIndex}`);
this.workerIndex = workerIndex; this.workerIndex = workerIndex;
@ -35,7 +35,6 @@ export class WorkerHost extends ProcessHost<WorkerInitParams> {
this._hash = testGroup.workerHash; this._hash = testGroup.workerHash;
this._params = { this._params = {
workerIsolation,
workerIndex: this.workerIndex, workerIndex: this.workerIndex,
parallelIndex, parallelIndex,
repeatEachIndex: testGroup.repeatEachIndex, repeatEachIndex: testGroup.repeatEachIndex,

View File

@ -262,14 +262,8 @@ export class WorkerRunner extends ProcessRunner {
} }
}; };
if (!this._isStopped) { if (!this._isStopped)
// Update the fixture pool - it may differ between tests.
// - In case of isolate-pools worker isolation, only test-scoped fixtures may differ.
// - In case of isolate-projects, worker fixtures can differ too, tear down worker fixture scope if they differ.
if (this._params.workerIsolation === 'isolate-projects' && this._fixtureRunner.pool && this._fixtureRunner.pool.digest !== test._pool!.digest)
await this._teardownScopes();
this._fixtureRunner.setPool(test._pool!); this._fixtureRunner.setPool(test._pool!);
}
const suites = getSuites(test); const suites = getSuites(test);
const reversedSuites = suites.slice().reverse(); const reversedSuites = suites.slice().reverse();