-
Notifications
You must be signed in to change notification settings - Fork 841
CI: Prevent Jetpack Sync tests from colliding when running in parallel #45948
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
base: trunk
Are you sure you want to change the base?
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCannot generate coverage summary while tests are failing. 🤐 Please fix the tests, or re-run the Code coverage job if it was something being flaky. |
| if ( ! static::$lockfile ) { | ||
| throw new RuntimeException( 'Failed to open lockfile ' . sys_get_temp_dir() . '/jetpack-sync-test.lock' ); | ||
| } | ||
| if ( ! flock( static::$lockfile, LOCK_SH ) ) { |
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.
If sync tests are failing because one test process modifies the filesystem (themes/plugins) while another test process reads it at the same time, then won't using LOCK_SH give both tests the lock at the same time?
The current test failure -TypeError: fclose(): supplied resource is not a valid stream resource - could imply that the resource was already closed.
So, should we:
- use an exclusive lock (
LOCK_EX), so only one process is holding it at a time - release the lock (
LOCK_UN) beforefclose()?
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.
LOCK_SH to LOCK_EX: Yes, definitely. I was playing with different flags in the last PR but it slipped through there and then into this PR. Thank you for catching it. 😄
release the lock
Per the documentation, the lock is released on fclose():
https://www.php.net/manual/en/function.flock.php
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.
Closes MONOREP-226
Like done in #45851 and #45902 (which will probably be reverted), this adds the locking code to prevent parallel tests from colliding, but this time at a base class level.
See comment here: #45923 (comment)
Proposed changes:
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
I haven't yet tested this, but presumably running multiple Sync-related tests at the same time should generate the lock file and things should take turns.