-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix(testing): fix race condition in tests for parallel commands runner #2358
fix(testing): fix race condition in tests for parallel commands runner #2358
Conversation
We are now checking for the presence of both command outputs regardless of the order they were written in to the file
… parallel In addition to checking whether the tasks complete and they write to the file, we are now also checking if the runner creates all the tasks synchronously when invoked with parallel: true, vs. zero or at most 1 when ran in serial mode.
} | ||
], | ||
parallel: true | ||
} | ||
); | ||
const processesCreated = exec.calls.count(); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Is this comment in the right place? :)
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 added your suggestion to the serial runner tests 👍 please let me know if that's not what you meant
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.
Yeah
Due to differences in implementation between serial and parallel runner, we need to wait for a micro-tick in the serial test runner tests before checking for calls to spawn-process, otherwise it would be zero.
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior (This is the behavior we have today, before the PR is merged)
Test would occasionally fail.
Expected Behavior (This is the new behavior we can expect after the PR is merged)
Test should consistently pass now.
Issue
The previous setup was as follows:
The idea was that, if truly running in parallel, the second commands would finish before the first, because it was sleeping for less.
But as @jaysoo pointed out, if they're running in parallel we can't guarantee order, even with
sleep
.Fix (checked-in / part of this PR)
Instead of checking the order in which the commands were executed we now:
To prove above strategy works, it's also been added to the
serial
runner tests, and it indeed just prints 0 (as the initial promise it creates is a null one, only once that resolves it schedules the first task in the queue)