From 28a2c0d8a9051b7ce87de2df14a5339dd2c6d50d Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Thu, 7 May 2015 17:48:24 +0000 Subject: [PATCH] Parallelise integration tests. --- circle.yml | 29 +++++++++++++++++------------ test/gce.sh | 2 +- test/run_all.sh | 14 +++++++++++++- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/circle.yml b/circle.yml index a11d50ff..338fbbe4 100644 --- a/circle.yml +++ b/circle.yml @@ -17,13 +17,13 @@ dependencies: cache_directories: - "~/docker" override: - - if [[ -e "$WEAVE_BUILD" ]]; then - docker load -i $WEAVE_BUILD; - else - docker pull weaveworks/weave-build; - mkdir -p $(dirname "$WEAVE_BUILD"); - docker save weaveworks/weave-build >$WEAVE_BUILD; - fi + - if [[ -e "$WEAVE_BUILD" ]]; then + docker load -i $WEAVE_BUILD; + else + docker pull weaveworks/weave-build; + mkdir -p $(dirname "$WEAVE_BUILD"); + docker save weaveworks/weave-build >$WEAVE_BUILD; + fi post: - curl https://sdk.cloud.google.com | bash - bin/setup-circleci-secrets "$SECRET_PASSWORD" @@ -32,9 +32,14 @@ dependencies: test: override: - - docker run -v /var/run/docker.sock:/run/docker.sock -v /home/ubuntu:/home/go weaveworks/weave-build - - cd $SRCDIR/test; ./gce.sh setup - - cd $SRCDIR/test; . ./gce.sh hosts; ./setup.sh - - cd $SRCDIR/test; . ./gce.sh hosts; ./run_all.sh + - docker run -v /var/run/docker.sock:/run/docker.sock -v /home/ubuntu:/home/go weaveworks/weave-build: + parallel: true + - cd $SRCDIR/test; ./gce.sh setup: + parallel: true + - cd $SRCDIR/test; . ./gce.sh hosts; ./setup.sh: + parallel: true + - cd $SRCDIR/test; . ./gce.sh hosts; ./run_all.sh: + parallel: true post: - - cd $SRCDIR/test; ./gce.sh destroy + - cd $SRCDIR/test; ./gce.sh destroy: + parallel: true diff --git a/test/gce.sh b/test/gce.sh index 829ac8f4..bf632993 100755 --- a/test/gce.sh +++ b/test/gce.sh @@ -15,7 +15,7 @@ ZONE=us-central1-a NUM_HOSTS=2 SUFFIX="" if [ -n "$CIRCLECI" ]; then - SUFFIX="-${CIRCLE_BUILD_NUM}" + SUFFIX="-${CIRCLE_BUILD_NUM}-$CIRCLE_NODE_INDEX" fi # Setup authentication diff --git a/test/run_all.sh b/test/run_all.sh index 5ea2755d..7007925d 100755 --- a/test/run_all.sh +++ b/test/run_all.sh @@ -24,7 +24,19 @@ check_test_status() { # Overwrite assert.sh _assert_cleanup trap with our own trap check_test_status EXIT -for t in *_test.sh; do +# If running on circle, only run the tests for my "shard". +# CIRCLE_NODE_TOTAL is the total number of shards, and +# CIRCLE_NODE_INDEX is my index. +i=0 +TESTS= +for test in *_test.sh; do + if [ -z "$CIRCLECI" ] || [ $(($i % $CIRCLE_NODE_TOTAL)) -eq $CIRCLE_NODE_INDEX ]; then + TESTS="$TESTS $test" + fi + i=$(($i + 1)) +done + +for t in $TESTS; do echo greyly echo "---= Running $t =---" . $t