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

Update to termtest v2 #2731

Merged
merged 146 commits into from
Sep 25, 2023
Merged

Update to termtest v2 #2731

merged 146 commits into from
Sep 25, 2023

Conversation

Naatan
Copy link
Member

@Naatan Naatan commented Aug 23, 2023

No description provided.

@github-actions github-actions bot changed the base branch from master to version/0-41-0-RC1 August 23, 2023 21:01
# Conflicts:
#	cmd/state-installer/test/integration/installer_int_test.go
#	go.sum
#	test/integration/auth_int_test.go
#	test/integration/bundle_int_test.go
#	test/integration/package_int_test.go
#	test/integration/push_int_test.go
#	test/integration/revert_int_test.go
#	vendor/modules.txt
Fix tests to be termtest compatible
@Naatan
Copy link
Member Author

Naatan commented Sep 20, 2023

@mitchell-as I suggest giving the e2e changes a closer look, but to only review the rest at a very high level.

Copy link
Contributor

@mitchell-as mitchell-as left a comment

Choose a reason for hiding this comment

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

This was a herculean effort that you managed to pull off. No amount of applause is enough.
In addition to the overhaul, I like that you also added reasonable timeouts or removed unnecessary ones.

Nevertheless, there are a few things that we should probably address.

.github/workflows/build.yml Show resolved Hide resolved
cp.Expect("Starting")
time.Sleep(1 * time.Second) // wait for the service to start up
cp.Signal(syscall.SIGINT)
cp.Cmd().Process.Signal(syscall.SIGINT)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not very discoverable. Other uses of cp.Cmd() are in session.go, which is fine for lower-level stuff, but high level stuff like sending process signal should be a top-level function in my opinion. Are you open to changing this back to cp.Signal(syscall.SIGINT)?

Edit: is this any different than cp.SendCtrlC()? Something to think about.

Copy link
Member Author

Choose a reason for hiding this comment

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

Originally I had this implemented at a higher level, but it quickly becomes burdensome to handle these states when it comes to closing the connections when it's done. In the end I felt that making the command a responsibility of the consumer was better as it's rare that you even need to do this, and this way we're not trying to do too much with the termtest library.

Making it accessible via a Cmd() method is itself already going slightly further than required as the command is fed into termtest by the consumer, so the consumer should already have access to this regardless.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, so this is different than cp.SendCtrlC()?

internal/testhelpers/e2e/session.go Show resolved Hide resolved
internal/testhelpers/e2e/session.go Outdated Show resolved Hide resolved
@@ -187,6 +178,7 @@ func new(t *testing.T, retainDirs, updatePath bool, extraEnv ...string) *Session
constants.OptinUnstableEnvVarName + "=true",
constants.ServiceSockDir + "=" + dirs.SockRoot,
constants.HomeEnvVarName + "=" + dirs.HomeDir,
"NO_COLOR=true",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we either constantize this option or add a comment on what it does? I think I know what it means, but I'd like a comment somewhere to confirm.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I was not familiar with said standard. Would you add a brief comment please?

test/integration/analytics_int_test.go Show resolved Hide resolved
test/integration/branch_int_test.go Show resolved Hide resolved
test/integration/e2eissues_int_test.go Show resolved Hide resolved
cp.ExpectLongString("Installation path must be an empty directory")
cp.Wait()
cp.Expect("Installation path must be an empty directory")
cp.ExpectExit()
Copy link
Contributor

Choose a reason for hiding this comment

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

How about expecting a non-zero exit code? This looks like an error.

Copy link
Member Author

Choose a reason for hiding this comment

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

I should've added a comment, cause I don't remember the specifics. But looking at the commit and the context I believe I did this because the exit code doesn't bubble up properly through powershell.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to have some comment here rather than none at all. If I saw this down the road I would be very tempted to change it to ExpectExitCode(0).

test/integration/vscode_int_test.go Show resolved Hide resolved
@Naatan
Copy link
Member Author

Naatan commented Sep 25, 2023

This was a herculean effort that you managed to pull off. No amount of applause is enough. In addition to the overhaul, I like that you also added reasonable timeouts or removed unnecessary ones.

Thank you! Worth noting that I still want to work more on the timeouts, just not in this PR.

I'd like to end up with a default timeout of 5 seconds, and have anything that needs more specifically state it. But as you might imagine that could itself take days to untangle.

if spawnOpts.RunInsideShell {
switch runtime.GOOS {
case "windows":
shell = "cmd.exe"
Copy link
Contributor

Choose a reason for hiding this comment

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

I see you added the Cmd constant on line 295, but you didn't change the one here. Unless I'm missing something, best to be safe and change it here too, right?

cp.ExpectLongString("Installation path must be an empty directory")
cp.Wait()
cp.Expect("Installation path must be an empty directory")
cp.ExpectExit()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to have some comment here rather than none at all. If I saw this down the road I would be very tempted to change it to ExpectExitCode(0).

Copy link
Contributor

@mitchell-as mitchell-as left a comment

Choose a reason for hiding this comment

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

Almost there!

@Naatan Naatan merged commit 99bbe2f into version/0-42-0-RC1 Sep 25, 2023
4 of 7 checks passed
@Naatan Naatan deleted the DX-1910 branch September 25, 2023 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants