Skip to content
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 the feature tests with a retry #8534

Merged
merged 5 commits into from
Dec 9, 2020

Conversation

zadjii-msft
Copy link
Member

@zadjii-msft zadjii-msft commented Dec 9, 2020

A bunch of our feature tests don't work reliably in CI. They rely on creating a new OpenConsole.exe window, then running the test in that console. As a part of that test setup, the test runner used to wait a second to attach to the newly created console. Then the test goes on it's merry way, assuming the console is ready to go. However, in CI, that might take more than a second. If it does, then the test would fail pretty immediately, as soon as it tries to get at the buffer of the new console.

This PR introduces a little retry loop to the test init. After attaching to the new console, we'll try and get at the screen buffer. If that fails, we'll wait a second and try again. We'll try 5 times total, before bailing entirely. Hopefully, this should mitigate most of the random CI failures we get in the feature tests.

@zadjii-msft
Copy link
Member Author

Hey look, this works!

Attempt #1 to confirm we've attached
Verify: AreEqual(0, err)
Verify: AreEqual(0, err)
Verify: AreNotEqual(hConsole, INVALID_HANDLE_VALUE): Ensure we got a valid console handle
Verify: IsNotNull(hConsole): Ensure we got a non-null console handle
Verify: IsNotNull(hOut): Verify we have the standard output handle.
Verify: AreEqual(6u, gle): If we fail to set up the console, GetLastError should return 6 here.
Attempt #2 to confirm we've attached
Verify: AreEqual(0, err)
Verify: AreEqual(0, err)
Verify: AreNotEqual(hConsole, INVALID_HANDLE_VALUE): Ensure we got a valid console handle
Verify: IsNotNull(hConsole): Ensure we got a non-null console handle
Verify: IsNotNull(hOut): Verify we have the standard output handle.

It's silly, but it gets the job done, right?

@zadjii-msft zadjii-msft added Area-Build Issues pertaining to the build system, CI, infrastructure, meta Product-Meta The product is the management of the products. labels Dec 9, 2020
@ghost ghost added Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) labels Dec 9, 2020
Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a good call. Thanks.

}
else
{
setupConsole = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could also dispense with the boolean and just break here!

@DHowett DHowett merged commit 1d08288 into main Dec 9, 2020
@DHowett DHowett deleted the dev/migrie/b/silly-feature-tests-fix branch December 9, 2020 19:02
mpela81 pushed a commit to mpela81/terminal that referenced this pull request Jan 28, 2021
A bunch of our feature tests don't work reliably in CI. They rely on
creating a new `OpenConsole.exe` window, then running the test _in that
console_. As a part of that test setup, the test runner used to wait a
second to attach to the newly created console. Then the test goes on
it's merry way, assuming the console is ready to go. However, in CI,
that might take more than a second. If it does, then the test would fail
pretty immediately, as soon as it tries to get at the buffer of the new
console.

This PR introduces a little retry loop to the test init. After attaching
to the new console, we'll try and get at the screen buffer. If that
fails, we'll wait a second and try again. We'll try 5 times total,
before bailing entirely. Hopefully, this should mitigate most of the
random CI failures we get in the feature tests.

Closes microsoft#8495
DHowett pushed a commit that referenced this pull request Apr 13, 2023
Looking through this test, I seriously don't understand how this doesn't
work. I mean, I don't really get how it _does_ work, but at this point
in the tests, we've actually established that both `Nihilist.exe` _and_
openconsole are running. From my read, there's no reason these should be
failing at this point.

We previously added a "retry 5 times" bit to this test, in #8534. That
did work back then. So uh, just do that... again?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Build Issues pertaining to the build system, CI, infrastructure, meta Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Meta The product is the management of the products.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The feature tests fail in CI often
3 participants