organize cache functional test

pull/5987/head
Medya Gh 2019-11-26 16:19:29 -08:00
parent 63868dba4d
commit 71857f4288
1 changed files with 38 additions and 27 deletions

View File

@ -313,36 +313,47 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) {
if NoneDriver() {
t.Skipf("skipping: cache unsupported by none")
}
for _, img := range []string{"busybox", "busybox:1.28.4-glibc", "k8s.gcr.io/pause:latest"} {
_, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "add", img))
if err != nil {
t.Errorf("failed to add %q to cache", img)
}
}
t.Run("cache", func(t *testing.T) {
t.Run("add", func(t *testing.T) {
for _, img := range []string{"busybox", "busybox:1.28.4-glibc", "k8s.gcr.io/pause:latest"} {
_, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "add", img))
if err != nil {
t.Errorf("Failed to cache image %q", img)
}
}
})
t.Run("delete", func(t *testing.T) {
_, err := Run(t, exec.CommandContext(ctx, Target(), "cache", "delete", "busybox:1.28.4-glibc"))
if err != nil {
t.Errorf("failed to delete image busybox:1.28.4-glibc from cache: %v", err)
}
})
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker", "images"))
if err != nil {
t.Errorf("failed to get docker images through ssh %v", err)
t.Run("list", func(t *testing.T) {
rr, err := Run(t, exec.CommandContext(ctx, Target(), "cache", "list"))
if err != nil {
t.Errorf("cache list failed: %v", err)
}
if !strings.Contains(rr.Output(), "k8s.gcr.io/pause") {
t.Errorf("cache list did not include k8s.gcr.io/pause")
}
if strings.Contains(rr.Output(), "busybox:1.28.4-glibc") {
t.Errorf("cache list should not include busybox:1.28.4-glibc")
}
})
}
if !strings.Contains(rr.Output(), "busybox:1.28.4-glibc") {
t.Errorf("expected busybox:1.28.4-glibc to be loaded by docker inside minikube node. but got %s", rr.Output())
}
_, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "delete", "busybox:1.28.4-glibc"))
if err != nil {
t.Errorf("failed to delete image busybox:1.28.4-glibc from cache: %v", err)
}
t.Run("verify cache inside node", func(t *testing.T) {
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker", "images"))
if err != nil {
t.Errorf("failed to get docker images through ssh %v", err)
}
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "list"))
if err != nil {
t.Errorf("cache list failed: %v", err)
}
if !strings.Contains(rr.Output(), "k8s.gcr.io/pause") {
t.Errorf("cache list did not include k8s.gcr.io/pause")
}
if strings.Contains(rr.Output(), "busybox:1.28.4-glibc") {
t.Errorf("cache list should not include busybox:1.28.4-glibc")
}
if !strings.Contains(rr.Output(), "busybox:1.28.4-glibc") {
t.Errorf("expected busybox:1.28.4-glibc to be loaded by docker inside minikube node. but got %s", rr.Output())
}
})
})
}
// validateConfigCmd asserts basic "config" command functionality