-
Notifications
You must be signed in to change notification settings - Fork 74
perf: speed up testplane launch #1115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7ff4a70
7798bb7
79fd75f
bb23c0b
9de2901
c2aefa9
2a8e61a
088d214
f8dc6a0
3b5f563
c61745a
86a2e95
91cafec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ export const MIN_CHROMIUM_MAC_ARM_VERSION = 93; | |
| export const MIN_CHROMIUM_VERSION = 73; | ||
| export const MIN_FIREFOX_VERSION = 60; | ||
| export const MIN_EDGEDRIVER_VERSION = 94; | ||
| export const DRIVER_WAIT_INTERVAL = 25; // 20ms | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are almost blocked while waiting for webdriver launch |
||
| export const DRIVER_WAIT_TIMEOUT = 10 * 1000; // 10s | ||
| export const LINUX_UBUNTU_RELEASE_ID = "ubuntu"; | ||
| export const LINUX_RUNTIME_LIBRARIES_PATH_ENV_NAME = "LD_LIBRARY_PATH"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import debug from "debug"; | ||
| import _ from "lodash"; | ||
|
|
||
| import { NewBrowser } from "../browser/new-browser"; | ||
| import type { NewBrowser } from "../browser/new-browser"; | ||
| import { CancelledError } from "./cancelled-error"; | ||
| import { AsyncEmitter, MasterEvents } from "../events"; | ||
| import { BrowserOpts, Pool } from "./types"; | ||
|
|
@@ -32,6 +32,7 @@ export class BasicPool implements Pool { | |
| } | ||
|
|
||
| async getBrowser(id: string, opts: BrowserOpts = {}): Promise<NewBrowser> { | ||
| const { NewBrowser } = await import("../browser/new-browser"); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "NewBrowser" takes some time to import |
||
| const browser = NewBrowser.create(this._config, { ...opts, id, wdPool: this._wdPool, emitter: this._emitter }); | ||
|
|
||
| try { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { ImageInfo, RefImageInfo } from "../../../../types"; | ||
| import type { ImageInfo, RefImageInfo } from "../../../../types"; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "import" -> "import type" also saves some time |
||
|
|
||
| export class BaseStateError extends Error { | ||
| constructor(public stateName: string, public currImg: ImageInfo, public refImg: RefImageInfo) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| import { ImageInfo, RefImageInfo } from "../../../../types"; | ||
|
|
||
| import { Image } from "../../../../image"; | ||
| import { BaseStateError } from "./base-state-error"; | ||
|
|
||
| import type { ImageInfo, RefImageInfo } from "../../../../types"; | ||
| import type { LooksSameOptions, LooksSameResult } from "looks-same"; | ||
|
|
||
| interface DiffOptions extends LooksSameOptions { | ||
|
|
@@ -110,6 +108,6 @@ export class ImageDiffError extends BaseStateError { | |
| } | ||
|
|
||
| saveDiffTo(diffPath: string): Promise<null> { | ||
| return Image.buildDiff({ diff: diffPath, ...this.diffOpts }); | ||
| return import("../../../../image").then(m => m.Image.buildDiff({ diff: diffPath, ...this.diffOpts })); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Image" is fat, and we dont need to requrie "Image" module every time |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import repl from "node:repl"; | ||
| import path from "node:path"; | ||
| import type repl from "node:repl"; | ||
| import { getEventListeners } from "node:events"; | ||
| import chalk from "chalk"; | ||
| import RuntimeConfig from "../../config/runtime-config"; | ||
|
|
@@ -60,7 +60,8 @@ export default (browser: Browser): void => { | |
| const testCwd = path.dirname(session.executionContext.ctx.currentTest.file!); | ||
| process.chdir(testCwd); | ||
|
|
||
| const replServer = repl.start({ prompt: "> " }); | ||
| const replServer = await import("node:repl").then(m => m.start({ prompt: "> " })); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. given that "node:repl" only imported here, we could save ~10ms by lazy-loading it |
||
|
|
||
| browser.applyState({ onReplMode: true }); | ||
|
|
||
| runtimeCfg.extend({ replServer }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,8 +19,6 @@ import { NEW_ISSUE_LINK } from "../constants/help"; | |
| import type { Options } from "@testplane/wdio-types"; | ||
| import { runWithoutHistory } from "./history"; | ||
|
|
||
| const OPTIONAL_SESSION_OPTS = ["transformRequest", "transformResponse"]; | ||
|
|
||
| interface SessionOptions { | ||
| sessionId: string; | ||
| sessionCaps?: WebdriverIO.Capabilities; | ||
|
|
@@ -82,6 +80,8 @@ export class ExistingBrowser extends Browser { | |
| this._startCollectingCustomCommands(); | ||
| } | ||
|
|
||
| const isolationPromise = this._performIsolation({ sessionCaps, sessionOpts }); | ||
|
|
||
| this._extendStacktrace(); | ||
| this._addSteps(); | ||
| this._addHistory(); | ||
|
Comment on lines
85
to
87
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These methods take ~40ms each |
||
|
|
@@ -95,7 +95,10 @@ export class ExistingBrowser extends Browser { | |
| "testplane: init browser", | ||
| async () => { | ||
| this._addCommands(); | ||
| await this._performIsolation({ sessionCaps, sessionOpts }); | ||
|
|
||
| await isolationPromise; | ||
|
|
||
| this._callstackHistory?.clear(); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because order in "add history" and "perform isolation" becomes undefined, removing this step, if its completed |
||
|
|
||
| try { | ||
| this.config.prepareBrowser && this.config.prepareBrowser(this.publicAPI); | ||
|
|
@@ -227,7 +230,7 @@ export class ExistingBrowser extends Browser { | |
| const opts: AttachOptions = { | ||
| sessionId, | ||
| ...sessionOpts, | ||
| ...this._getSessionOptsFromConfig(OPTIONAL_SESSION_OPTS), | ||
| ...this._getSessionOptsFromConfig(["transformRequest", "transformResponse"]), | ||
| ...detectedSessionEnvFlags, | ||
| ...this._config.sessionEnvFlags, | ||
| options: sessionOpts, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contains like 1 LOC:
In our project, typescript compiles all "import" to "require" and we can't prevent it
So, this package is used