Wait for Scheduler cache empty.

Signed-off-by: Klaus Ma <klaus1982.cn@gmail.com>
This commit is contained in:
Klaus Ma
2018-08-31 19:42:10 +08:00
parent cd06419973
commit 26142e614c
3 changed files with 21 additions and 1 deletions

View File

@@ -679,3 +679,15 @@ func cleanupPodsInNamespace(cs clientset.Interface, t *testing.T, ns string) {
t.Errorf("error while waiting for pods in namespace %v: %v", ns, err)
}
}
func waitForSchedulerCacheCleanup(sched *scheduler.Scheduler, t *testing.T) {
schedulerCacheIsEmpty := func() (bool, error) {
snapshot := sched.Cache().Snapshot()
return len(snapshot.Nodes) == 0 && len(snapshot.AssumedPods) == 0, nil
}
if err := wait.Poll(time.Second, wait.ForeverTestTimeout, schedulerCacheIsEmpty); err != nil {
t.Errorf("Failed to wait for scheduler cache cleanup: %v", err)
}
}