diff --git a/test/e2e/framework/node/wait_test.go b/test/e2e/framework/node/wait_test.go index 174d55016d6..3b3373de891 100644 --- a/test/e2e/framework/node/wait_test.go +++ b/test/e2e/framework/node/wait_test.go @@ -168,15 +168,26 @@ func TestCheckReadyForTests(t *testing.T) { return true, nodeList, tc.nodeListErr }) checkFunc := CheckReadyForTests(c, tc.nonblockingTaints, tc.allowedNotReadyNodes, testLargeClusterThreshold) - out, err := checkFunc() - if out != tc.expected { - t.Errorf("Expected %v but got %v", tc.expected, out) - } - switch { - case err == nil && len(tc.expectedErr) > 0: - t.Errorf("Expected error %q nil", tc.expectedErr) - case err != nil && err.Error() != tc.expectedErr: - t.Errorf("Expected error %q but got %q", tc.expectedErr, err.Error()) + // The check function returns "false, nil" during its + // first two calls, therefore we have to try several + // times until we get the expected error. + for attempt := 0; attempt <= 3; attempt++ { + out, err := checkFunc() + expected := tc.expected + expectedErr := tc.expectedErr + if tc.nodeListErr != nil && attempt < 2 { + expected = false + expectedErr = "" + } + if out != expected { + t.Errorf("Expected %v but got %v", expected, out) + } + switch { + case err == nil && expectedErr != "": + t.Errorf("attempt #%d: expected error %q nil", attempt, expectedErr) + case err != nil && err.Error() != expectedErr: + t.Errorf("attempt #%d: expected error %q but got %q", attempt, expectedErr, err.Error()) + } } }) }