Merge pull request #4965 from cjcullen/pdtestfix

Fix leaking PDs from pd.go e2e test
This commit is contained in:
Zach Loafman 2015-03-03 12:54:13 -08:00
commit 89422b63b9

View File

@ -58,7 +58,7 @@ var _ = Describe("PD", func() {
host0Pod := testPDPod(diskName, host0Name, false) host0Pod := testPDPod(diskName, host0Name, false)
host1Pod := testPDPod(diskName, host1Name, false) host1Pod := testPDPod(diskName, host1Name, false)
By("creating PD") By(fmt.Sprintf("creating PD %q", diskName))
expectNoError(createPD(diskName, testContext.gceConfig.Zone), "Error creating PD") expectNoError(createPD(diskName, testContext.gceConfig.Zone), "Error creating PD")
defer func() { defer func() {
@ -76,8 +76,8 @@ var _ = Describe("PD", func() {
_, err := podClient.Create(host0Pod) _, err := podClient.Create(host0Pod)
expectNoError(err, fmt.Sprintf("Failed to create host0Pod: %v", err)) expectNoError(err, fmt.Sprintf("Failed to create host0Pod: %v", err))
By("waiting up to 60 seconds for host0Pod to start running") By("waiting up to 180 seconds for host0Pod to start running")
expectNoError(waitForPodRunning(c, host0Pod.Name, 60*time.Second), "host0Pod not running after 60 seconds") expectNoError(waitForPodRunning(c, host0Pod.Name, 180*time.Second), "host0Pod not running after 180 seconds")
By("deleting host0Pod") By("deleting host0Pod")
expectNoError(podClient.Delete(host0Pod.Name), "Failed to delete host0Pod") expectNoError(podClient.Delete(host0Pod.Name), "Failed to delete host0Pod")
@ -86,12 +86,22 @@ var _ = Describe("PD", func() {
_, err = podClient.Create(host1Pod) _, err = podClient.Create(host1Pod)
expectNoError(err, "Failed to create host1Pod") expectNoError(err, "Failed to create host1Pod")
By("waiting up to 60 seconds for host1Pod to start running") By("waiting up to 180 seconds for host1Pod to start running")
expectNoError(waitForPodRunning(c, host1Pod.Name, 60*time.Second), "host1Pod not running after 60 seconds") expectNoError(waitForPodRunning(c, host1Pod.Name, 180*time.Second), "host1Pod not running after 180 seconds")
By("deleting host1Pod") By("deleting host1Pod")
expectNoError(podClient.Delete(host1Pod.Name), "Failed to delete host1Pod") expectNoError(podClient.Delete(host1Pod.Name), "Failed to delete host1Pod")
By(fmt.Sprintf("deleting PD %q", diskName))
for start := time.Now(); time.Since(start) < 180*time.Second; time.Sleep(5 * time.Second) {
if err = deletePD(diskName, testContext.gceConfig.Zone); err != nil {
Logf("Couldn't delete PD. Sleeping 5 seconds")
continue
}
break
}
expectNoError(err, "Error deleting PD")
return return
}) })
@ -112,13 +122,13 @@ var _ = Describe("PD", func() {
deletePD(diskName, testContext.gceConfig.Zone) deletePD(diskName, testContext.gceConfig.Zone)
}() }()
By("creating PD") By(fmt.Sprintf("creating PD %q", diskName))
expectNoError(createPD(diskName, testContext.gceConfig.Zone), "Error creating PD") expectNoError(createPD(diskName, testContext.gceConfig.Zone), "Error creating PD")
By("submitting rwPod to ensure PD is formatted") By("submitting rwPod to ensure PD is formatted")
_, err := podClient.Create(rwPod) _, err := podClient.Create(rwPod)
expectNoError(err, "Failed to create rwPod") expectNoError(err, "Failed to create rwPod")
expectNoError(waitForPodRunning(c, rwPod.Name, 60*time.Second), "rwPod not running after 60 seconds") expectNoError(waitForPodRunning(c, rwPod.Name, 180*time.Second), "rwPod not running after 180 seconds")
expectNoError(podClient.Delete(rwPod.Name), "Failed to delete host0Pod") expectNoError(podClient.Delete(rwPod.Name), "Failed to delete host0Pod")
By("submitting host0ROPod to kubernetes") By("submitting host0ROPod to kubernetes")
@ -129,17 +139,27 @@ var _ = Describe("PD", func() {
_, err = podClient.Create(host1ROPod) _, err = podClient.Create(host1ROPod)
expectNoError(err, "Failed to create host1ROPod") expectNoError(err, "Failed to create host1ROPod")
By("waiting up to 60 seconds for host0ROPod to start running") By("waiting up to 180 seconds for host0ROPod to start running")
expectNoError(waitForPodRunning(c, host0ROPod.Name, 60*time.Second), "host0ROPod not running after 60 seconds") expectNoError(waitForPodRunning(c, host0ROPod.Name, 180*time.Second), "host0ROPod not running after 180 seconds")
By("waiting up to 60 seconds for host1ROPod to start running") By("waiting up to 180 seconds for host1ROPod to start running")
expectNoError(waitForPodRunning(c, host1ROPod.Name, 60*time.Second), "host1ROPod not running after 60 seconds") expectNoError(waitForPodRunning(c, host1ROPod.Name, 180*time.Second), "host1ROPod not running after 180 seconds")
By("deleting host0ROPod") By("deleting host0ROPod")
expectNoError(podClient.Delete(host0ROPod.Name), "Failed to delete host0ROPod") expectNoError(podClient.Delete(host0ROPod.Name), "Failed to delete host0ROPod")
By("deleting host1ROPod") By("deleting host1ROPod")
expectNoError(podClient.Delete(host1ROPod.Name), "Failed to delete host1ROPod") expectNoError(podClient.Delete(host1ROPod.Name), "Failed to delete host1ROPod")
By(fmt.Sprintf("deleting PD %q", diskName))
for start := time.Now(); time.Since(start) < 180*time.Second; time.Sleep(5 * time.Second) {
if err = deletePD(diskName, testContext.gceConfig.Zone); err != nil {
Logf("Couldn't delete PD. Sleeping 5 seconds")
continue
}
break
}
expectNoError(err, "Error deleting PD")
}) })
}) })