Skip to content

Commit

Permalink
fixing TestCascadingDeletion flake
Browse files Browse the repository at this point in the history
  • Loading branch information
Chao Xu committed May 17, 2016
1 parent 2170638 commit 0cda99b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/integration/garbage_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,29 @@ func TestCascadingDeletion(t *testing.T) {
if err := rcClient.Delete(toBeDeletedRCName, nil); err != nil {
t.Fatalf("failed to delete replication controller: %v", err)
}

// wait for the garbage collector to drain its queue
if err := wait.Poll(10*time.Second, 120*time.Second, func() (bool, error) {
return gc.QueuesDrained(), nil
}); err != nil {
t.Fatal(err)
}
// sometimes the deletion of the RC takes long time to be observed by
// the gc, so wait for the garbage collector to observe the deletion of
// the toBeDeletedRC
if err := wait.Poll(10*time.Second, 120*time.Second, func() (bool, error) {
return !gc.GraphHasUID([]types.UID{toBeDeletedRC.ObjectMeta.UID}), nil
}); err != nil {
t.Fatal(err)
}
// wait for the garbage collector to drain its queue again because it's
// possible it just processed the delete of the toBeDeletedRC.
if err := wait.Poll(10*time.Second, 120*time.Second, func() (bool, error) {
return gc.QueuesDrained(), nil
}); err != nil {
t.Fatal(err)
}

t.Logf("garbage collector queues drained")
// checks the garbage collect doesn't delete pods it shouldn't do.
if _, err := podClient.Get(independentPodName); err != nil {
Expand All @@ -210,7 +227,7 @@ func TestCascadingDeletion(t *testing.T) {
t.Fatal(err)
}
if _, err := podClient.Get(garbageCollectedPodName); err == nil || !errors.IsNotFound(err) {
t.Fatalf("expect pod %s to be garbage collected", garbageCollectedPodName)
t.Fatalf("expect pod %s to be garbage collected, got err= %v", garbageCollectedPodName, err)
}
}

Expand Down

0 comments on commit 0cda99b

Please sign in to comment.