Improve running time of TestSchedulerWithVolumeBinding

Only wait for finished binding or error, but not both

Signed-off-by: Aldo Culquicondor <acondor@google.com>
Change-Id: I13d16e6c7c45c6527591aa05cc79fc5e96d47a68
This commit is contained in:
Aldo Culquicondor 2020-08-11 14:23:33 -04:00
parent eb8b5a9854
commit 1978866474

View File

@ -953,28 +953,26 @@ func TestSchedulerWithVolumeBinding(t *testing.T) {
t.Fatalf("scheduling timeout after %v", wait.ForeverTestTimeout) t.Fatalf("scheduling timeout after %v", wait.ForeverTestTimeout)
} }
stopFunc() stopFunc()
// Wait for scheduling to return an error // Wait for scheduling to return an error or succeed binding.
var (
gotErr error
gotBind *v1.Binding
)
select { select {
case err := <-errChan: case gotErr = <-errChan:
if item.expectError == nil || !reflect.DeepEqual(item.expectError.Error(), err.Error()) { case gotBind = <-bindingChan:
t.Errorf("err \nWANT=%+v,\nGOT=%+v", item.expectError, err)
}
case <-time.After(chanTimeout): case <-time.After(chanTimeout):
if item.expectError != nil { t.Fatalf("did not receive pod binding or error after %v", chanTimeout)
t.Errorf("did not receive error after %v", chanTimeout)
}
} }
if item.expectError != nil {
// Wait for pod to succeed binding if gotErr == nil || item.expectError.Error() != gotErr.Error() {
select { t.Errorf("err \nWANT=%+v,\nGOT=%+v", item.expectError, gotErr)
case b := <-bindingChan:
if !reflect.DeepEqual(item.expectPodBind, b) {
t.Errorf("err \nWANT=%+v,\nGOT=%+v", item.expectPodBind, b)
}
case <-time.After(chanTimeout):
if item.expectPodBind != nil {
t.Errorf("did not receive pod binding after %v", chanTimeout)
} }
} else if gotErr != nil {
t.Errorf("err \nWANT=%+v,\nGOT=%+v", item.expectError, gotErr)
}
if !cmp.Equal(item.expectPodBind, gotBind) {
t.Errorf("err \nWANT=%+v,\nGOT=%+v", item.expectPodBind, gotBind)
} }
if item.expectAssumeCalled != fakeVolumeBinder.AssumeCalled { if item.expectAssumeCalled != fakeVolumeBinder.AssumeCalled {