11#! /usr/bin/env bash
22
3- set -e
3+ set -euo pipefail
44
55function cleanup {
66 set +e
@@ -9,39 +9,56 @@ function cleanup {
99 echo " Cleaning up machines."
1010 ./test/tools/integration/cleanup_machines.sh
1111
12+ cd test/tools/integration
1213 for try in {1..20}; do
1314 # Clean up master
1415 echo " Cleaning up controller, attempt ${try} "
15- make -C test/tools/integration destroy
16+ # Clean up only the server, we want to keep the key as only one key may exist
17+ # for a given fingerprint
18+ terraform destroy -target=hcloud_server.machine-controller-test -force
1619 if [[ $? == 0 ]]; then break ; fi
1720 echo " Sleeping for $try seconds"
1821 sleep ${try} s
1922 done
2023}
2124trap cleanup EXIT
2225
23- export BUILD_ID=" ${BUILD_ID} "
24-
2526# Install dependencies
2627echo " Installing dependencies."
2728apt update && apt install -y jq rsync unzip &&
28- curl --retry 5 -LO https://storage.googleapis.com/kubernetes-release/release/v1.10.0/bin/linux/amd64/kubectl &&
29+ curl --retry 5 -LO \
30+ https://storage.googleapis.com/kubernetes-release/release/v1.12.4/bin/linux/amd64/kubectl &&
2931chmod +x kubectl &&
3032mv kubectl /usr/local/bin
3133
3234# Generate ssh keypair
33- echo " Generating ssh keypairs."
34- ssh-keygen -f $HOME /.ssh/id_rsa -P ' '
35+ echo " Set permissions for ssh key"
36+ chmod 0700 $HOME /.ssh
37+
38+ # Initialize terraform
39+ echo " Initalizing terraform"
40+ cd test/tools/integration
41+ make terraform
42+ cp provider.tf{.disabled,}
43+ terraform init --input=false --backend-config=key=$BUILD_ID
44+ export TF_VAR_hcloud_token=" ${HZ_E2E_TOKEN} "
45+ export TF_VAR_hcloud_sshkey_content=" $( cat ~ /.ssh/id_rsa.pub) "
46+ export TF_VAR_hcloud_test_server_name=" machine-controller-test-${BUILD_ID} "
3547
3648for try in {1..20}; do
49+ set +e
3750 # Create environment at cloud provider
3851 echo " Creating environment at cloud provider."
39- make -C test/tools/integration apply
52+ terraform import hcloud_ssh_key.default 265119
53+ terraform apply -auto-approve
4054 if [[ $? == 0 ]]; then break ; fi
4155 echo " Sleeping for $try seconds"
4256 sleep ${try} s
4357done
4458
59+ set -e
60+ cd -
61+
4562# Build binaries
4663echo " Building machine-controller and webhook"
4764make machine-controller webhook
0 commit comments