Skip to content

Commit

Permalink
Added integration test to test skaffold fix with v1alpha3
Browse files Browse the repository at this point in the history
  • Loading branch information
Priya Wadhwa committed Sep 13, 2018
1 parent e69338b commit ebdf975
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 14 deletions.
45 changes: 31 additions & 14 deletions integration/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions integration/testdata/v1alpha2/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions integration/testdata/v1alpha2/k8s-pod.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions integration/testdata/v1alpha2/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main

import (
"fmt"
"time"
)

func main() {
for {
fmt.Println("Hello world!")
time.Sleep(time.Second * 1)
}
}
13 changes: 13 additions & 0 deletions integration/testdata/v1alpha2/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -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-*

0 comments on commit ebdf975

Please sign in to comment.