Commit bc82d87f authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #43398 from enisoc/deletion-race-flake

Automatic merge from submit-queue Deflake TestSyncDeploymentDeletionRace **What this PR does / why we need it**: The cache was sometimes catching up while we were testing the case where the cache is not yet caught up. Before this fix, I could reproduce the failure with the following command. After the fix, it passes. ``` go test -count 100000 -run TestSyncDeploymentDeletionRace ``` I checked the other controllers, and they all were already not starting informers for the deletion race test. I also checked that the deletion race tests for other controllers all pass with `-count 100000`. **Which issue this PR fixes**: Fixes #43390 **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
parents e668ee11 0b923364
...@@ -195,19 +195,21 @@ func (f *fixture) newController() (*DeploymentController, informers.SharedInform ...@@ -195,19 +195,21 @@ func (f *fixture) newController() (*DeploymentController, informers.SharedInform
return c, informers return c, informers
} }
func (f *fixture) runExpectError(deploymentName string) { func (f *fixture) runExpectError(deploymentName string, startInformers bool) {
f.run_(deploymentName, true) f.run_(deploymentName, startInformers, true)
} }
func (f *fixture) run(deploymentName string) { func (f *fixture) run(deploymentName string) {
f.run_(deploymentName, false) f.run_(deploymentName, true, false)
} }
func (f *fixture) run_(deploymentName string, expectError bool) { func (f *fixture) run_(deploymentName string, startInformers bool, expectError bool) {
c, informers := f.newController() c, informers := f.newController()
stopCh := make(chan struct{}) if startInformers {
defer close(stopCh) stopCh := make(chan struct{})
informers.Start(stopCh) defer close(stopCh)
informers.Start(stopCh)
}
err := c.syncDeployment(deploymentName) err := c.syncDeployment(deploymentName)
if !expectError && err != nil { if !expectError && err != nil {
...@@ -329,7 +331,8 @@ func TestSyncDeploymentDeletionRace(t *testing.T) { ...@@ -329,7 +331,8 @@ func TestSyncDeploymentDeletionRace(t *testing.T) {
// Expect to only recheck DeletionTimestamp. // Expect to only recheck DeletionTimestamp.
f.expectGetDeploymentAction(d) f.expectGetDeploymentAction(d)
// Sync should fail and requeue to let cache catch up. // Sync should fail and requeue to let cache catch up.
f.runExpectError(getKey(d, t)) // Don't start informers, since we don't want cache to catch up for this test.
f.runExpectError(getKey(d, t), false)
} }
// issue: https://github.com/kubernetes/kubernetes/issues/23218 // issue: https://github.com/kubernetes/kubernetes/issues/23218
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment