Skip to content
This repository was archived by the owner on Apr 27, 2020. It is now read-only.

Commit 3e12333

Browse files
Use kind for integration test (#59)
* Use kind for integration test instead of minikube * Change cluster version depending on kubectl version
1 parent f3682b6 commit 3e12333

File tree

4 files changed

+40
-44
lines changed

4 files changed

+40
-44
lines changed

.travis.yml

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
1-
sudo: required
1+
language: go
22

3-
language: bash
4-
5-
services:
6-
- docker
7-
8-
sudo: required
3+
go:
4+
- "1.11.x"
95

106
env:
11-
global:
12-
- TMPDIR=/tmp
13-
- CHANGE_MINIKUBE_NONE_USER=true
14-
- MINIKUBE_VERSION=v0.28.0
15-
- MINIKUBE_ARGS="--vm-driver=none --bootstrapper=localkube --extra-config=apiserver.Authorization.Mode=RBAC"
167
matrix:
17-
- KUBE_VERSION=v1.10.0
18-
- KUBE_VERSION=v1.11.0
8+
- KUBECTL_VERSION=v1.13.0 NODE_VERSION=v1.12.3 # v1.13.x hasn't been released yet
9+
- KUBECTL_VERSION=v1.12.0 NODE_VERSION=v1.12.3
10+
- KUBECTL_VERSION=v1.11.0 NODE_VERSION=v1.11.3
1911

20-
matrix:
21-
allow_failures:
22-
- env: KUBE_VERSION=v1.11.0
12+
services:
13+
- docker
2314

2415
before_script:
25-
# Download kubectl, which is a requirement for using minikube.
26-
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
27-
# Download minikube.
28-
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
29-
- sudo minikube start --kubernetes-version=${KUBE_VERSION} ${MINIKUBE_ARGS}
30-
# Fix the kubectl context, as it's often stale.
31-
- sudo minikube update-context
32-
# Prevent Permission denied
33-
- sudo chown -R ${USER} ${HOME}/.kube ${HOME}/.minikube
34-
# Wait for Kubernetes to be up and ready.
35-
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done
16+
# Download and install kubectl
17+
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
18+
# Build and install kind
19+
- go get sigs.k8s.io/kind
20+
# Create a new kubernetes cluster
21+
- kind create cluster --image="kindest/node:${NODE_VERSION}"
22+
# Set KUBECONFIG environment variable
23+
- export KUBECONFIG="$(kind get kubeconfig-path)"
24+
# Show version
25+
- kubectl version
3626

3727
script:
38-
- ./scripts/verify-authors.sh
39-
- make lint
4028
- make test
41-
- make image
29+
30+
matrix:
31+
include:
32+
- &bash
33+
language: bash
34+
go: null
35+
env: null
36+
before_script: null
37+
script:
38+
- ./scripts/verify-authors.sh
39+
- <<: *bash
40+
script:
41+
- make lint
42+
- <<: *bash
43+
script:
44+
- make image

assets/out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ set -o pipefail
1212
exec 3>&1 # make stdout available as fd 3 for the result
1313
exec 1>&2 # redirect all output to stderr for logging
1414

15+
# Set TMPDIR environment variable to /tmp if it does not defined
16+
export TMPDIR="${TMPDIR:-/tmp}"
17+
1518
# shellcheck source=assets/common.sh
1619
source "$(dirname "$0")/common.sh"
1720

scripts/run-bats.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,7 @@
22

33
set -e
44

5-
context="$(kubectl config current-context)"
6-
7-
# Change the current-context to minikube
8-
kubectl config use-context minikube
9-
105
for bats_file in $(find test -name "*.bats"); do
116
echo "=> $bats_file"
127
bats "$bats_file"
138
done
14-
15-
if [[ "$context" != "minikube" ]]; then
16-
echo "Restore the current-context to $context"
17-
kubectl config use-context "$context"
18-
fi

test/suite.bats

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ teardown() {
4444
run assets/out <<< "$(jq -n '{"source": {"kubeconfig": $kubeconfig}, "params": {"kubectl": $kubectl}}' \
4545
--arg kubeconfig "$(cat "$kubeconfig_file")" \
4646
--arg kubectl "run nginx --image nginx")"
47-
assert_match 'deployment.apps "nginx" created' "$output"
47+
assert_match 'deployment.apps/nginx created' "$output"
4848
assert_success
4949
}
5050

@@ -93,7 +93,7 @@ teardown() {
9393
run assets/out <<< "$(jq -n '{"source": {"kubeconfig": $kubeconfig}, "params": {"kubectl": $kubectl}}' \
9494
--arg kubeconfig "$(cat "$kubeconfig_file")" \
9595
--arg kubectl "patch deploy nginx -p '{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"updated_at\":\"'\$(date +%s)'\"}}}}}'")"
96-
assert_match 'deployment.extensions "nginx" patched' "$output"
96+
assert_match 'deployment.extensions/nginx patched' "$output"
9797
assert_success
9898

9999
run kubectl --kubeconfig "$kubeconfig_file" get deploy nginx -o go-template --template "{{.spec.template.metadata.labels.updated_at}}"
@@ -106,6 +106,6 @@ teardown() {
106106
run assets/out <<< "$(jq -n '{"source": {"kubeconfig": $kubeconfig}, "params": {"kubectl": $kubectl}}' \
107107
--arg kubeconfig "$(cat "$kubeconfig_file")" \
108108
--arg kubectl "run nginx --image nginx --requests='cpu=1000'")"
109-
assert_match 'deployment.apps "nginx" created' "$output"
109+
assert_match 'deployment.apps/nginx created' "$output"
110110
assert_failure
111111
}

0 commit comments

Comments
 (0)