From 7895fbd45dbb72113e343a7d5e1857ab52a806cf Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Thu, 3 Mar 2022 21:33:01 -0500 Subject: [PATCH] Restore wait loop to integration test --- .../serviceaccount/service_account_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/integration/serviceaccount/service_account_test.go b/test/integration/serviceaccount/service_account_test.go index f5f0adacbf1..d4f3abb2da4 100644 --- a/test/integration/serviceaccount/service_account_test.go +++ b/test/integration/serviceaccount/service_account_test.go @@ -285,6 +285,22 @@ func TestServiceAccountTokenAuthentication(t *testing.T) { if err != nil { t.Fatalf("could not delete token: %v", err) } + // wait for delete to be observed and reacted to via watch + err = wait.PollImmediate(100*time.Millisecond, 30*time.Second, func() (bool, error) { + _, err := roClient.CoreV1().Secrets(myns).List(context.TODO(), metav1.ListOptions{}) + if err == nil { + t.Logf("token is still valid, waiting") + return false, nil + } + if !apierrors.IsUnauthorized(err) { + t.Logf("expected unauthorized error, got %v", err) + return false, nil + } + return true, nil + }) + if err != nil { + t.Fatalf("waiting for token to be invalidated: %v", err) + } doServiceAccountAPIRequests(t, roClient, myns, false, false, false) // Create "rw" user in myns