Skip to content

chore: debugging CT performance slowness #22612

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mainBuildFilters: &mainBuildFilters
branches:
only:
- develop
- issue-22147-nohoist
- lmiller/22353-ct-single-session

# usually we don't build Mac app - it takes a long time
# but sometimes we want to really confirm we are doing the right thing
Expand All @@ -38,7 +38,7 @@ macWorkflowFilters: &darwin-workflow-filters
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ linux-arm64, << pipeline.git.branch >> ]
- matches:
pattern: "-release$"
pattern: "lmiller/22353-ct-single-session"
value: << pipeline.git.branch >>

linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
Expand Down Expand Up @@ -128,7 +128,7 @@ commands:
- run:
name: Check current branch to persist artifacts
command: |
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "issue-22147-nohoist" ]]; then
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "lmiller/22353-ct-single-session" ]]; then
echo "Not uploading artifacts or posting install comment for this branch."
circleci-agent step halt
fi
Expand Down
17 changes: 10 additions & 7 deletions packages/app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ app.use(Toast, {
closeOnClick: false,
})

makeUrqlClient({ target: 'app', namespace: config.namespace, socketIoRoute: config.socketIoRoute }).then((client) => {
app.use(urql, client)
app.use(createRouter())
app.use(createI18n())
app.use(createPinia())
app.use(createRouter())
app.use(createI18n())
app.use(createPinia())

app.mount('#app')
})
if (window.__CYPRESS_MODE__ === 'open') {
makeUrqlClient({ target: 'app', namespace: config.namespace, socketIoRoute: config.socketIoRoute }).then((client) => {
app.use(urql, client)
})
}

app.mount('#app')
19 changes: 17 additions & 2 deletions packages/server/lib/modes/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,12 @@ module.exports = {

displayRunStarting,

navigateToNextSpec (spec) {
debug('navigating to next spec')

return openProject.changeUrlToSpec('', spec)
},

exitEarly (err) {
debug('set early exit error: %s', err.stack)

Expand Down Expand Up @@ -1109,6 +1115,13 @@ module.exports = {
const wait = () => {
debug('waiting for socket to connect and browser to launch...')

if (options.testingType === 'component' && !options.isFirstSpec) {
// If we do not launch the browser,
// we tell it that we are ready
// to receive the next spec
return Promise.resolve(this.navigateToNextSpec(options.spec))
}

return Promise.join(
this.waitForSocketConnection(project, socketId)
.tap(() => {
Expand Down Expand Up @@ -1251,11 +1264,11 @@ module.exports = {
// await openProject.closeBrowser()
// } else {
debug('attempting to close the browser tab')
await openProject.resetBrowserTabsForNextTest(shouldKeepTabOpen)
// await openProject.resetBrowserTabsForNextTest(shouldKeepTabOpen)
// }

debug('resetting server state')
openProject.projectBase.server.reset()
// openProject.projectBase.server.reset()

if (videoExists && !skippedSpec && endVideoCapture && !videoCaptureFailed) {
const ffmpegChaptersConfig = videoCapture.generateFfmpegChaptersConfig(results.tests)
Expand Down Expand Up @@ -1497,6 +1510,8 @@ module.exports = {
socketId: options.socketId,
webSecurity: options.webSecurity,
projectRoot: options.projectRoot,
testingType: options.testingType,
isFirstSpec,
shouldLaunchNewTab: !isFirstSpec, // !process.env.CYPRESS_INTERNAL_FORCE_BROWSER_RELAUNCH && !isFirstSpec,
// TODO(tim): investigate the socket disconnect
}),
Expand Down
23 changes: 23 additions & 0 deletions packages/server/lib/open_project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,29 @@ export class OpenProject {
this.closeOpenProjectAndBrowsers()
}

changeUrlToSpec (browserUrl: string, spec: Cypress.Spec) {
if (!this.projectBase) {
return
}

const newSpecUrl = getSpecUrl({
projectRoot: this.projectBase.projectRoot,
spec,
// absoluteSpecPath: spec.absolute,
// specType: spec.specType,
// browserUrl: this.openProject.cfg.browserUrl,
// integrationFolder: this.openProject.cfg.integrationFolder || 'integration',
// componentFolder: this.openProject.cfg.componentFolder || 'component',
// projectRoot: this.openProject.projectRoot,
})

console.log(`New url is ${newSpecUrl}`)

this.projectBase.server._socket.changeToUrl(newSpecUrl)

// this.openProject.changeToUrl(newSpecUrl)
}

// close existing open project if it exists, for example
// if you are switching from CT to E2E or vice versa.
// used by launchpad
Expand Down
4 changes: 4 additions & 0 deletions packages/server/lib/socket-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,4 +612,8 @@ export class SocketBase {
close () {
return this._io?.close()
}

changeToUrl (url: string) {
return this.toRunner('change:to:url', url)
}
}