mirror of https://github.com/k3s-io/k3s
Merge pull request #26123 from brendandburns/flaker
Automatic merge from submit-queue Add some extra checking in the tests to prevent flakes. Attempts to fix https://github.com/kubernetes/kubernetes/issues/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.pull/6/head
commit
70a71990d4
|
@ -33,6 +33,7 @@ import (
|
||||||
// can't reliably simulate periodic sync of volumes/claims - it would be
|
// can't reliably simulate periodic sync of volumes/claims - it would be
|
||||||
// either very timing-sensitive or slow to wait for real periodic sync.
|
// either very timing-sensitive or slow to wait for real periodic sync.
|
||||||
func TestControllerSync(t *testing.T) {
|
func TestControllerSync(t *testing.T) {
|
||||||
|
expectedChanges := []int{1, 4, 1, 1}
|
||||||
tests := []controllerTest{
|
tests := []controllerTest{
|
||||||
// [Unit test set 5] - controller tests.
|
// [Unit test set 5] - controller tests.
|
||||||
// We test the controller as if
|
// 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)
|
glog.V(4).Infof("starting test %q", test.name)
|
||||||
|
|
||||||
// Initialize the controller
|
// Initialize the controller
|
||||||
|
@ -148,13 +149,17 @@ func TestControllerSync(t *testing.T) {
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count := reactor.getChangeCount()
|
||||||
|
|
||||||
// Call the tested function
|
// Call the tested function
|
||||||
err := test.test(ctrl, reactor, test)
|
err := test.test(ctrl, reactor, test)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Test %q initial test call failed: %v", test.name, err)
|
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)
|
evaluateTestResults(ctrl, reactor, test, t)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue