mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
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:
parent
38348532a3
commit
e198c3a544
@ -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())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user