From f6a3966abb56c8baff7a5d7fe8f4b96e149f9007 Mon Sep 17 00:00:00 2001 From: Piotr Szczesniak Date: Wed, 19 Aug 2015 11:29:35 +0200 Subject: [PATCH] Added clean up to scheduler-predicates --- test/e2e/scheduler_predicates.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/e2e/scheduler_predicates.go b/test/e2e/scheduler_predicates.go index 9634271f6f3..7f6b3abadc0 100644 --- a/test/e2e/scheduler_predicates.go +++ b/test/e2e/scheduler_predicates.go @@ -124,6 +124,16 @@ func verifyResult(c *client.Client, podName string, ns string, oldNotRunning int Expect(schedEvents.Items).ToNot(BeEmpty(), printOnce(fmt.Sprintf("Pods found in the cluster: %#v", allPods))) } +func cleanupPods(c *client.Client, ns string) { + By("Removing all pods in namespace " + ns) + pods, err := c.Pods(ns).List(labels.Everything(), fields.Everything()) + expectNoError(err) + opt := api.NewDeleteOptions(0) + for _, p := range pods.Items { + expectNoError(c.Pods(ns).Delete(p.ObjectMeta.Name, opt)) + } +} + var _ = Describe("SchedulerPredicates", func() { var c *client.Client var nodeList *api.NodeList @@ -228,6 +238,7 @@ var _ = Describe("SchedulerPredicates", func() { time.Sleep(10 * time.Second) verifyResult(c, podName, ns, currentlyDeadPods) + cleanupPods(c, ns) }) // This test verifies we don't allow scheduling of pods in a way that sum of limits of pods is greater than machines capacit. @@ -316,6 +327,7 @@ var _ = Describe("SchedulerPredicates", func() { time.Sleep(10 * time.Second) verifyResult(c, podName, ns, currentlyDeadPods) + cleanupPods(c, ns) }) // Test Nodes does not have any label, hence it should be impossible to schedule Pod with @@ -355,5 +367,6 @@ var _ = Describe("SchedulerPredicates", func() { time.Sleep(10 * time.Second) verifyResult(c, podName, ns, currentlyDeadPods) + cleanupPods(c, ns) }) })