From 9560a139105abb2ef4bf448849209ac2aacf6f18 Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Sun, 18 Nov 2018 10:39:29 +0100 Subject: [PATCH] define datacenter to used for E2E tests based on datacenter availability Signed-off-by: Marco Vito Moscaritolo --- .travis.yml | 2 +- Makefile | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c9b2b19f..827c6f7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ jobs: - stage: E2E testing script: - go build - - make preparare + - export DATACENTER=$(make detect-datacenter) - make test-all - make cleanup go: 1.11.x diff --git a/Makefile b/Makefile index 047e8b05..4a2df3c0 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ HETZNER_KUBE=${TRAVIS_BUILD_DIR}/hetzner-kube SSH_KEY_FOLDER=${TRAVIS_BUILD_DIR}/tests/keys -DATACENTER=fsn1-dc8 SSH_KEY_NAME=testing-ssh-key-${TRAVIS_JOB_NUMBER} CONTEXT_NAME=testing-context-${TRAVIS_JOB_NUMBER} @@ -9,6 +8,9 @@ CLUSTER_NAME=testing-cluster-${TRAVIS_JOB_NUMBER} VERSION=${TRAVIS_TAG} +detect-datacenter: + @curl -s --request GET --url https://api.hetzner.cloud/v1/datacenters --header "Authorization: Bearer ${HETZNER_API_KEY}" | jq -M '.recommendation as $$reco | .datacenters[] | select(.id == $$reco) | .name' | tr -d '"' + build-cleanup: @rm -rf dist/* @@ -26,11 +28,11 @@ build: build-cleanup build-prepare CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-X cmd.version=${VERSION}" -o dist/hetzner-kube-${VERSION}-windows-amd64.exe CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-X cmd.version=${VERSION}" -o dist/hetzner-kube-${VERSION}-windows-386.exe -preparare: +test-preparare: mkdir -p ${SSH_KEY_FOLDER} ssh-keygen -t rsa -b 4096 -P "" -f ${SSH_KEY_FOLDER}/id_rsa -test-all: test-info test-context test-ssh-key test-clusters +test-all: test-preparare test-info test-context test-ssh-key test-clusters test-info: ${HETZNER_KUBE} help