Skip to content

Commit

Permalink
Merge a66b1e0 into 18ea2f7
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Sep 11, 2017
2 parents 18ea2f7 + a66b1e0 commit 3b2f239
Show file tree
Hide file tree
Showing 23 changed files with 801 additions and 161 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ Session.vim
# coverage artifacts
.coverprofile
/gover.coverprofile

# skip go tests
*/**/*.test

# skip e2e binaries
minikube
kubectl
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ notifications:
email: true

go:
- 1.8.3
- 1.9

go_import_path: k8s.io/ingress

Expand All @@ -18,6 +18,7 @@ env:
# to add additional secure variables:
# docker run --rm caktux/travis-cli encrypt key=value -r kubernetes/ingress
- RELEASE="ci-${TRAVIS_BUILD_ID}"
- DOCKER=docker

before_script:
- export PATH=$PATH:$PWD/hack/e2e-internal/
Expand All @@ -34,4 +35,6 @@ jobs:
- go get github.com/modocache/gover
- if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
- make cover
#- make test-e2e
- stage: e2e
script:
- make test-e2e
19 changes: 3 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ all: fmt lint vet

BUILDTAGS=

# building inside travis generates a custom version of the
# backends in order to run e2e tests agains the build.
ifdef TRAVIS_BUILD_ID
RELEASE := ci-build-${TRAVIS_BUILD_ID}
endif

# 0.0 shouldn't clobber any release builds
RELEASE?=0.0

# by default build a linux version
GOOS?=linux

Expand All @@ -23,7 +14,7 @@ endif
# base package. It contains the common and backends code
PKG := "k8s.io/ingress"

GO_LIST_FILES=$(shell go list ${PKG}/... | grep -v vendor | grep -v -e "test/e2e")
GO_LIST_FILES=$(shell go list ${PKG}/... | grep -v vendor | grep -v -e "e2e")

.PHONY: fmt
fmt:
Expand All @@ -38,8 +29,8 @@ test:
@go test -v -race -tags "$(BUILDTAGS) cgo" ${GO_LIST_FILES}

.PHONY: test-e2e
test-e2e: ginkgo
@go run hack/e2e.go -v --up --test --down
test-e2e:
make -C controllers/nginx test-e2e

.PHONY: cover
cover:
Expand Down Expand Up @@ -70,7 +61,3 @@ docker-push:
.PHONE: release
release:
make -C controllers/nginx release

.PHONY: ginkgo
ginkgo:
go get github.com/onsi/ginkgo/ginkgo
9 changes: 7 additions & 2 deletions controllers/nginx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ DOCKER?=gcloud docker --
SED_I?=sed -i
GOHOSTOS ?= $(shell go env GOHOSTOS)

SKIP_TESTS?=

ifeq ($(GOHOSTOS),darwin)
SED_I=sed -i ''
endif
Expand Down Expand Up @@ -120,11 +122,14 @@ lint:

test: fmt lint vet
@echo "+ $@"
@go test -v -race -tags "$(BUILDTAGS) cgo" $(shell go list ${PKG}/... | grep -v vendor)
@go test -v -race -tags "$(BUILDTAGS) cgo" $(shell go list ${PKG}/... | grep -v vendor |grep -v e2e)

test-e2e: sub-container-amd64
@TAG=${TAG} IMAGE=$(MULTI_ARCH_IMG) go run e2e/e2e.go --files=e2e/nginx-ingress-controller.yaml,e2e/default-backend.yaml --verbose --up --test --down

cover:
@echo "+ $@"
@go list -f '{{if len .TestGoFiles}}"go test -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"{{end}}' $(shell go list ${PKG}/... | grep -v vendor) | xargs -L 1 sh -c
@go list -f '{{if len .TestGoFiles}}"go test -skipTest "${SKIP_TESTS}" -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"{{end}}' $(shell go list ${PKG}/... | grep -v vendor) | xargs -L 1 sh -c
gover
goveralls -coverprofile=gover.coverprofile -service travis-ci -repotoken ${COVERALLS_TOKEN}

Expand Down
51 changes: 51 additions & 0 deletions controllers/nginx/e2e/default-backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: default-http-backend
labels:
k8s-app: default-http-backend
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: default-http-backend
spec:
terminationGracePeriodSeconds: 60
containers:
- name: default-http-backend
# Any image is permissable as long as:
# 1. It serves a 404 page at /
# 2. It serves 200 on a /healthz endpoint
image: gcr.io/google_containers/defaultbackend:1.0
livenessProbe:
httpGet:
path: /healthz
port: 8080
scheme: HTTP
initialDelaySeconds: 30
timeoutSeconds: 5
ports:
- containerPort: 8080
resources:
limits:
cpu: 10m
memory: 20Mi
requests:
cpu: 10m
memory: 20Mi
---
apiVersion: v1
kind: Service
metadata:
name: default-http-backend
namespace: kube-system
labels:
k8s-app: default-http-backend
spec:
ports:
- port: 80
targetPort: 8080
selector:
k8s-app: default-http-backend
6 changes: 6 additions & 0 deletions controllers/nginx/e2e/e2e-internal/e2e-down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

. ./e2e/e2e-internal/e2e-env.sh

echo "Destroying running e2e cluster..."
${MINIKUBE} --profile ${MINIKUBE_PROFILE} delete || echo "Cluster already destroyed"
33 changes: 33 additions & 0 deletions controllers/nginx/e2e/e2e-internal/e2e-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

export MINIKUBE_VERSION=0.22.0
export K8S_VERSION=v1.7.5

export PWD=`pwd`
export BASEDIR="$(dirname ${BASH_SOURCE})"
export KUBECTL="${BASEDIR}/kubectl"
export MINIKUBE="${BASEDIR}/minikube"
export GOOS="${GOOS:-linux}"

export MINIKUBE_WANTUPDATENOTIFICATION=false
export MINIKUBE_WANTREPORTERRORPROMPT=false
export MINIKUBE_HOME=$HOME
export CHANGE_MINIKUBE_NONE_USER=true

export KUBECONFIG=$HOME/.kube/config

export MINIKUBE_PROFILE="ingress-e2e"

export PATH=$PATH:$BASEDIR

if [ ! -e ${KUBECTL} ]; then
echo "kubectl binary is missing. downloading..."
curl -sSL http://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/${GOOS}/amd64/kubectl -o ${KUBECTL}
chmod u+x ${KUBECTL}
fi

if [ ! -e ${MINIKUBE} ]; then
echo "minikube binary is missing. downloading..."
curl -sSLo ${MINIKUBE} https://storage.googleapis.com/minikube/releases/v${MINIKUBE_VERSION}/minikube-linux-amd64
chmod +x ${MINIKUBE}
fi
7 changes: 7 additions & 0 deletions controllers/nginx/e2e/e2e-internal/e2e-status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -eof pipefail

. ./e2e/e2e-internal/e2e-env.sh

${MINIKUBE} --profile ${MINIKUBE_PROFILE} status
28 changes: 28 additions & 0 deletions controllers/nginx/e2e/e2e-internal/e2e-up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

set -eof pipefail

. ./e2e/e2e-internal/e2e-env.sh

mkdir -p $HOME/.kube
touch $KUBECONFIG

if [ "$TRAVIS" = true ] ; then
sudo -E ${MINIKUBE} --profile ${MINIKUBE_PROFILE} start --vm-driver=none
else
${MINIKUBE} --profile ${MINIKUBE_PROFILE} start
fi

# this for loop waits until kubectl can access the api server that minikube has created
for i in {1..150} # timeout for 5 minutes
do
$KUBECTL get po &> /dev/null
if [ $? -ne 1 ]; then
break
fi
sleep 10
done

sleep 60

echo "Kubernetes started"
17 changes: 17 additions & 0 deletions controllers/nginx/e2e/e2e-internal/run-e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -eof pipefail

. ./e2e/e2e-internal/e2e-env.sh

PATH=$PATH:$(pwd)

echo "Creating test tag for image $IMAGE:$TAG"
docker tag $IMAGE:$TAG $IMAGE:test

echo "Uploading test image to minikube"
dockerenv=$(${MINIKUBE} --profile ${MINIKUBE_PROFILE} docker-env | sed 's/export//g' | sed 's/^#.*$//g' | sed 's/"//g')
docker save $IMAGE:test | env -i $dockerenv docker load

echo "Running tests..."
go test -v k8s.io/ingress/controllers/nginx/e2e/... -run ^TestIngressSuite$ --args --alsologtostderr --v=10
Loading

0 comments on commit 3b2f239

Please sign in to comment.