From ebdf975bc35e0d627af1f6f0dbada0565adbe04d Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Thu, 13 Sep 2018 15:44:03 -0700 Subject: [PATCH] Added integration test to test skaffold fix with v1alpha3 --- integration/run_test.go | 45 +++++++++++++------ .../{old-config => v1alpha1}/Dockerfile | 0 .../{old-config => v1alpha1}/k8s-pod.yaml | 0 .../testdata/{old-config => v1alpha1}/main.go | 0 .../{old-config => v1alpha1}/skaffold.yaml | 0 integration/testdata/v1alpha2/Dockerfile | 6 +++ integration/testdata/v1alpha2/k8s-pod.yaml | 8 ++++ integration/testdata/v1alpha2/main.go | 13 ++++++ integration/testdata/v1alpha2/skaffold.yaml | 13 ++++++ 9 files changed, 71 insertions(+), 14 deletions(-) rename integration/testdata/{old-config => v1alpha1}/Dockerfile (100%) rename integration/testdata/{old-config => v1alpha1}/k8s-pod.yaml (100%) rename integration/testdata/{old-config => v1alpha1}/main.go (100%) rename integration/testdata/{old-config => v1alpha1}/skaffold.yaml (100%) create mode 100644 integration/testdata/v1alpha2/Dockerfile create mode 100644 integration/testdata/v1alpha2/k8s-pod.yaml create mode 100644 integration/testdata/v1alpha2/main.go create mode 100644 integration/testdata/v1alpha2/skaffold.yaml diff --git a/integration/run_test.go b/integration/run_test.go index 7b0f3b9200c..76e17642cbc 100644 --- a/integration/run_test.go +++ b/integration/run_test.go @@ -221,22 +221,39 @@ func setupNamespace(t *testing.T) (*v1.Namespace, func()) { } } func TestFix(t *testing.T) { - ns, deleteNs := setupNamespace(t) - defer deleteNs() - - fixCmd := exec.Command("skaffold", "fix", "-f", "skaffold.yaml") - fixCmd.Dir = "testdata/old-config" - out, err := util.RunCmdOut(fixCmd) - if err != nil { - t.Fatalf("testing error: %v", err) + tests := []struct { + name string + directory string + }{ + { + name: "test v1alpha1 to v1alpha2 fix", + directory: "testdata/v1alpha1", + }, + { + name: "test v1alpha2 to v1alpha3 kaniko fix", + directory: "testdata/v1alpha2", + }, } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ns, deleteNs := setupNamespace(t) + defer deleteNs() - runCmd := exec.Command("skaffold", "run", "--namespace", ns.Name, "-f", "-") - runCmd.Dir = "testdata/old-config" - runCmd.Stdin = bytes.NewReader(out) - err = util.RunCmd(runCmd) - if err != nil { - t.Fatalf("testing error: %v", err) + fixCmd := exec.Command("skaffold", "fix", "-f", "skaffold.yaml") + fixCmd.Dir = test.directory + out, err := util.RunCmdOut(fixCmd) + if err != nil { + t.Fatalf("testing error: %v", err) + } + + runCmd := exec.Command("skaffold", "run", "--namespace", ns.Name, "-f", "-") + runCmd.Dir = test.directory + runCmd.Stdin = bytes.NewReader(out) + err = util.RunCmd(runCmd) + if err != nil { + t.Fatalf("testing error: %v", err) + } + }) } } diff --git a/integration/testdata/old-config/Dockerfile b/integration/testdata/v1alpha1/Dockerfile similarity index 100% rename from integration/testdata/old-config/Dockerfile rename to integration/testdata/v1alpha1/Dockerfile diff --git a/integration/testdata/old-config/k8s-pod.yaml b/integration/testdata/v1alpha1/k8s-pod.yaml similarity index 100% rename from integration/testdata/old-config/k8s-pod.yaml rename to integration/testdata/v1alpha1/k8s-pod.yaml diff --git a/integration/testdata/old-config/main.go b/integration/testdata/v1alpha1/main.go similarity index 100% rename from integration/testdata/old-config/main.go rename to integration/testdata/v1alpha1/main.go diff --git a/integration/testdata/old-config/skaffold.yaml b/integration/testdata/v1alpha1/skaffold.yaml similarity index 100% rename from integration/testdata/old-config/skaffold.yaml rename to integration/testdata/v1alpha1/skaffold.yaml diff --git a/integration/testdata/v1alpha2/Dockerfile b/integration/testdata/v1alpha2/Dockerfile new file mode 100644 index 00000000000..2d107918ad0 --- /dev/null +++ b/integration/testdata/v1alpha2/Dockerfile @@ -0,0 +1,6 @@ +FROM gcr.io/google-appengine/golang + +WORKDIR /go/src/github.com/GoogleCloudPlatform/skaffold +CMD ["./app"] +COPY main.go . +RUN go build -o app main.go diff --git a/integration/testdata/v1alpha2/k8s-pod.yaml b/integration/testdata/v1alpha2/k8s-pod.yaml new file mode 100644 index 00000000000..df436eb186b --- /dev/null +++ b/integration/testdata/v1alpha2/k8s-pod.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Pod +metadata: + name: getting-started-kaniko +spec: + containers: + - name: getting-started + image: gcr.io/k8s-skaffold/skaffold-example diff --git a/integration/testdata/v1alpha2/main.go b/integration/testdata/v1alpha2/main.go new file mode 100644 index 00000000000..64b7bdfc4a1 --- /dev/null +++ b/integration/testdata/v1alpha2/main.go @@ -0,0 +1,13 @@ +package main + +import ( + "fmt" + "time" +) + +func main() { + for { + fmt.Println("Hello world!") + time.Sleep(time.Second * 1) + } +} diff --git a/integration/testdata/v1alpha2/skaffold.yaml b/integration/testdata/v1alpha2/skaffold.yaml new file mode 100644 index 00000000000..1b81d4a523d --- /dev/null +++ b/integration/testdata/v1alpha2/skaffold.yaml @@ -0,0 +1,13 @@ +apiVersion: skaffold/v1alpha2 +kind: Config +build: + artifacts: + - imageName: gcr.io/k8s-skaffold/skaffold-example + kaniko: + gcsBucket: skaffold-kaniko + pullSecretName: e2esecret + namespace: default +deploy: + kubectl: + manifests: + - k8s-*