-
Notifications
You must be signed in to change notification settings - Fork 66
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
chore(e2e-tests): add TestShell#eventually
and refactor TestShell#executeLine
and TestShell#waitForPrompt
#2171
base: main
Are you sure you want to change the base?
Conversation
* Like the `eventually` utility, but instead of calling the callback on a timer, | ||
* the callback is called as output is emitted. | ||
*/ | ||
eventually<T = unknown>( |
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 might need help to pick a better name for it 🤔 The reason I choose this, is because it acts as a replacement for the pull-based eventually
utility used elsewhere.
PROMPT_PATTERN.test(lastLine), | ||
`Expected a prompt (last line was "${lastLine}")` | ||
); | ||
return lastLine; |
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.
Now returning the prompt since we need this in executeLine
to omit it from the output.
c4b9f35
to
0601808
Compare
6e2024a
to
49c8443
Compare
It seems this is agitating a few of the flaky tests a bit more. Specifically, I'm seeing these failures quite frequently:
|
544b16d
to
25ac37c
Compare
Remove unused imports
In an attempt to fix flakiness of "fails fast for ENOTFOUND/EINVAL errors" in e2e.spec.ts
a6f6834
to
8179ade
Compare
This adds a
TestShell#eventually
which is designed to be a drop-in replacement for the timing basedeventually
utility.Tests can now call
await shell.eventually(() => { /* block which conditionally throws */ })
and pass a callback which will get called whenever the child process spawned by theTestShell
receives output. This effectively acts as a push-stream to allow for faster execution of tests (5min 4sec before vs 4min 20sec after) and less noise if logging in these callbacks while developing tests.This refactors
TestShell
'sexecuteLine
to await a prompt before writing the input instead of simply awaiting the prompt afterwards. This is to fix a race which occurs ifshell.writeInputLine
is called directly from a test and aneventually
polls for the output to contain something. In which case the prompt won't be awaited and anexecuteLine
will incorrectly pick up the prompt from the previous command:mongosh/packages/e2e-tests/test/e2e-auth.spec.ts
Lines 738 to 749 in a520eb1
This also refactors
TestShell
'swaitForPrompt
to use the newshell.eventually
(push streaming) and only consider the last line of the output determining if the output has a prompt. I believe this is now possible because of a fix for the race inexecuteLine
.Note: This is based on the changes introduced in #2170 and needs a rebase once that is merged.
Note: This also sneaks in a bump of the timeout passed to
eventually
in the "e2e Analytics Node" before hook, as it was often failing locally and the timeout of the hook itself was already 60s.