Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tests) switch from minikube to kind (#107)
Browse files Browse the repository at this point in the history
* fix(kind) switch from minikube to kind

* fix(ci) kind / helm compatibility fix

* fix(ci) adjust installation order

* fix(ci) install helm

* fix(ci) define clone location

* fix(ci) cleanup travis.yml file

* fix(ci) background the ci test setup steps

* fix(ci) wait until the k8s cluster is ready
hutchic authored Jul 23, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 148c8b6 commit 7eb014c
Showing 4 changed files with 29 additions and 63 deletions.
18 changes: 18 additions & 0 deletions .ci/setup_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

GO111MODULE=on go get sigs.k8s.io/kind
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
mv kubectl $HOME/bin/
curl -Lo get_helm.sh https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get
chmod +x get_helm.sh
kind create cluster
sudo ./get_helm.sh
rm -rf get_helm.sh
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller --upgrade
kubectl get nodes -o wide
kubectl get pods --all-namespaces -o wide
kubectl get services --all-namespaces -o wide
38 changes: 10 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
dist: xenial
language: python
python:
- "3.6"
sudo: required
language: go
go:
- "1.12"

env:
global:
- CHANGE_MINIKUBE_NONE_USER=true
- MINIKUBE_WANTUPDATENOTIFICATION=false
- MINIKUBE_WANTREPORTERRORPROMPT=false
- MINIKUBE_HOME=$HOME
- KONG_SOURCE_LOCATION=$PWD/kong
- HELM_VERSION=v2.11.0
- MINIKUBE_VERSION=v0.33.1
- EDITION=community
- KONG_PACKAGE_NAME=kong
- KONG_CONFLICTS=kong-enterprise
@@ -53,28 +48,15 @@ matrix:
- env: PACKAGE_TYPE=deb RESTY_IMAGE_BASE=ubuntu RESTY_IMAGE_TAG=bionic KONG_SOURCE=master POSTGRES_VERSION=11
- end: PACKAGE_TYPE=rpm RESTY_IMAGE_BASE=amazonlinux RESTY_IMAGE_TAG=latest KONG_SOURCE=master

before_install:
- make setup_tests >make.log 2>&1 &
- docker pull kong/kong-build-tools:fpm || true
- docker pull kong/kong-build-tools:test_runner || true
- docker pull kong/kong-build-tools:test-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} || true
- docker pull kong/kong-build-tools:${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} || true
- docker pull kong/kong-build-tools:kong-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} || true
- git clone --single-branch --branch ${KONG_SOURCE} https://github.com/Kong/kong.git kong

install:
- make build-base
- make package-kong

before_script:
- sudo chown -R $USER $HOME/.minikube
- sudo chgrp -R $USER $HOME/.minikube
- sudo chown -R $USER $HOME/.kube
- sudo chgrp -R $USER $HOME/.kube
- cat make.log
- until kubectl get nodes 2>&1 | sed -n 2p | grep -q Ready; do sleep 5 && kubectl get nodes; done
- ./.ci/setup_ci.sh >setup.log 2>&1 &
- git clone --single-branch --branch ${KONG_SOURCE} https://github.com/Kong/kong.git ${KONG_SOURCE_LOCATION}
- make package-kong

script:
- cat setup.log
- export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
- until kubectl get nodes | grep -q Ready; do sleep 5 && kubectl get nodes; done
- make test

after_success:
27 changes: 0 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -201,30 +201,3 @@ build_test_container:
KONG_TEST_CONTAINER_NAME=$(KONG_TEST_CONTAINER_NAME) \
test/build_container.sh

cleanup_tests:
-sudo minikube delete

setup_tests: cleanup_tests
ifeq (, $(shell which minikube))
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.33.1/minikube-linux-amd64
sudo cp minikube /usr/local/bin/
sudo chmod 755 /usr/local/bin/minikube
rm minikube
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.12.8/bin/linux/amd64/kubectl
sudo cp kubectl /usr/local/bin/
sudo chmod 755 /usr/local/bin/kubectl
rm kubectl
curl -Lo get_helm.sh https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get
chmod +x get_helm.sh
sudo ./get_helm.sh
rm -rf get_helm.sh
sudo apt-get update && sudo apt-get install -y socat
endif
sudo minikube start --vm-driver none --kubernetes-version=v1.13.2
sudo minikube addons enable registry
sudo chown -R $$USER $$HOME/.minikube
sudo chgrp -R $$USER $$HOME/.minikube
sudo chown -R $$USER $$HOME/.kube
sudo chgrp -R $$USER $$HOME/.kube
sudo minikube update-context
until kubectl get nodes 2>&1 | sed -n 2p | grep -q Ready; do sleep 1 && kubectl get nodes; done
9 changes: 1 addition & 8 deletions test/run_tests.sh
Original file line number Diff line number Diff line change
@@ -8,14 +8,7 @@ fi

docker run -it --rm ${KONG_TEST_CONTAINER_NAME} /bin/sh -c "luarocks --version"

kubectl create -f kube-registry.yaml

while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:5000)" != 200 ]]; do
echo "waiting for registry to be ready"
sleep 10;
done

for i in {1..5}; do docker push ${KONG_TEST_CONTAINER_NAME} && break || sleep 15; done
kind load docker-image ${KONG_TEST_CONTAINER_NAME}

helm init --wait
helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/

0 comments on commit 7eb014c

Please sign in to comment.