From 88663fc58b071afe0ba679de8b171d8e9425665f Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Mon, 23 May 2016 16:25:02 -0700 Subject: [PATCH] Add some extra checking in the tests to prevent flakes. --- pkg/controller/persistentvolume/controller_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/controller/persistentvolume/controller_test.go b/pkg/controller/persistentvolume/controller_test.go index d3f92e6b6f7ea..5b65b1176f574 100644 --- a/pkg/controller/persistentvolume/controller_test.go +++ b/pkg/controller/persistentvolume/controller_test.go @@ -33,6 +33,7 @@ import ( // can't reliably simulate periodic sync of volumes/claims - it would be // either very timing-sensitive or slow to wait for real periodic sync. func TestControllerSync(t *testing.T) { + expectedChanges := []int{1, 4, 1, 1} tests := []controllerTest{ // [Unit test set 5] - controller tests. // We test the controller as if @@ -121,7 +122,7 @@ func TestControllerSync(t *testing.T) { }, } - for _, test := range tests { + for ix, test := range tests { glog.V(4).Infof("starting test %q", test.name) // Initialize the controller @@ -148,13 +149,17 @@ func TestControllerSync(t *testing.T) { time.Sleep(10 * time.Millisecond) } + count := reactor.getChangeCount() + // Call the tested function err := test.test(ctrl, reactor, test) if err != nil { t.Errorf("Test %q initial test call failed: %v", test.name, err) } - reactor.waitTest() + for reactor.getChangeCount() < count+expectedChanges[ix] { + reactor.waitTest() + } evaluateTestResults(ctrl, reactor, test, t) }