Skip to content

Commit

Permalink
Merge pull request kubernetes#26123 from brendandburns/flaker
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

Add some extra checking in the tests to prevent flakes.

Attempts to fix kubernetes#25967

The hypothesis is that somehow waitTest() catches an idle that occurs before all changes have been applied.  This will block until the expected number of changes have arrived.
  • Loading branch information
k8s-merge-robot committed May 25, 2016
2 parents 28a6015 + 88663fc commit 70a7199
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/controller/persistentvolume/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
}
Expand Down

0 comments on commit 70a7199

Please sign in to comment.