diff --git a/.github/workflows/tests_secondary.yml b/.github/workflows/tests_secondary.yml index 4607cf4926..d5844b1ca3 100644 --- a/.github/workflows/tests_secondary.yml +++ b/.github/workflows/tests_secondary.yml @@ -185,7 +185,12 @@ jobs: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 - run: npm run build - run: npx playwright install --with-deps chromium + - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project='Chromium page tests' + if: matrix.mode == 'service' + env: + PWTEST_MODE: ${{ matrix.mode }} - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ctest + if: matrix.mode != 'service' env: PWTEST_MODE: ${{ matrix.mode }} - run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json diff --git a/packages/playwright-core/src/grid/gridClient.ts b/packages/playwright-core/src/grid/gridClient.ts deleted file mode 100644 index 82966bdb7d..0000000000 --- a/packages/playwright-core/src/grid/gridClient.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. - * - * 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 WebSocket from 'ws'; -import { Connection } from '../client/connection'; -import type { Playwright } from '../client/playwright'; -import { getPlaywrightVersion } from '../common/userAgent'; - -export class GridClient { - private _ws: WebSocket; - private _playwright: Playwright; - - static async connect(gridURL: string) { - const params = new URLSearchParams(); - params.set('pwVersion', getPlaywrightVersion(true /* majorMinorOnly */)); - const ws = new WebSocket(`${gridURL}/claimWorker?` + params.toString()); - const errorText = await Promise.race([ - new Promise(f => ws.once('open', () => f(undefined))), - new Promise(f => ws.once('close', (code, reason) => f(reason))), - ]); - if (errorText) - throw errorText; - const connection = new Connection(); - connection.markAsRemote(); - connection.onmessage = (message: Object) => ws.send(JSON.stringify(message)); - ws.on('message', message => connection.dispatch(JSON.parse(message.toString()))); - ws.on('close', (code, reason) => connection.close(reason.toString())); - const playwright = await connection.initializePlaywright(); - playwright._enablePortForwarding(); - return new GridClient(ws, playwright); - } - - constructor(ws: WebSocket, playwright: Playwright) { - this._ws = ws; - this._playwright = playwright; - } - - playwright(): Playwright { - return this._playwright; - } - - close() { - this._ws.close(); - } -} - - diff --git a/packages/playwright-core/src/grid/gridServer.ts b/packages/playwright-core/src/grid/gridServer.ts index 5757923962..2be67d84fd 100644 --- a/packages/playwright-core/src/grid/gridServer.ts +++ b/packages/playwright-core/src/grid/gridServer.ts @@ -263,6 +263,7 @@ export class GridServer { // shouldHandle claims it accepts promise, except it doesn't. return true; } + this._log('rejecting websocket request'); return false; }; diff --git a/packages/playwright-test/src/cli.ts b/packages/playwright-test/src/cli.ts index e65f37ac24..c03fab10e9 100644 --- a/packages/playwright-test/src/cli.ts +++ b/packages/playwright-test/src/cli.ts @@ -242,7 +242,6 @@ async function launchDockerContainer(): Promise<() => Promise> { const { error } = await gridServer.createAgent(); if (error) throw error; - process.env.PW_GRID = gridServer.gridURL(); return async () => await gridServer.stop(); } diff --git a/packages/playwright-test/src/index.ts b/packages/playwright-test/src/index.ts index ab5ff0ae47..758c9eabd6 100644 --- a/packages/playwright-test/src/index.ts +++ b/packages/playwright-test/src/index.ts @@ -21,7 +21,6 @@ import type { TestType, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWor import { rootTestType } from './testType'; import { createGuid, debugMode } from 'playwright-core/lib/utils'; import { removeFolders } from 'playwright-core/lib/utils/fileUtils'; -import { GridClient } from 'playwright-core/lib/grid/gridClient'; export { expect } from './expect'; export const _baseTest: TestType<{}, {}> = rootTestType.test; import * as outOfProcess from 'playwright-core/lib/outofprocess'; @@ -53,12 +52,8 @@ type WorkerFixtures = PlaywrightWorkerArgs & PlaywrightWorkerOptions & { export const test = _baseTest.extend({ defaultBrowserType: [ 'chromium', { scope: 'worker', option: true } ], browserName: [ ({ defaultBrowserType }, use) => use(defaultBrowserType), { scope: 'worker', option: true } ], - playwright: [async ({}, use, workerInfo) => { - if (process.env.PW_GRID) { - const gridClient = await GridClient.connect(process.env.PW_GRID); - await use(gridClient.playwright() as any); - gridClient.close(); - } else if (process.env.PW_OUT_OF_PROCESS_DRIVER) { + playwright: [async ({ }, use) => { + if (process.env.PW_OUT_OF_PROCESS_DRIVER) { const impl = await outOfProcess.start({ NODE_OPTIONS: undefined // Hide driver process while debugging. }); diff --git a/tests/config/testMode.ts b/tests/config/testMode.ts index cdc16c987d..1f5461b9eb 100644 --- a/tests/config/testMode.ts +++ b/tests/config/testMode.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { GridClient } from '../../packages/playwright-core/lib/grid/gridClient'; import { start } from '../../packages/playwright-core/lib/outofprocess'; import type { Playwright } from '../../packages/playwright-core/lib/client/playwright'; @@ -41,19 +40,6 @@ export class DriverTestMode implements TestMode { } } -export class ServiceTestMode implements TestMode { - private _gridClient: GridClient; - - async setup() { - this._gridClient = await GridClient.connect('ws://localhost:3333'); - return this._gridClient.playwright(); - } - - async teardown() { - this._gridClient.close(); - } -} - export class DefaultTestMode implements TestMode { async setup() { return require('playwright-core'); diff --git a/tests/config/testModeFixtures.ts b/tests/config/testModeFixtures.ts index 077866d131..6e8561a0b1 100644 --- a/tests/config/testModeFixtures.ts +++ b/tests/config/testModeFixtures.ts @@ -16,7 +16,7 @@ import { test } from '@playwright/test'; import type { TestModeName } from './testMode'; -import { DefaultTestMode, DriverTestMode, ServiceTestMode } from './testMode'; +import { DefaultTestMode, DriverTestMode } from './testMode'; export type TestModeWorkerOptions = { mode: TestModeName; @@ -32,7 +32,7 @@ export const testModeTest = test.extend<{}, TestModeWorkerOptions & TestModeWork playwright: [ async ({ mode }, run) => { const testMode = { default: new DefaultTestMode(), - service: new ServiceTestMode(), + service: new DefaultTestMode(), driver: new DriverTestMode(), service2: new DefaultTestMode(), }[mode]; diff --git a/tests/library/playwright.config.ts b/tests/library/playwright.config.ts index 8c80259938..f7d6d6e518 100644 --- a/tests/library/playwright.config.ts +++ b/tests/library/playwright.config.ts @@ -69,13 +69,26 @@ const config: Config