Move the pod setup outside of the mount test loop. (#1423)

Deleting pods with HVs takes some time, so let's do that separately.
pull/1424/head
dlorenc 2017-04-27 12:50:04 -07:00 committed by GitHub
parent c9bb006283
commit 56b45d6488
2 changed files with 15 additions and 4 deletions

View File

@ -49,7 +49,7 @@ func testMounting(t *testing.T) {
defer cmd.Process.Kill() defer cmd.Process.Kill()
kubectlRunner := util.NewKubectlRunner(t) kubectlRunner := util.NewKubectlRunner(t)
podName := "busybox" podName := "busybox-mount"
podPath, _ := filepath.Abs("testdata/busybox-mount-test.yaml") podPath, _ := filepath.Abs("testdata/busybox-mount-test.yaml")
// Write file in mounted dir from host // Write file in mounted dir from host
@ -62,12 +62,23 @@ func testMounting(t *testing.T) {
t.Fatalf("Unexpected error while writing file %s: %s.", path, err) t.Fatalf("Unexpected error while writing file %s: %s.", path, err)
} }
} }
mountTest := func() error {
// Create the pods we need outside the main test loop.
setupTest := func() error {
if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil { if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil {
return err return err
} }
defer kubectlRunner.RunCommand([]string{"delete", "-f", podPath}) return nil
}
defer kubectlRunner.RunCommand([]string{"delete", "-f", podPath})
if err := commonutil.RetryAfter(40, setupTest, 5*time.Second); err != nil {
t.Fatal("mountTest failed with error:", err)
}
mountTest := func() error {
// Wait for the pod to actually startup.
p := &api.Pod{} p := &api.Pod{}
for p.Status.Phase != "Running" { for p.Status.Phase != "Running" {
p, err = kubectlRunner.GetPod(podName, "default") p, err = kubectlRunner.GetPod(podName, "default")

View File

@ -1,7 +1,7 @@
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
name: busybox name: busybox-mount
spec: spec:
containers: containers:
- image: busybox:glibc - image: busybox:glibc