Skip to content

Commit

Permalink
chore: use separate ports for QuitQuitQuit tests (#748)
Browse files Browse the repository at this point in the history
Windows test runs are failing frequently, presumably because shutting
down the HTTP server and releasing the port takes longer than macOS or
Linux.

This commit is a simple fix and uses separate ports to avoid collision.

Fixes #739
  • Loading branch information
enocom authored Jan 15, 2025
1 parent be4d719 commit 5c1f8ff
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ func TestQuitQuitQuitGet(t *testing.T) {
c := NewCommand(WithDialer(&spyDialer{}))
c.SilenceUsage = true
c.SilenceErrors = true
c.SetArgs([]string{"--quitquitquit", "--admin-port", "9192",
c.SetArgs([]string{"--quitquitquit", "--admin-port", "9193",
"projects/proj/locations/region/clusters/clust/instances/inst"})
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand All @@ -1248,14 +1248,14 @@ func TestQuitQuitQuitGet(t *testing.T) {
err := c.ExecuteContext(ctx)
errCh <- err
}()
resp, err := tryDial("HEAD", "http://localhost:9192/quitquitquit")
resp, err := tryDial("HEAD", "http://localhost:9193/quitquitquit")
if err != nil {
t.Fatalf("failed to dial endpoint: %v", err)
}
if resp.StatusCode != http.StatusBadRequest {
t.Fatalf("expected a 400 status, got = %v", resp.StatusCode)
}
resp, err = tryDial("GET", "http://localhost:9192/quitquitquit")
resp, err = tryDial("GET", "http://localhost:9193/quitquitquit")
if err != nil {
t.Fatalf("failed to dial endpoint: %v", err)
}
Expand All @@ -1282,7 +1282,7 @@ func TestQuitQuitQuitWithErrors(t *testing.T) {
c.SilenceUsage = true
c.SilenceErrors = true
c.SetArgs([]string{
"--quitquitquit", "--admin-port", "9193",
"--quitquitquit", "--admin-port", "9194",
"projects/proj/locations/region/clusters/clust/instances/inst"})
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand All @@ -1292,7 +1292,7 @@ func TestQuitQuitQuitWithErrors(t *testing.T) {
err := c.ExecuteContext(ctx)
errCh <- err
}()
resp, err := tryDial("POST", "http://localhost:9193/quitquitquit")
resp, err := tryDial("POST", "http://localhost:9194/quitquitquit")
if err != nil {
t.Fatalf("failed to dial endpoint: %v", err)
}
Expand Down

0 comments on commit 5c1f8ff

Please sign in to comment.