From fd34dda6c1fde3f0bd5fdb84211f9811c415ef3a Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 24 Nov 2016 16:36:53 +0000 Subject: [PATCH] Run test instances on a locked-down network and open up a rule from the specific IP running the tests --- test/gce.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/gce.sh b/test/gce.sh index f2721d42..4d40c5a3 100755 --- a/test/gce.sh +++ b/test/gce.sh @@ -34,6 +34,9 @@ function vm_names { # Delete all vms in this account function destroy { + if [ $(gcloud compute firewall-rules list test-allow-docker$SUFFIX 2>/dev/null | wc -l) -gt 0 ] ; then + gcloud compute firewall-rules delete test-allow-docker$SUFFIX + fi names="$(vm_names)" if [ $(gcloud compute instances list --zones $ZONE -q $names | wc -l) -le 1 ] ; then return 0 @@ -124,7 +127,9 @@ function setup { destroy names="$(vm_names)" - gcloud compute instances create $names --image $TEMPLATE_NAME --zone $ZONE + gcloud compute instances create $names --image $TEMPLATE_NAME --zone $ZONE --tags test$SUFFIX --network=test + my_ip="$(curl -s http://ipinfo.io/ip)" + gcloud compute firewall-rules create test-allow-docker$SUFFIX --network=test --allow tcp:2375,tcp:12375 --target-tags test$SUFFIX --source-ranges $my_ip gcloud compute config-ssh --ssh-key-file $SSH_KEY_FILE sed -i '/UserKnownHostsFile=\/dev\/null/d' ~/.ssh/config