Provision and destroy test VMs in the background.

This should help speed-up the build by provisioning test VMs while we run unit tests, and destroying them while we generate coverage reports.
This commit is contained in:
Marc CARRE committed 2017-02-08 14:15:59 +00:00
1 parent 67dbdd377c
commit dd935b7e9e
7 files changed
+141 -48

No files matched your search

+17 -2
View File
@@ -3,7 +3,22 @@
set -e
source "$STATE"
source "$(dirname "$0")/wait_for.sh"
if [ -n "$TEST_AND_PUBLISH" ] ; then
cd $SRCDIR/test
if [ -n "$TEST_AND_PUBLISH" ]; then
[ -n "$SECRET_KEY" ] || {
echo "Cannot run smoke tests: no secret key"
exit 1
}
# Provisioning from image typically take 90 seconds,
# but if we are creating a GCP image, it can take more than 10 minutes:
wait_for 900 "$TEST_VMS_PROV_AND_CONF_LOCK_FILE"
# Upload built binaries to testing VMs:
rm -f "$TEST_VMS_READY_LOCK_FILE"
cd "$SRCDIR/test" # Ensures we generate Terraform state files in the right folder, for later use by integration tests.
./run-integration-tests.sh setup >>"$TEST_VMS_SETUP_OUTPUT_FILE" 2>&1
touch "$TEST_VMS_READY_LOCK_FILE"
echo "Test VMs now ready. $(date)." >>"$TEST_VMS_SETUP_OUTPUT_FILE"
fi
+7 -13
View File
@@ -3,27 +3,21 @@
set -e
source "$STATE"
source "$(dirname "$0")/wait_for.sh"
if [ -n "$TEST_AND_PUBLISH" ]; then
[ -n "$SECRET_KEY" ] || {
echo "Cannot run smoke tests: no secret key"
exit 1
}
# Install Terraform and Ansible:
curl -fsS https://releases.hashicorp.com/terraform/0.8.5/terraform_0.8.5_linux_amd64.zip | gunzip >terraform && chmod +x terraform && sudo mv terraform /usr/bin
sudo apt-get update || true
sudo apt-get install -qq -y python-pip python-dev libffi-dev libssl-dev && pip install --user -U cffi && pip install --user ansible
export PATH="$PATH:$HOME/.local/bin"
# Provisioning from image typically take 90 seconds,
# but if we are creating a GCP image, it can take more than 10 minutes:
wait_for 900 "$TEST_VMS_READY_LOCK_FILE"
# Run integration tests:
export COVERAGE=true
export WEAVE_NET_SANITY_CHECKS_FILES="$CIRCLE_ARTIFACTS/weave_net_sanity_check_*.log"
export NAME="test-$CIRCLE_BUILD_NUM-$CIRCLE_NODE_INDEX"
export DISK_NAME_PREFIX="test-$CIRCLE_BUILD_NUM-0"
export USE_IMAGE=1
# Only attempt to create GCP image in first container, wait for it to be created otherwise:
[ "$CIRCLE_NODE_INDEX" == "0" ] && export CREATE_IMAGE=1
cd "$SRCDIR/test" # Ensures we generate code coverage files in the right folder.
./run-integration-tests.sh
cd "$SRCDIR/test" # Ensures we generate code coverage files in the right folder, and use the Terraform state of previously provisionned VMs.
./run-integration-tests.sh test
fi
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
set -e
source "$STATE"
function install_terraform() {
curl -fsS https://releases.hashicorp.com/terraform/0.8.5/terraform_0.8.5_linux_amd64.zip | gunzip >terraform && chmod +x terraform && sudo mv terraform /usr/bin
}
function install_ansible() {
sudo apt-get update || true
sudo apt-get install -qq -y python-pip python-dev libffi-dev libssl-dev && pip install --user -U cffi && pip install --user ansible
export PATH="$PATH:$HOME/.local/bin"
}
if [ -n "$TEST_AND_PUBLISH" ]; then
[ -n "$SECRET_KEY" ] || {
echo "Cannot run smoke tests: no secret key"
exit 1
}
install_terraform >>"$TEST_VMS_SETUP_OUTPUT_FILE" 2>&1
install_ansible >>"$TEST_VMS_SETUP_OUTPUT_FILE" 2>&1
# Only attempt to create GCP image in first container, wait for it to be created otherwise:
[ "$CIRCLE_NODE_INDEX" == "0" ] && export CREATE_IMAGE=1
# Provision and configure testing VMs:
rm -f "$TEST_VMS_PROV_AND_CONF_LOCK_FILE"
cd "$SRCDIR/test" # Ensures we generate Terraform state files in the right folder, for later use by integration tests.
./run-integration-tests.sh configure >>"$TEST_VMS_SETUP_OUTPUT_FILE" 2>&1
touch "$TEST_VMS_PROV_AND_CONF_LOCK_FILE"
echo "Test VMs now provisioned and configured. $(date)." >>"$TEST_VMS_SETUP_OUTPUT_FILE"
fi
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
wait_for() {
local timeout=$1
local lock_file=$2
for i in $(seq 1 "$timeout"); do
[ -f "$lock_file" ] && echo "[$i seconds]: $lock_file found." && return
if ! ((i % 10)); then echo "[$i seconds]: Waiting for $lock_file to be created..."; fi
sleep 1
done
echo "Timed out waiting for test VMs to be ready. See details in: $TEST_VMS_SETUP_OUTPUT_FILE" >&2
exit 1
}