Skip to content

Commit

Permalink
Add check for exit
Browse files Browse the repository at this point in the history
- 10s for sync catalog since it needs more time
  • Loading branch information
lawliet89 committed Nov 13, 2020
1 parent 855da2b commit c54699e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
11 changes: 10 additions & 1 deletion subcommand/lifecycle-sidecar/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@ func testRunSignalHandling(sig os.Signal) func(*testing.T) {
exitChan := runCommandAsynchronously(&cmd, []string{
"-service-config", configFile,
})
defer stopCommand(t, &cmd, exitChan, sig)
cmd.sendSignal(sig)

// Assert that it exits cleanly or timeout.
select {
case exitCode := <-exitChan:
require.Equal(t, 0, exitCode, ui.ErrorWriter.String())
case <-time.After(time.Second * 1):
// Fail if the signal was not caught.
require.Fail(t, "timeout waiting for command to exit")
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion subcommand/sync-catalog/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,16 @@ func testSignalHandling(sig os.Signal) func(*testing.T) {
exitChan := runCommandAsynchronously(&cmd, []string{
"-http-addr", testServer.HTTPAddr,
})
defer stopCommand(t, &cmd, exitChan, sig)
cmd.sendSignal(sig)

// Assert that it exits cleanly or timeout.
select {
case exitCode := <-exitChan:
require.Equal(t, 0, exitCode, ui.ErrorWriter.String())
case <-time.After(time.Second * 10):
// Fail if the signal was not caught.
require.Fail(t, "timeout waiting for command to exit")
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion subcommand/webhook-cert-manager/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,16 @@ func testSignalHandling(sig os.Signal) func(*testing.T) {
exitCh := runCommandAsynchronously(&cmd, []string{
"-config-file", file.Name(),
})
defer stopCommand(t, &cmd, exitCh, sig)
cmd.sendSignal(sig)

// Assert that it exits cleanly or timeout.
select {
case exitCode := <-exitCh:
require.Equal(t, 0, exitCode, ui.ErrorWriter.String())
case <-time.After(time.Second * 1):
// Fail if the signal was not caught.
require.Fail(t, "timeout waiting for command to exit")
}
}
}

Expand Down

0 comments on commit c54699e

Please sign in to comment.