Skip to content

chore: improve error logging in TestServer/EphemeralDeployment #17184

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions cli/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,16 @@ func TestServer(t *testing.T) {
go func() {
errCh <- inv.WithContext(ctx).Run()
}()
pty.ExpectMatch("Using an ephemeral deployment directory")
matchCh1 := make(chan string, 1)
go func() {
matchCh1 <- pty.ExpectMatchContext(ctx, "Using an ephemeral deployment directory")
}()
select {
case err := <-errCh:
require.NoError(t, err)
case <-matchCh1:
// OK!
}
Comment on lines +211 to +213
Copy link
Member

Choose a reason for hiding this comment

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

If you have the matched string here, why not move the assertions from L214-220 in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to keep modifications to the existing test to a minimum.

rootDirLine := pty.ReadLine(ctx)
rootDir := strings.TrimPrefix(rootDirLine, "Using an ephemeral deployment directory")
rootDir = strings.TrimSpace(rootDir)
Expand All @@ -210,7 +219,17 @@ func TestServer(t *testing.T) {
require.NotEmpty(t, rootDir)
require.DirExists(t, rootDir)

pty.ExpectMatchContext(ctx, "View the Web UI")
matchCh2 := make(chan string, 1)
go func() {
// The "View the Web UI" log is a decent indicator that the server was successfully started.
matchCh2 <- pty.ExpectMatchContext(ctx, "View the Web UI")
}()
select {
case err := <-errCh:
require.NoError(t, err)
case <-matchCh2:
// OK!
}

cancelFunc()
<-errCh
Expand Down
Loading