From aeaa5733f89bdec3f175a3e9cf5105626e69b7e4 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 23 Jul 2019 15:03:40 -0700 Subject: [PATCH] consistant naming for kubectl runner --- test/integration/cluster_status_test.go | 4 ++-- test/integration/mount_test.go | 12 ++++++------ test/integration/persistence_test.go | 4 ++-- test/integration/pv_test.go | 10 +++++----- test/integration/start_stop_delete_test.go | 4 ++-- test/integration/tunnel_test.go | 20 ++++++++++---------- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/test/integration/cluster_status_test.go b/test/integration/cluster_status_test.go index 9af4dd98a..f848e39ef 100644 --- a/test/integration/cluster_status_test.go +++ b/test/integration/cluster_status_test.go @@ -28,12 +28,12 @@ import ( ) func testClusterStatus(t *testing.T) { - kubectlRunner := util.NewKubectlRunner(t) + kr := util.NewKubectlRunner(t) cs := api.ComponentStatusList{} healthy := func() error { t.Log("Checking if cluster is healthy.") - if err := kubectlRunner.RunCommandParseOutput([]string{"get", "cs"}, &cs); err != nil { + if err := kr.RunCommandParseOutput([]string{"get", "cs"}, &cs); err != nil { return err } for _, i := range cs.Items { diff --git a/test/integration/mount_test.go b/test/integration/mount_test.go index d6459eac9..38af18aae 100644 --- a/test/integration/mount_test.go +++ b/test/integration/mount_test.go @@ -60,7 +60,7 @@ func testMounting(t *testing.T) { } }() - kubectlRunner := util.NewKubectlRunner(t) + kr := util.NewKubectlRunner(t) podName := "busybox-mount" curdir, err := filepath.Abs("") if err != nil { @@ -77,14 +77,14 @@ func testMounting(t *testing.T) { // Create the pods we need outside the main test loop. setupTest := func() error { t.Logf("Deploying pod from: %s", podPath) - if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil { + if _, err := kr.RunCommand([]string{"create", "-f", podPath}); err != nil { return err } return nil } defer func() { t.Logf("Deleting pod from: %s", podPath) - if out, err := kubectlRunner.RunCommand([]string{"delete", "-f", podPath}); err != nil { + if out, err := kr.RunCommand([]string{"delete", "-f", podPath}); err != nil { t.Logf("delete -f %s failed: %v\noutput: %s\n", podPath, err, out) } }() @@ -99,7 +99,7 @@ func testMounting(t *testing.T) { t.Logf("Pods appear to be running") mountTest := func() error { - if err := verifyFiles(mk, kubectlRunner, tempDir, podName, expected); err != nil { + if err := verifyFiles(mk, kr, tempDir, podName, expected); err != nil { t.Fatalf(err.Error()) } @@ -144,7 +144,7 @@ func waitForPods(s map[string]string) error { return nil } -func verifyFiles(mk util.MinikubeRunner, kubectlRunner *util.KubectlRunner, tempDir string, podName string, expected string) error { +func verifyFiles(mk util.MinikubeRunner, kr *util.KubectlRunner, tempDir string, podName string, expected string) error { path := filepath.Join(tempDir, "frompod") out, err := ioutil.ReadFile(path) if err != nil { @@ -156,7 +156,7 @@ func verifyFiles(mk util.MinikubeRunner, kubectlRunner *util.KubectlRunner, temp } // test that file written from host was read in by the pod via cat /mount-9p/fromhost; - if out, err = kubectlRunner.RunCommand([]string{"logs", podName}); err != nil { + if out, err = kr.RunCommand([]string{"logs", podName}); err != nil { return err } if string(out) != expected { diff --git a/test/integration/persistence_test.go b/test/integration/persistence_test.go index 8d5dac922..be6ff22bc 100644 --- a/test/integration/persistence_test.go +++ b/test/integration/persistence_test.go @@ -35,7 +35,7 @@ func TestPersistence(t *testing.T) { } mk.EnsureRunning() - kubectlRunner := util.NewKubectlRunner(t) + kr := util.NewKubectlRunner(t) curdir, err := filepath.Abs("") if err != nil { t.Errorf("Error getting the file path for current directory: %s", curdir) @@ -43,7 +43,7 @@ func TestPersistence(t *testing.T) { podPath := path.Join(curdir, "testdata", "busybox.yaml") // Create a pod and wait for it to be running. - if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil { + if _, err := kr.RunCommand([]string{"create", "-f", podPath}); err != nil { t.Fatalf("Error creating test pod: %v", err) } diff --git a/test/integration/pv_test.go b/test/integration/pv_test.go index f648f79db..a912c3558 100644 --- a/test/integration/pv_test.go +++ b/test/integration/pv_test.go @@ -40,10 +40,10 @@ var ( func testProvisioning(t *testing.T) { t.Parallel() - kubectlRunner := util.NewKubectlRunner(t) + kr := util.NewKubectlRunner(t) defer func() { - if out, err := kubectlRunner.RunCommand([]string{"delete", "pvc", pvcName}); err != nil { + if out, err := kr.RunCommand([]string{"delete", "pvc", pvcName}); err != nil { t.Logf("delete pvc %s failed: %v\noutput: %s\n", pvcName, err, out) } }() @@ -53,7 +53,7 @@ func testProvisioning(t *testing.T) { checkStorageClass := func() error { scl := storage.StorageClassList{} - if err := kubectlRunner.RunCommandParseOutput([]string{"get", "storageclass"}, &scl); err != nil { + if err := kr.RunCommandParseOutput([]string{"get", "storageclass"}, &scl); err != nil { return fmt.Errorf("get storageclass: %v", err) } @@ -88,14 +88,14 @@ func testProvisioning(t *testing.T) { // Now create the PVC pvcPath := filepath.Join(*testdataDir, "pvc.yaml") - if _, err := kubectlRunner.RunCommand([]string{"create", "-f", pvcPath}); err != nil { + if _, err := kr.RunCommand([]string{"create", "-f", pvcPath}); err != nil { t.Fatalf("Error creating pvc: %v", err) } // And check that it gets bound to a PV. checkStorage := func() error { pvc := core.PersistentVolumeClaim{} - if err := kubectlRunner.RunCommandParseOutput(pvcCmd, &pvc); err != nil { + if err := kr.RunCommandParseOutput(pvcCmd, &pvc); err != nil { return err } // The test passes if the volume claim gets bound. diff --git a/test/integration/start_stop_delete_test.go b/test/integration/start_stop_delete_test.go index a707a0363..a995cec18 100644 --- a/test/integration/start_stop_delete_test.go +++ b/test/integration/start_stop_delete_test.go @@ -83,8 +83,8 @@ func TestStartStop(t *testing.T) { } // check for the current-context before and after the stop - kubectlRunner := util.NewKubectlRunner(t) - currentContext, err := kubectlRunner.RunCommand([]string{"config", "current-context"}) + kr := util.NewKubectlRunner(t) + currentContext, err := kr.RunCommand([]string{"config", "current-context"}) if err != nil { t.Fatalf("Failed to fetch current-context") } diff --git a/test/integration/tunnel_test.go b/test/integration/tunnel_test.go index 83a224f59..bfdd0a066 100644 --- a/test/integration/tunnel_test.go +++ b/test/integration/tunnel_test.go @@ -46,9 +46,9 @@ func testTunnel(t *testing.T) { } t.Log("starting tunnel test...") - mk := NewMinikubeRunner(t, "--wait=false") + mkNewMinikubeRunner(t, "--wait=false") go func() { - output := mk.RunCommand("tunnel --alsologtostderr -v 8 --logtostderr", true) + output := mkCommand("tunnel --alsologtostderr -v 8 --logtostderr", true) if t.Failed() { fmt.Println(output) } @@ -60,7 +60,7 @@ func testTunnel(t *testing.T) { t.Fatal(errors.Wrap(err, "cleaning up tunnels")) } - kubectlRunner := util.NewKubectlRunner(t) + kr := util.NewKubectlRunner(t) t.Log("deploying nginx...") curdir, err := filepath.Abs("") @@ -68,7 +68,7 @@ func testTunnel(t *testing.T) { t.Errorf("Error getting the file path for current directory: %s", curdir) } podPath := path.Join(curdir, "testdata", "testsvc.yaml") - if _, err := kubectlRunner.RunCommand([]string{"apply", "-f", podPath}); err != nil { + if _, err := kr.RunCommand([]string{"apply", "-f", podPath}); err != nil { t.Fatalf("creating nginx ingress resource: %s", err) } @@ -89,13 +89,13 @@ func testTunnel(t *testing.T) { t.Log("getting nginx ingress...") - nginxIP, err := getIngress(kubectlRunner) + nginxIP, err := getIngress(kr) if err != nil { t.Errorf("error getting ingress IP for nginx: %s", err) } if len(nginxIP) == 0 { - stdout, err := describeIngress(kubectlRunner) + stdout, err := describeIngress(kr) if err != nil { t.Errorf("error debugging nginx service: %s", err) @@ -113,12 +113,12 @@ func testTunnel(t *testing.T) { } } -func getIngress(kubectlRunner *util.KubectlRunner) (string, error) { +func getIngress(kr *util.KubectlRunner) (string, error) { nginxIP := "" var ret error err := wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) { cmd := []string{"get", "svc", "nginx-svc", "-o", "jsonpath={.status.loadBalancer.ingress[0].ip}"} - stdout, err := kubectlRunner.RunCommand(cmd) + stdout, err := kr.RunCommand(cmd) switch { case err == nil: nginxIP = string(stdout) @@ -137,8 +137,8 @@ func getIngress(kubectlRunner *util.KubectlRunner) (string, error) { return nginxIP, ret } -func describeIngress(kubectlRunner *util.KubectlRunner) ([]byte, error) { - return kubectlRunner.RunCommand([]string{"get", "svc", "nginx-svc", "-o", "jsonpath={.status}"}) +func describeIngress(kr *util.KubectlRunner) ([]byte, error) { + return kr.RunCommand([]string{"get", "svc", "nginx-svc", "-o", "jsonpath={.status}"}) } // getResponseBody returns the contents of a URL -- GitLab