Skip to content
Snippets Groups Projects
Commit e75d86ff authored by František Dvořák's avatar František Dvořák
Browse files

gitLab CI: cache the latest floating IP to improve robustness

parent b22e7745
Branches master
No related tags found
No related merge requests found
...@@ -44,12 +44,14 @@ test-single: ...@@ -44,12 +44,14 @@ test-single:
- touch ./secure.yml - touch ./secure.yml
# better to init terraform before allocating public floating IP address (the state could be locked) # better to init terraform before allocating public floating IP address (the state could be locked)
- terraform init -input=false - terraform init -input=false
- ip=`openstack floating ip create -c floating_ip_address -f value public-muni-147-251-21-GROUP` - if test -f ip.txt; then ip=$(cat ip.txt); openstack floating ip show "$ip" >/dev/null || ip=''; fi
- if test -z "$ip"; then ip=$(openstack floating ip create -c floating_ip_address -f value public-muni-147-251-21-GROUP); echo "$ip" > ip.txt; fi
cache: cache:
when: always when: always
key: single key: single
paths: paths:
- ".terraform/" - ".terraform/"
- "ip.txt"
script: script:
- args="-auto-approve -var type=hadoop-single -var flavor=standard.large -var n=0 -var domain=terra1 -var image_name=$IMAGE_NAME -var image_visibility=$IMAGE_VISIBILITY -var floating_ip=$ip" - args="-auto-approve -var type=hadoop-single -var flavor=standard.large -var n=0 -var domain=terra1 -var image_name=$IMAGE_NAME -var image_visibility=$IMAGE_VISIBILITY -var floating_ip=$ip"
- terraform apply $args - terraform apply $args
...@@ -58,6 +60,7 @@ test-single: ...@@ -58,6 +60,7 @@ test-single:
- ssh -o PreferredAuthentications=publickey deployadm@$ip "sudo -u debian sh -c 'cd; ~deployadm/terraform/image/tests/run-tests.sh'" - ssh -o PreferredAuthentications=publickey deployadm@$ip "sudo -u debian sh -c 'cd; ~deployadm/terraform/image/tests/run-tests.sh'"
- terraform destroy $args - terraform destroy $args
- openstack floating ip delete $ip - openstack floating ip delete $ip
- rm -fv ip.txt
rules: rules:
- if: '$JOB =~ /all|test-single/' - if: '$JOB =~ /all|test-single/'
artifacts: &artifacts artifacts: &artifacts
...@@ -73,6 +76,7 @@ test-cluster: ...@@ -73,6 +76,7 @@ test-cluster:
key: cluster key: cluster
paths: paths:
- ".terraform/" - ".terraform/"
- "ip.txt"
script: script:
- args="-auto-approve -var type=hadoop -var domain=terra2 -var image_name=$IMAGE_NAME -var image_visibility=$IMAGE_VISIBILITY -var floating_ip=$ip" - args="-auto-approve -var type=hadoop -var domain=terra2 -var image_name=$IMAGE_NAME -var image_visibility=$IMAGE_VISIBILITY -var floating_ip=$ip"
- terraform apply $args - terraform apply $args
...@@ -81,6 +85,7 @@ test-cluster: ...@@ -81,6 +85,7 @@ test-cluster:
- ssh -o PreferredAuthentications=publickey deployadm@$ip "sudo -u debian sh -c 'cd; ~deployadm/terraform/image/tests/run-tests.sh'" - ssh -o PreferredAuthentications=publickey deployadm@$ip "sudo -u debian sh -c 'cd; ~deployadm/terraform/image/tests/run-tests.sh'"
- terraform destroy $args - terraform destroy $args
- openstack floating ip delete $ip - openstack floating ip delete $ip
- rm -fv ip.txt
rules: rules:
- if: '$JOB =~ /all|test-cluster/' - if: '$JOB =~ /all|test-cluster/'
artifacts: *artifacts artifacts: *artifacts
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment