提交 30a714ad 编写于 作者: M Medya Gh

address review comment

上级 9fd88800
...@@ -62,10 +62,10 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { ...@@ -62,10 +62,10 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) {
t.Fatalf("Unexpected error while creating tempDir: %v", err) t.Fatalf("Unexpected error while creating tempDir: %v", err)
} }
mctx, cancel := context.WithTimeout(ctx, Minutes(10)) ctx, cancel := context.WithTimeout(ctx, Minutes(10))
args := []string{"mount", "-p", profile, fmt.Sprintf("%s:%s", tempDir, guestMount), "--alsologtostderr", "-v=1"} args := []string{"mount", "-p", profile, fmt.Sprintf("%s:%s", tempDir, guestMount), "--alsologtostderr", "-v=1"}
ss, err := Start(t, exec.CommandContext(mctx, Target(), args...)) ss, err := Start(t, exec.CommandContext(ctx, Target(), args...))
if err != nil { if err != nil {
t.Fatalf("%v failed: %v", args, err) t.Fatalf("%v failed: %v", args, err)
} }
...@@ -107,7 +107,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { ...@@ -107,7 +107,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) {
// Block until the mount succeeds to avoid file race // Block until the mount succeeds to avoid file race
checkMount := func() error { checkMount := func() error {
_, err := Run(t, exec.CommandContext(mctx, Target(), "-p", profile, "ssh", "findmnt -T /mount-9p | grep 9p")) _, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "findmnt -T /mount-9p | grep 9p"))
return err return err
} }
...@@ -121,7 +121,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { ...@@ -121,7 +121,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) {
} }
// Assert that we can access the mount without an error. Display for debugging. // Assert that we can access the mount without an error. Display for debugging.
rr, err := Run(t, exec.CommandContext(mctx, Target(), "-p", profile, "ssh", "--", "ls", "-la", guestMount)) rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "--", "ls", "-la", guestMount))
if err != nil { if err != nil {
t.Fatalf("failed verifying accessing to the mount. args %q : %v", rr.Command(), err) t.Fatalf("failed verifying accessing to the mount. args %q : %v", rr.Command(), err)
} }
...@@ -129,7 +129,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { ...@@ -129,7 +129,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) {
// Assert that the mount contains our unique test marker, as opposed to a stale mount // Assert that the mount contains our unique test marker, as opposed to a stale mount
tp := filepath.Join("/mount-9p", testMarker) tp := filepath.Join("/mount-9p", testMarker)
rr, err = Run(t, exec.CommandContext(mctx, Target(), "-p", profile, "ssh", "cat", tp)) rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat", tp))
if err != nil { if err != nil {
t.Fatalf("failed to verify the mount contains unique test marked: args %q: %v", rr.Command(), err) t.Fatalf("failed to verify the mount contains unique test marked: args %q: %v", rr.Command(), err)
} }
...@@ -140,12 +140,12 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { ...@@ -140,12 +140,12 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) {
} }
// Start the "busybox-mount" pod. // Start the "busybox-mount" pod.
rr, err = Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "busybox-mount-test.yaml"))) rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "busybox-mount-test.yaml")))
if err != nil { if err != nil {
t.Fatalf("failed to 'kubectl replace' for busybox-mount-test. args %q : %v", rr.Command(), err) t.Fatalf("failed to 'kubectl replace' for busybox-mount-test. args %q : %v", rr.Command(), err)
} }
if _, err := PodWait(mctx, t, profile, "default", "integration-test=busybox-mount", Minutes(4)); err != nil { if _, err := PodWait(ctx, t, profile, "default", "integration-test=busybox-mount", Minutes(4)); err != nil {
t.Fatalf("failed waiting for busybox-mount pod: %v", err) t.Fatalf("failed waiting for busybox-mount pod: %v", err)
} }
...@@ -161,7 +161,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { ...@@ -161,7 +161,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) {
} }
// test that file written from host was read in by the pod via cat /mount-9p/written-by-host; // test that file written from host was read in by the pod via cat /mount-9p/written-by-host;
rr, err = Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "logs", "busybox-mount")) rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "logs", "busybox-mount"))
if err != nil { if err != nil {
t.Errorf("failed to get kubectl logs for busybox-mount. args %q : %v", rr.Command(), err) t.Errorf("failed to get kubectl logs for busybox-mount. args %q : %v", rr.Command(), err)
} }
......
...@@ -36,15 +36,15 @@ import ( ...@@ -36,15 +36,15 @@ import (
func validatePersistentVolumeClaim(ctx context.Context, t *testing.T, profile string) { func validatePersistentVolumeClaim(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile) defer PostMortemLogs(t, profile)
mctx, cancel := context.WithTimeout(ctx, Minutes(10)) ctx, cancel := context.WithTimeout(ctx, Minutes(10))
defer cancel() defer cancel()
if _, err := PodWait(mctx, t, profile, "kube-system", "integration-test=storage-provisioner", Minutes(4)); err != nil { if _, err := PodWait(ctx, t, profile, "kube-system", "integration-test=storage-provisioner", Minutes(4)); err != nil {
t.Fatalf("failed waiting for storage-provisioner: %v", err) t.Fatalf("failed waiting for storage-provisioner: %v", err)
} }
checkStorageClass := func() error { checkStorageClass := func() error {
rr, err := Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "get", "storageclass", "-o=json")) rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "storageclass", "-o=json"))
if err != nil { if err != nil {
return err return err
} }
...@@ -64,13 +64,13 @@ func validatePersistentVolumeClaim(ctx context.Context, t *testing.T, profile st ...@@ -64,13 +64,13 @@ func validatePersistentVolumeClaim(ctx context.Context, t *testing.T, profile st
} }
// Now create a testpvc // Now create a testpvc
rr, err := Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "apply", "-f", filepath.Join(*testdataDir, "pvc.yaml"))) rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "apply", "-f", filepath.Join(*testdataDir, "pvc.yaml")))
if err != nil { if err != nil {
t.Fatalf("kubectl apply pvc.yaml failed: args %q: %v", rr.Command(), err) t.Fatalf("kubectl apply pvc.yaml failed: args %q: %v", rr.Command(), err)
} }
checkStoragePhase := func() error { checkStoragePhase := func() error {
rr, err := Run(t, exec.CommandContext(mctx, "kubectl", "--context", profile, "get", "pvc", "testpvc", "-o=json")) rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "pvc", "testpvc", "-o=json"))
if err != nil { if err != nil {
return err return err
} }
......
...@@ -49,7 +49,7 @@ var ( ...@@ -49,7 +49,7 @@ var (
) )
func validateTunnelCmd(ctx context.Context, t *testing.T, profile string) { func validateTunnelCmd(ctx context.Context, t *testing.T, profile string) {
mctx, cancel := context.WithTimeout(ctx, Minutes(5)) ctx, cancel := context.WithTimeout(ctx, Minutes(5))
type validateFunc func(context.Context, *testing.T, string) type validateFunc func(context.Context, *testing.T, string)
defer cancel() defer cancel()
...@@ -70,7 +70,7 @@ func validateTunnelCmd(ctx context.Context, t *testing.T, profile string) { ...@@ -70,7 +70,7 @@ func validateTunnelCmd(ctx context.Context, t *testing.T, profile string) {
for _, tc := range tests { for _, tc := range tests {
tc := tc tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
tc.validator(mctx, t, profile) tc.validator(ctx, t, profile)
}) })
} }
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册