mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 18:28:13 +00:00 
			
		
		
		
	fix flake integration rotation via informer
Signed-off-by: pacoxu <paco.xu@daocloud.io>
This commit is contained in:
		| @@ -569,8 +569,14 @@ func (is *informerSpy) clear() { | |||||||
| // waitForEvents waits for adds, updates, and deletes to be populated with at least one event. | // waitForEvents waits for adds, updates, and deletes to be populated with at least one event. | ||||||
| func (is *informerSpy) waitForEvents(t *testing.T, wantEvents bool) { | func (is *informerSpy) waitForEvents(t *testing.T, wantEvents bool) { | ||||||
| 	t.Helper() | 	t.Helper() | ||||||
|  | 	// wait for create/update/delete 3 events for 30 seconds | ||||||
|  | 	waitTimeout := time.Second * 30 | ||||||
|  | 	if !wantEvents { | ||||||
|  | 		// wait just 15 seconds for no events | ||||||
|  | 		waitTimeout = time.Second * 15 | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	err := wait.PollImmediate(time.Second, time.Second*30, func() (bool, error) { | 	err := wait.PollImmediate(time.Second, waitTimeout, func() (bool, error) { | ||||||
| 		is.mu.Lock() | 		is.mu.Lock() | ||||||
| 		defer is.mu.Unlock() | 		defer is.mu.Unlock() | ||||||
| 		return len(is.adds) > 0 && len(is.updates) > 0 && len(is.deletes) > 0, nil | 		return len(is.adds) > 0 && len(is.updates) > 0 && len(is.deletes) > 0, nil | ||||||
| @@ -905,14 +911,14 @@ func startConfigMapInformer(ctx context.Context, t *testing.T, client clientset. | |||||||
| func waitForInformerSync(ctx context.Context, t *testing.T, informer cache.SharedIndexInformer, wantSynced bool, lastSyncResourceVersion string) { | func waitForInformerSync(ctx context.Context, t *testing.T, informer cache.SharedIndexInformer, wantSynced bool, lastSyncResourceVersion string) { | ||||||
| 	t.Helper() | 	t.Helper() | ||||||
|  |  | ||||||
| 	syncCtx, cancel := context.WithTimeout(ctx, time.Second*30) | 	syncCtx, cancel := context.WithTimeout(ctx, time.Second*60) | ||||||
| 	defer cancel() | 	defer cancel() | ||||||
| 	if gotSynced := cache.WaitForCacheSync(syncCtx.Done(), informer.HasSynced); wantSynced != gotSynced { | 	if gotSynced := cache.WaitForCacheSync(syncCtx.Done(), informer.HasSynced); wantSynced != gotSynced { | ||||||
| 		t.Fatalf("wanted sync %t, got sync %t", wantSynced, gotSynced) | 		t.Fatalf("wanted sync %t, got sync %t", wantSynced, gotSynced) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if len(lastSyncResourceVersion) != 0 { | 	if len(lastSyncResourceVersion) != 0 { | ||||||
| 		if err := wait.PollImmediate(time.Second, time.Second*30, func() (bool, error) { | 		if err := wait.PollImmediate(time.Second, time.Second*60, func() (bool, error) { | ||||||
| 			return informer.LastSyncResourceVersion() != lastSyncResourceVersion, nil | 			return informer.LastSyncResourceVersion() != lastSyncResourceVersion, nil | ||||||
| 		}); err != nil { | 		}); err != nil { | ||||||
| 			t.Fatalf("informer never changed resource versions from %q: %v", lastSyncResourceVersion, err) | 			t.Fatalf("informer never changed resource versions from %q: %v", lastSyncResourceVersion, err) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 pacoxu
					pacoxu