diff --git a/.ci/setup_ci.sh b/.ci/setup_ci.sh new file mode 100755 index 000000000000..aa896e49318b --- /dev/null +++ b/.ci/setup_ci.sh @@ -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 diff --git a/.travis.yml b/.travis.yml index aef163bcd50a..2ac66c4e88a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/Makefile b/Makefile index 867587c764d4..90c8dfa25e36 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/test/run_tests.sh b/test/run_tests.sh index 6f79999e9dda..cd3aa472cd86 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -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/