e2e: fix node wait test

Because these tests don't run in the CI, the test did not quite match the
actual code anymore. Apparently a retry mechanism was added after the test was
written.
This commit is contained in:
Patrick Ohly 2022-05-11 11:43:55 +02:00
parent 38348532a3
commit e198c3a544

View File

@ -168,15 +168,26 @@ func TestCheckReadyForTests(t *testing.T) {
return true, nodeList, tc.nodeListErr return true, nodeList, tc.nodeListErr
}) })
checkFunc := CheckReadyForTests(c, tc.nonblockingTaints, tc.allowedNotReadyNodes, testLargeClusterThreshold) checkFunc := CheckReadyForTests(c, tc.nonblockingTaints, tc.allowedNotReadyNodes, testLargeClusterThreshold)
out, err := checkFunc() // The check function returns "false, nil" during its
if out != tc.expected { // first two calls, therefore we have to try several
t.Errorf("Expected %v but got %v", tc.expected, out) // times until we get the expected error.
} for attempt := 0; attempt <= 3; attempt++ {
switch { out, err := checkFunc()
case err == nil && len(tc.expectedErr) > 0: expected := tc.expected
t.Errorf("Expected error %q nil", tc.expectedErr) expectedErr := tc.expectedErr
case err != nil && err.Error() != tc.expectedErr: if tc.nodeListErr != nil && attempt < 2 {
t.Errorf("Expected error %q but got %q", tc.expectedErr, err.Error()) 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())
}
} }
}) })
} }