From 44b2e8464bd3ece4effdb888ceabf65ae2f39ff7 Mon Sep 17 00:00:00 2001 From: Wei Guo Date: Mon, 31 Dec 2018 20:53:19 +0800 Subject: [PATCH] change the period of GarbageCollector.Sync to 200ms for TestGarbageCollectorSync --- .../garbagecollector/garbagecollector_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/controller/garbagecollector/garbagecollector_test.go b/pkg/controller/garbagecollector/garbagecollector_test.go index 60aab9ff19b..b382a3a185c 100644 --- a/pkg/controller/garbagecollector/garbagecollector_test.go +++ b/pkg/controller/garbagecollector/garbagecollector_test.go @@ -856,7 +856,16 @@ func TestGarbageCollectorSync(t *testing.T) { stopCh := make(chan struct{}) defer close(stopCh) go gc.Run(1, stopCh) - go gc.Sync(fakeDiscoveryClient, 10*time.Millisecond, stopCh) + // The pseudo-code of GarbageCollector.Sync(): + // GarbageCollector.Sync(client, period, stopCh): + // wait.Until() loops with `period` until the `stopCh` is closed : + // wait.PollImmediateUntil() loops with 100ms (hardcode) util the `stopCh` is closed: + // GetDeletableResources() + // gc.resyncMonitors() + // controller.WaitForCacheSync() loops with `syncedPollPeriod` (hardcoded to 100ms), until either its stop channel is closed after `period`, or all caches synced. + // + // Setting the period to 200ms allows the WaitForCacheSync() to check for cache sync ~2 times in every wait.PollImmediateUntil() loop. + go gc.Sync(fakeDiscoveryClient, 200*time.Millisecond, stopCh) // Wait until the sync discovers the initial resources fmt.Printf("Test output")