Merge commit '6a1af9ac0e65098e0b4e914ce451f6bd1e659f60' into alessandro/integration-fix

This commit is contained in:
Alessandro Puccetti
2017-02-21 16:55:24 +01:00
57 changed files with 2879 additions and 36 deletions

View File

@@ -130,4 +130,4 @@ end_suite() {
whitely assert_end
}
WEAVE=$DIR/../weave
WEAVE=$DIR/../../integration/weave

View File

@@ -9,7 +9,9 @@ set -e
: "${KEY_FILE:=/tmp/gce_private_key.json}"
: "${SSH_KEY_FILE:=$HOME/.ssh/gce_ssh_key}"
: "${IMAGE:=ubuntu-14-04}"
: "${IMAGE_FAMILY:=ubuntu-1404-lts}"
: "${IMAGE_PROJECT:=ubuntu-os-cloud}"
: "${USER_ACCOUNT:=ubuntu}"
: "${ZONE:=us-central1-a}"
: "${PROJECT:=}"
: "${TEMPLATE_NAME:=}"
@@ -22,7 +24,9 @@ fi
SUFFIX=""
if [ -n "$CIRCLECI" ]; then
SUFFIX="-${CIRCLE_BUILD_NUM}-$CIRCLE_NODE_INDEX"
SUFFIX="-${CIRCLE_PROJECT_USERNAME}-${CIRCLE_PROJECT_REPONAME}-${CIRCLE_BUILD_NUM}-$CIRCLE_NODE_INDEX"
else
SUFFIX="-${USER}"
fi
# Setup authentication
@@ -41,7 +45,8 @@ function vm_names() {
function destroy() {
local names
names="$(vm_names)"
if [ "$(gcloud compute instances list --zone "$ZONE" -q "$names" | wc -l)" -le 1 ]; then
# shellcheck disable=SC2086
if [ "$(gcloud compute instances list --zones "$ZONE" -q $names | wc -l)" -le 1 ]; then
return 0
fi
for i in {0..10}; do
@@ -82,12 +87,16 @@ function try_connect() {
function install_docker_on() {
name=$1
echo "Installing Docker on $name for user ${USER_ACCOUNT}"
# shellcheck disable=SC2087
ssh -t "$name" sudo bash -x -s <<EOF
set -x
set -e
curl -sSL https://get.docker.com/gpg | sudo apt-key add -
curl -sSL https://get.docker.com/ | sh
apt-get update -qq;
apt-get install -q -y --force-yes --no-install-recommends ethtool;
usermod -a -G docker vagrant;
usermod -a -G docker "${USER_ACCOUNT}";
echo 'DOCKER_OPTS="-H unix:///var/run/docker.sock -H unix:///var/run/alt-docker.sock -H tcp://0.0.0.0:2375 -s overlay"' >> /etc/default/docker;
service docker restart
EOF
@@ -136,7 +145,7 @@ function setup() {
}
function make_template() {
gcloud compute instances create "$TEMPLATE_NAME" --image "$IMAGE" --zone "$ZONE"
gcloud compute instances create "$TEMPLATE_NAME" --image-family "$IMAGE_FAMILY" --image-project "$IMAGE_PROJECT" --zone "$ZONE"
gcloud compute config-ssh --ssh-key-file "$SSH_KEY_FILE"
name="$TEMPLATE_NAME.$ZONE.$PROJECT"
try_connect "$name"
@@ -155,7 +164,7 @@ function hosts() {
hosts=($hostname "${hosts[@]}")
args=("--add-host=$hostname:$(internal_ip "$json" "$name")" "${args[@]}")
done
echo export SSH=\"ssh -l vagrant\"
echo export SSH=\"ssh -l "${USER_ACCOUNT}"\"
echo "export HOSTS=\"${hosts[*]}\""
echo "export ADD_HOST_ARGS=\"${args[*]}\""
rm "$json"
@@ -178,6 +187,9 @@ case "$1" in
# see if template exists
if ! gcloud compute images list | grep "$PROJECT" | grep "$TEMPLATE_NAME"; then
make_template
else
echo "Reusing existing template:"
gcloud compute images describe "$TEMPLATE_NAME" | grep "^creationTimestamp"
fi
;;
esac

View File

@@ -1,6 +1,6 @@
#! /bin/bash
# shellcheck disable=SC1091
. ./config.sh
# shellcheck disable=SC1090,SC1091
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config.sh"
set -e