Skip to content

Commit

Permalink
Merge pull request #1695 from vmware-tanzu/fix_pod_shutdown_test_flake
Browse files Browse the repository at this point in the history
fix flake seen in pod_shutdown_test.go
  • Loading branch information
cfryanr authored Sep 27, 2023
2 parents 7513092 + 87b7ea1 commit 24069b5
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 24069b5

Please sign in to comment.