Merge pull request #1235 from weaveworks/gce

Improve CI run time
This commit is contained in:
Paul Bellamy committed 2015-07-29 17:38:30 +01:00
commit 4da999ba86
4 files changed
+45 -17

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ dependencies:
docker save weaveworks/weave-build >$WEAVE_BUILD;
fi
post:
- sudo apt-get install bc
- sudo apt-get install bc jq
- pip install requests
- curl https://sdk.cloud.google.com | bash
- bin/setup-circleci-secrets "$SECRET_PASSWORD"
+2 -2
View File
@@ -314,9 +314,9 @@ func TestAllocatorFuzz(t *testing.T) {
const (
firstpass = 1000
secondpass = 10000
nodes = 10
nodes = 5
maxAddresses = 1000
concurrency = 30
concurrency = 5
cidr = "10.0.1.7/22"
)
allocs, _, subnet := makeNetworkOfAllocators(nodes, cidr)
+33 -13
View File
@@ -50,12 +50,12 @@ function destroy {
done
}
function external_ip {
gcloud compute instances list $1 --format=yaml | grep "^ natIP\:" | cut -d: -f2 | tr -d ' '
function internal_ip {
jq -r ".[] | select(.name == \"$2\") | .networkInterfaces[0].networkIP" $1
}
function internal_ip {
gcloud compute instances list $1 --format=yaml | grep "^ networkIP\:" | cut -d: -f2 | tr -d ' '
function external_ip {
jq -r ".[] | select(.name == \"$2\") | .networkInterfaces[0].accessConfigs[0].natIP" $1
}
function try_connect {
@@ -81,32 +81,49 @@ EOF
ssh -t $name sudo docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter
}
# Create new set of VMS
function copy_hosts {
hostname=$1
hosts=$2
cat $hosts | ssh -t "$hostname" "sudo -- sh -c \"cat >>/etc/hosts\""
}
# Create new set of VMs
function setup {
destroy
names="$(vm_names)"
gcloud compute instances create $names --image $TEMPLATE_NAME --zone $ZONE
gcloud compute config-ssh --ssh-key-file $SSH_KEY_FILE
sed -i '/UserKnownHostsFile=\/dev\/null/d' ~/.ssh/config
# build an /etc/hosts file for these vms
hosts=$(mktemp hosts.XXXXXXXXXX)
json=$(mktemp json.XXXXXXXXXX)
gcloud compute instances list --format=json >$json
for name in $names; do
echo "$(internal_ip $json $name) $name.$ZONE.$PROJECT" >>$hosts
done
for name in $names; do
hostname="$name.$ZONE.$PROJECT"
# Add the remote ip to the local /etc/hosts
sudo -- sh -c "echo \"$(external_ip $name) $hostname\" >>/etc/hosts"
sudo sed -i "/$hostname/d" /etc/hosts
sudo sh -c "echo \"$(external_ip $json $name) $hostname\" >>/etc/hosts"
try_connect $hostname
# Add the local ips to the remote /etc/hosts
for othername in $names; do
entry="$(internal_ip $othername) $othername.$ZONE.$PROJECT"
ssh -t "$hostname" "sudo -- sh -c \"echo \\\"$entry\\\" >>/etc/hosts\""
done
copy_hosts $hostname $hosts &
done
wait
rm $hosts $json
}
function make_template {
gcloud compute instances create $TEMPLATE_NAME --image $IMAGE --zone $ZONE
gcloud compute config-ssh --ssh-key-file $SSH_KEY_FILE
name="$TEMPLATE_NAME.$ZONE.$PROJECT"
try_connect $name
try_connect $name
install_docker_on $name
gcloud -q compute instances delete $TEMPLATE_NAME --keep-disks boot --zone $ZONE
gcloud compute images create $TEMPLATE_NAME --source-disk $TEMPLATE_NAME --source-disk-zone $ZONE
@@ -115,14 +132,17 @@ function make_template {
function hosts {
hosts=
args=
json=$(mktemp json.XXXXXXXXXX)
gcloud compute instances list --format=json >$json
for name in $(vm_names); do
hostname="$name.$ZONE.$PROJECT"
hosts="$hostname $hosts"
args="--add-host=$hostname:$(internal_ip $name) $args"
args="--add-host=$hostname:$(internal_ip $json $name) $args"
done
echo export SSH=ssh
echo export HOSTS=\"$hosts\"
echo export WEAVE_DOCKER_ARGS=\"$args\"
rm $json
}
case "$1" in
+9 -1
View File
@@ -10,7 +10,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
echo "Copying weave images, scripts, and certificates to hosts, and"
echo " prefetch test images"
for HOST in $HOSTS; do
setup_host() {
HOST=$1
docker_on $HOST load -i ../weave.tar
DANGLING_IMAGES="$(docker_on $HOST images -q -f dangling=true)"
[ -n "$DANGLING_IMAGES" ] && docker_on $HOST rmi $DANGLING_IMAGES 1>/dev/null 2>&1 || true
@@ -21,4 +23,10 @@ for HOST in $HOSTS; do
for IMG in $TEST_IMAGES ; do
docker_on $HOST inspect --format=" " $IMG >/dev/null 2>&1 || docker_on $HOST pull $IMG
done
}
for HOST in $HOSTS; do
setup_host $HOST &
done
wait