Add integration test to test against latest skaffold release
This PR: 1. Adds an integration test to test minikube against the latest skaffold release 1. Adds in a sample skaffold app from the skaffold repo to test 1. Adds this test to the addons_certs_docker_ubuntu Github Actions testpull/8779/head
parent
bf38785070
commit
aa51f179bb
|
|
@ -612,7 +612,7 @@ jobs:
|
|||
chmod a+x e2e-*
|
||||
chmod a+x minikube-*
|
||||
START_TIME=$(date -u +%s)
|
||||
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.run "(TestAddons|TestCertOptions)" -test.timeout=10m -test.v -timeout-multiplier=1.5 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt
|
||||
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.run "(TestAddons|TestCertOptions|TestSkaffold)" -test.timeout=10m -test.v -timeout-multiplier=1.5 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt
|
||||
END_TIME=$(date -u +%s)
|
||||
TIME_ELAPSED=$(($END_TIME-$START_TIME))
|
||||
min=$((${TIME_ELAPSED}/60))
|
||||
|
|
|
|||
1
go.mod
1
go.mod
|
|
@ -74,7 +74,6 @@ require (
|
|||
github.com/zchee/go-vmnet v0.0.0-20161021174912-97ebf9174097
|
||||
golang.org/x/build v0.0.0-20190927031335-2835ba2e683f
|
||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 // indirect
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121
|
||||
golang.org/x/text v0.3.2
|
||||
|
|
|
|||
|
|
@ -0,0 +1,97 @@
|
|||
// +build integration
|
||||
|
||||
/*
|
||||
Copyright 2020 The Kubernetes Authors All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-getter"
|
||||
"k8s.io/minikube/pkg/util/retry"
|
||||
)
|
||||
|
||||
func TestSkaffold(t *testing.T) {
|
||||
// get unique profile for test
|
||||
MaybeParallel(t)
|
||||
profile := UniqueProfileName("skaffold")
|
||||
ctx, cancel := context.WithTimeout(context.Background(), Minutes(5))
|
||||
defer CleanupWithLogs(t, profile, cancel)
|
||||
|
||||
// install latest skaffold release
|
||||
tf, err := installSkaffold()
|
||||
if err != nil {
|
||||
t.Fatalf("skaffold release installation failed: %v", err)
|
||||
}
|
||||
defer os.Remove(tf.Name())
|
||||
|
||||
// start minikube cluster
|
||||
args := append([]string{"start", "-p", profile, "--memory=2200"}, StartArgs()...)
|
||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
|
||||
if err != nil {
|
||||
t.Fatalf("starting minikube: %v\n%s", err, rr.Output())
|
||||
}
|
||||
|
||||
// make sure "skaffold run" exits without failure
|
||||
cmd := exec.CommandContext(ctx, tf.Name(), "run", "--kube-context", profile, "--status-check=true", "--port-forward=false")
|
||||
cmd.Dir = "testdata/skaffold"
|
||||
rr, err = Run(t, cmd)
|
||||
if err != nil {
|
||||
t.Fatalf("error running skaffold: %v\n%s", err, rr.Output())
|
||||
}
|
||||
|
||||
// make sure expected deployment is running
|
||||
if _, err := PodWait(ctx, t, profile, "default", "app=leeroy-app", Minutes(1)); err != nil {
|
||||
t.Fatalf("failed waiting for pod leeroy-app: %v", err)
|
||||
}
|
||||
if _, err := PodWait(ctx, t, profile, "default", "app=leeroy-web", Minutes(1)); err != nil {
|
||||
t.Fatalf("failed waiting for pod leeroy-web: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// installSkaffold installs the latest release of skaffold
|
||||
func installSkaffold() (f *os.File, err error) {
|
||||
tf, err := ioutil.TempFile("", "skaffold.exe")
|
||||
if err != nil {
|
||||
return tf, err
|
||||
}
|
||||
tf.Close()
|
||||
|
||||
url := "https://storage.googleapis.com/skaffold/releases/latest/skaffold-%s-amd64"
|
||||
url = fmt.Sprintf(url, runtime.GOOS)
|
||||
if runtime.GOOS == "windows" {
|
||||
url += ".exe"
|
||||
}
|
||||
|
||||
if err := retry.Expo(func() error { return getter.GetFile(tf.Name(), url) }, 3*time.Second, Minutes(3)); err != nil {
|
||||
return tf, err
|
||||
}
|
||||
|
||||
if runtime.GOOS != "windows" {
|
||||
if err := os.Chmod(tf.Name(), 0700); err != nil {
|
||||
return tf, err
|
||||
}
|
||||
}
|
||||
return tf, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
This [example](https://github.com/GoogleContainerTools/skaffold/tree/master/integration/examples/microservices) is the microservices example and was copied from the skaffold repo.
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
FROM golang:1.12.9-alpine3.10 as builder
|
||||
COPY app.go .
|
||||
RUN go build -o /app .
|
||||
|
||||
FROM alpine:3.10
|
||||
# Define GOTRACEBACK to mark this container as using the Go language runtime
|
||||
# for `skaffold debug` (https://skaffold.dev/docs/workflows/debug/).
|
||||
ENV GOTRACEBACK=single
|
||||
CMD ["./app"]
|
||||
COPY --from=builder /app .
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "leeroooooy app!!\n")
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.Print("leeroy app server ready")
|
||||
http.HandleFunc("/", handler)
|
||||
http.ListenAndServe(":50051", nil)
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: leeroy-app
|
||||
labels:
|
||||
app: leeroy-app
|
||||
spec:
|
||||
clusterIP: None
|
||||
ports:
|
||||
- port: 50051
|
||||
name: leeroy-app
|
||||
selector:
|
||||
app: leeroy-app
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: leeroy-app
|
||||
labels:
|
||||
app: leeroy-app
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: leeroy-app
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: leeroy-app
|
||||
spec:
|
||||
containers:
|
||||
- name: leeroy-app
|
||||
image: leeroy-app
|
||||
ports:
|
||||
- containerPort: 50051
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
FROM golang:1.12.9-alpine3.10 as builder
|
||||
COPY web.go .
|
||||
RUN go build -o /web .
|
||||
|
||||
FROM alpine:3.10
|
||||
# Define GOTRACEBACK to mark this container as using the Go language runtime
|
||||
# for `skaffold debug` (https://skaffold.dev/docs/workflows/debug/).
|
||||
ENV GOTRACEBACK=single
|
||||
CMD ["./web"]
|
||||
COPY --from=builder /web .
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: leeroy-web
|
||||
labels:
|
||||
app: leeroy-web
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: leeroy-web
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: leeroy-web
|
||||
spec:
|
||||
containers:
|
||||
- name: leeroy-web
|
||||
image: leeroy-web
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"log"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
resp, err := http.Get("http://leeroy-app:50051")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if _, err := io.Copy(w, resp.Body); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.Print("leeroy web server ready")
|
||||
http.HandleFunc("/", handler)
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
apiVersion: skaffold/v2beta5
|
||||
kind: Config
|
||||
build:
|
||||
artifacts:
|
||||
- image: leeroy-web
|
||||
context: leeroy-web
|
||||
- image: leeroy-app
|
||||
context: leeroy-app
|
||||
deploy:
|
||||
kubectl:
|
||||
manifests:
|
||||
- leeroy-web/kubernetes/*
|
||||
- leeroy-app/kubernetes/*
|
||||
portForward:
|
||||
- resourceType: deployment
|
||||
resourceName: leeroy-web
|
||||
port: 8080
|
||||
localPort: 9000
|
||||
Loading…
Reference in New Issue