Skip to content

Commit

Permalink
fix flake seen in pod_shutdown_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
cfryanr committed Sep 26, 2023
1 parent d44882f commit 7ca590f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/integration/pod_shutdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func testShutdownAllPodsOfApp(t *testing.T, env *testlib.TestEnv, namespace stri
// The leader election lease should already contain the empty string as the holder, because the old leader
// pod should have given up the lease during its graceful shutdown.
waitForLeaderElectionLeaseToHaveHolderIdentity(t, namespace, appName,
func(holder string) bool { return holder == "" }, 200*time.Millisecond)
func(holder string) bool { return holder == "" }, 1*time.Minute)
}

// Given a list of pods, return a list of their names.
Expand Down Expand Up @@ -220,13 +220,14 @@ func waitForLeaderElectionLeaseToHaveHolderIdentity(
waitDuration time.Duration,
) {
t.Helper()
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
ctx, cancel := context.WithTimeout(context.Background(), waitDuration*2)
defer cancel()
client := testlib.NewKubernetesClientset(t)

testlib.RequireEventually(t, func(requireEventually *require.Assertions) {
lease, err := client.CoordinationV1().Leases(namespace).Get(ctx, leaseName, metav1.GetOptions{})
requireEventually.NoError(err)
requireEventually.True(holderIdentityPredicate(*lease.Spec.HolderIdentity))
requireEventually.Truef(holderIdentityPredicate(*lease.Spec.HolderIdentity),
"leader election lease had holder %s", *lease.Spec.HolderIdentity)
}, waitDuration, 200*time.Millisecond)
}

0 comments on commit 7ca590f

Please sign in to comment.