From 5967d5de206321e896af82713eeb93bd6e1c98f4 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sat, 31 Jan 2015 16:55:45 +0000 Subject: [PATCH] make it easier to set up more than 2 VMs for testing --- test/Vagrantfile | 17 +++++++++-------- test/config.sh | 17 +++++++++++++++-- test/setup.sh | 2 +- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/test/Vagrantfile b/test/Vagrantfile index 0bdfa750..a8ac645c 100644 --- a/test/Vagrantfile +++ b/test/Vagrantfile @@ -1,7 +1,9 @@ VAGRANTFILE_API_VERSION = "2" -host1_ip = "192.168.48.19" # arbitrary private IP -host2_ip = "192.168.48.15" # arbitrary private IP +# these ought to match what is in config.sh +n_machines = 2 +ip_prefix = "192.168.48" +ip_suffix_base = 10 def configure_docker(host, ip) pkgs = "lxc-docker" @@ -30,12 +32,11 @@ end Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - config.vm.define "host1" do |host1| - configure_docker(host1, host1_ip) - end - - config.vm.define "host2" do |host2| - configure_docker(host2, host2_ip) + (1..n_machines).each do |i| + config.vm.define "host#{i}" do |host| + ip_suffix = ip_suffix_base + i + configure_docker(host, "#{ip_prefix}.#{ip_suffix}") + end end end diff --git a/test/config.sh b/test/config.sh index df0b2780..7acba9ec 100644 --- a/test/config.sh +++ b/test/config.sh @@ -2,11 +2,24 @@ set -e +# these ought to match what is in Vagrantfile +N_MACHINES=${N_MACHINES:-2} +IP_PREFIX=${IP_PREFIX:-192.168.48} +IP_SUFFIX_BASE=${IP_SUFFIX_BASE:-10} + +HOSTS= +for i in $(seq 1 $N_MACHINES); do + IP="${IP_PREFIX}.$((${IP_SUFFIX_BASE}+$i))" + HOSTS="$HOSTS $IP" +done + +# these are used by the tests +HOST1="${IP_PREFIX}.$((${IP_SUFFIX_BASE}+1))" +HOST2="${IP_PREFIX}.$((${IP_SUFFIX_BASE}+2))" + . ./assert.sh SSH=${SSH:-ssh -l vagrant -i ./insecure_private_key -o UserKnownHostsFile=./.ssh_known_hosts -o CheckHostIP=no -o StrictHostKeyChecking=no} -HOST1=${HOST1:-192.168.48.19} -HOST2=${HOST2:-192.168.48.15} remote() { rem=$1 diff --git a/test/setup.sh b/test/setup.sh index ee66c2bb..33276793 100755 --- a/test/setup.sh +++ b/test/setup.sh @@ -8,7 +8,7 @@ curl -sS https://raw.githubusercontent.com/lehmannro/assert.sh/master/assert.sh . ./config.sh echo Copying weave images and script to hosts -for HOST in $HOST1 $HOST2; do +for HOST in $HOSTS; do docker_on $HOST load -i /var/tmp/weave.tar docker_on $HOST load -i /var/tmp/weavedns.tar docker_on $HOST load -i /var/tmp/weavetools.tar