From 26b6b743f5c26f99e279f535f466e935b98fe135 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Thu, 7 May 2015 10:57:12 +0000 Subject: [PATCH] Use a template with everything installed for GCE tests. --- test/gce.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/gce.sh b/test/gce.sh index 58f903fc..aad13d95 100755 --- a/test/gce.sh +++ b/test/gce.sh @@ -10,6 +10,7 @@ KEY_FILE=/tmp/gce_private_key.json SSH_KEY_FILE=$HOME/.ssh/gce_ssh_key PROJECT=positive-cocoa-90213 IMAGE=ubuntu-14-04 +TEMPLATE_NAME="test-template" ZONE=us-central1-a NUM_HOSTS=2 @@ -57,14 +58,12 @@ function setup { names="host$i $names" done - gcloud compute instances create $names --image $IMAGE --zone $ZONE + gcloud compute instances create $names --image $TEMPLATE_NAME --zone $ZONE gcloud compute config-ssh --ssh-key-file $SSH_KEY_FILE hosts= for i in $(seq 1 $NUM_HOSTS); do name="host$i.$ZONE.$PROJECT" - install_docker_on $name - # Add the remote ip to the local /etc/hosts sudo -- sh -c "echo \"$(external_ip host$i) $name\" >>/etc/hosts" # Add the local ips to the remote /etc/hosts @@ -77,6 +76,15 @@ function setup { done } +function make_template { + gcloud compute instances create template --image $IMAGE --zone $ZONE + gcloud compute config-ssh --ssh-key-file $SSH_KEY_FILE + name="template.$ZONE.$PROJECT" + install_docker_on $name + gcloud compute instances delete template --keep-disks boot -zone $ZONE + gcloud compute images create $TEMPLATE_NAME --source-disk example-disk --source-disk-zone $ZONE +} + function hosts { hosts= args= @@ -102,4 +110,7 @@ hosts) destroy) destroy ;; + +make_template) + make_template esac