-
Notifications
You must be signed in to change notification settings - Fork 3.4k
test: fix flaky migration test #25672
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 1 commit
d5b012b
5d13579
d545ad7
5aa6c1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,6 +103,11 @@ export class ProjectLifecycleManager { | |
|
|
||
| async getProjectId (): Promise<string | null> { | ||
| try { | ||
| // No need to kick off config initialization if we need to migrate | ||
| if (this.ctx.migration.needsCypressJsonMigration()) { | ||
|
Contributor
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. General question - if the test is only flaky, I wouldn't expect we need to touch production code to fix it. WDYT? Is there any additional risk here? Is the test hitting a scenario that's impossible in prod?
Contributor
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. Or is this just a general QOL improvement since it's purely optimizations?
Contributor
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. I think this test was particularly flaky because it migrated two projects, and the number of queries re-executed was doubled/tripled. Hard to reproduce locally but in slow CI environments I think a call might have been dropped in between states and caused the test to fail. I don't think there is a fix for this outside touching production code. The number of requeries is a sign we aren't doing something correct so most of the changes was to reduce this behavior.
Contributor
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.
I see this a bit differently, a flaky test is often telling us about non-determinism in the app code that we don't see locally due to different system resources, OS, etc. |
||
| return null | ||
| } | ||
|
|
||
| const contents = await this.ctx.project.getConfig() | ||
|
|
||
| return contents.projectId ?? null | ||
|
|
@@ -458,8 +463,6 @@ export class ProjectLifecycleManager { | |
| const legacyConfigPath = path.join(projectRoot, this.ctx.migration.legacyConfigFile) | ||
|
|
||
| if (needsCypressJsonMigration && !this.ctx.isRunMode && this.ctx.fs.existsSync(legacyConfigPath)) { | ||
| this.legacyMigration(legacyConfigPath).catch(this.onLoadError) | ||
|
|
||
| return false | ||
| } | ||
|
|
||
|
|
@@ -470,8 +473,9 @@ export class ProjectLifecycleManager { | |
| return this.metaState.hasValidConfigFile | ||
| } | ||
|
|
||
| private async legacyMigration (legacyConfigPath: string) { | ||
| async legacyMigration () { | ||
| try { | ||
| const legacyConfigPath = path.join(this.projectRoot, this.ctx.migration.legacyConfigFile) | ||
| // we run the legacy plugins/index.js in a child process | ||
| // and mutate the config based on the return value for migration | ||
| // only used in open mode (cannot migrate via terminal) | ||
|
|
@@ -480,8 +484,6 @@ export class ProjectLifecycleManager { | |
| // should never throw, unless there existing pluginsFile errors out, | ||
| // in which case they are attempting to migrate an already broken project. | ||
| await this.ctx.actions.migration.initialize(legacyConfig) | ||
|
|
||
| this.ctx.emitter.toLaunchpad() | ||
| } catch (error) { | ||
| this.onLoadError(error) | ||
| } | ||
|
|
||
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.
Nice, I noticed we have a lot of excess gql calls in general, hope we can find a good way to monitor/track these eventually... no idea how other apps handle this, or do they just have lots of requests 🤔
Nice thing about REST is you are very deliberate about requests - just thinking out loud here, gql sure is nice but man it has some trade-offs (complexity, hard to really know what/when a call is triggered).
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.
I think it all boils down the the
toLaunchpadcalls. This causes every active query to retrigger. If properly designed, we could probably get away with removing this altogether. Or we could rely more heavily on subscriptions to update data.