Skip to content

Commit

Permalink
Fix sources of test instability (#368)
Browse files Browse the repository at this point in the history
- Wait up to 1 second for the server to become healthy before assuming
  it's failed. After the server starts accepting connections, we were
  assuming it should be healthy immediately, but that's not always true.

- Make sure the server finishes shutting down before exiting the CLI,
  because otherwise it will hold open files, and this intermittently
  breaks tests on Windows (which, unlike POSIXy OSes, will refuse to
  delete open files). Closes #338. I hope.
  • Loading branch information
josh-berry authored Oct 20, 2023
1 parent 676fd19 commit 4d2784a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,16 @@ func assertServerHealth(ctx context.Context, t *testing.T, opts sdkclient.Option
t.Error(clientErr)
}

if _, err := c.CheckHealth(ctx, nil); err != nil {
t.Error(err)
// Give the server 1 second to become healthy.
for i := 0; i < 10; i++ {
_, clientErr = c.CheckHealth(ctx, nil)
if clientErr == nil {
break
}
time.Sleep(100 * time.Millisecond)
}
if clientErr != nil {
t.Error(clientErr)
}

// Check for pollers on a system task queue to ensure that the worker service is running.
Expand Down
1 change: 1 addition & 0 deletions server/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ func NewServerCommands(defaultCfg *sconfig.Config) []*cli.Command {
if err := s.Start(); err != nil {
return cli.Exit(fmt.Sprintf("Unable to start server. Error: %v", err), 1)
}
s.Stop()
return cli.Exit("All services are stopped.", 0)
},
},
Expand Down

0 comments on commit 4d2784a

Please sign in to comment.