Skip to content

Commit

Permalink
test: make tick time configurable to reduce test duration
Browse files Browse the repository at this point in the history
  • Loading branch information
deepthidevaki committed Dec 8, 2022
1 parent d591077 commit 07cd4a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions go-chaos/internal/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ func (c K8Client) RestartPodWithGracePeriod(podName string, gracePeriodSec *int6
}

func (c K8Client) AwaitReadiness() error {
return c.AwaitReadinessWithTimeout(5 * time.Minute)
return c.AwaitReadinessWithTimeout(5*time.Minute, 1*time.Second)
}

func (c K8Client) AwaitReadinessWithTimeout(timeout time.Duration) error {
func (c K8Client) AwaitReadinessWithTimeout(timeout time.Duration, tickTime time.Duration) error {
timedOut := time.After(timeout)
ticker := time.Tick(1 * time.Second)
ticker := time.Tick(tickTime)

// Keep checking until we're timed out
for {
Expand Down
6 changes: 3 additions & 3 deletions go-chaos/internal/pods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func Test_ShouldReturnTrueWhenBrokersAreReady(t *testing.T) {
k8Client.CreateDeploymentWithLabelsAndName(t, gatewaySelector, "gateway")

// when
err = k8Client.AwaitReadinessWithTimeout(2 * time.Second)
err = k8Client.AwaitReadinessWithTimeout(100*time.Millisecond, 1*time.Millisecond)

// then
require.NoError(t, err)
Expand All @@ -304,7 +304,7 @@ func Test_ShouldReturnErrorWhenAtleastOneBrokerIsNotReady(t *testing.T) {
k8Client.CreateDeploymentWithLabelsAndName(t, gatewaySelector, "gateway")

// when
err = k8Client.AwaitReadinessWithTimeout(2 * time.Second)
err = k8Client.AwaitReadinessWithTimeout(100*time.Millisecond, 1*time.Second)

// then
require.Error(t, err)
Expand All @@ -325,7 +325,7 @@ func Test_ShouldReturnErrorWhenAtleastOneBrokerIsNotRunning(t *testing.T) {
k8Client.CreateDeploymentWithLabelsAndName(t, gatewaySelector, "gateway")

// when
err = k8Client.AwaitReadinessWithTimeout(2 * time.Second)
err = k8Client.AwaitReadinessWithTimeout(100*time.Millisecond, 1*time.Second)

// then
require.Error(t, err)
Expand Down

0 comments on commit 07cd4a6

Please sign in to comment.