Skip to content

Commit

Permalink
longer wait
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
Adrian Cole committed Apr 10, 2021
1 parent 1fef970 commit fe67873
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/util/os/signals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import (
"github.com/stretchr/testify/require"
)

// Signal response can be slow in CI, so use a period larger than what makes sense locally
const waitFor = 100 * time.Millisecond

func TestShutdownSignals(t *testing.T) {
// This is a base-case, just verifying the default values
require.Equal(t, []os.Signal{syscall.SIGINT, syscall.SIGTERM}, shutdownSignals)
Expand Down Expand Up @@ -80,7 +83,7 @@ func requireSignal(t *testing.T, expected os.Signal, ch <-chan os.Signal) {
default:
return false
}
}, 100*time.Millisecond, 10*time.Millisecond)
}, waitFor, 10*time.Millisecond)
}

func requireChannelClosed(t *testing.T, ch <-chan os.Signal) {
Expand All @@ -101,7 +104,7 @@ func requireNoSignal(t *testing.T, ch <-chan os.Signal) {
default:
return false
}
}, 100*time.Millisecond, 10*time.Millisecond)
}, waitFor, 10*time.Millisecond)
}

// overrideTerminateWithBool returns a boolean made true on terminate. The function returned reverts the original.
Expand Down Expand Up @@ -141,7 +144,7 @@ func TestSetupSignalHandlerTerminatesOnSecondRelevantSignal(t *testing.T) {
// Second relevant signal terminates the process
require.Eventually(t, func() bool {
return *terminated
}, 50*time.Millisecond, 10*time.Millisecond)
}, waitFor, 10*time.Millisecond)
}

func TestSetupSignalHandlerDoesntTerminateWhenContextCanceledBeforeSecondRelevantSignal(t *testing.T) {
Expand Down Expand Up @@ -171,5 +174,5 @@ func TestSetupSignalHandlerDoesntTerminateWhenContextCanceledBeforeSecondRelevan
// Second relevant signal doesn't terminate the process
require.Never(t, func() bool {
return *terminated
}, 50*time.Millisecond, 10*time.Millisecond)
}, waitFor, 10*time.Millisecond)
}

0 comments on commit fe67873

Please sign in to comment.