From 8cf01382af2627269279f6da3ebd753a08bc94bc Mon Sep 17 00:00:00 2001 From: Varun Arbatti Date: Thu, 29 Aug 2019 16:12:14 +1000 Subject: [PATCH] DCD-621: Changes pipelines to run scenarios in parallel. (9 batches of 3 scenarios each) --- bin/run-tests-in-batches | 50 +++++++++++++++++++++++++ bitbucket-pipelines.yml | 81 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 126 insertions(+), 5 deletions(-) create mode 100755 bin/run-tests-in-batches diff --git a/bin/run-tests-in-batches b/bin/run-tests-in-batches new file mode 100755 index 0000000..ca3bd78 --- /dev/null +++ b/bin/run-tests-in-batches @@ -0,0 +1,50 @@ +#!/bin/bash + +set -e +#set -x + +# Install dev packages from Pipfile.lock if necessary. +#pipenv sync --dev + +BATCH_NUMBER="" +batch_args="$1" + +case $batch_args in + -b|--batch) + BATCH_NUMBER="$2" + ;; + --default) + BATCH_NUMBER="" + ;; +esac + +if [[ -z "$BATCH_NUMBER" ]]; then + echo "Batch number not passed in. Please pass a batch number to run tests." + exit -1 +fi + +case ${BATCH_NUMBER} in + ''|*[1-9]*) ;; + *) echo "Bad Input for Batch number. ${BATCH_NUMBER} is not a valid batch number (Should be a number >= 1)" && exit -1 ;; +esac + +scenarios=( $(ls -d1 roles/**/molecule/* | sort) ) + +offset=$(( ${BATCH_NUMBER} - 1)) +test_start_index=$(( ${offset} * 3 )) + +for scenario in "${scenarios[@]:$test_start_index:3}"; do + pushd $(dirname $(dirname $scenario)) + pipenv run \ + molecule test --all + popd +done; + + + +#for role in `find roles/ -name molecule | sort`; do +# pushd `dirname $role` +# pipenv run \ +# molecule test --all +# popd +#done diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index a19258c..5239424 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -12,9 +12,80 @@ definitions: pipelines: default: - step: - services: - - docker + name: Pre Parallelization stage script: - - apt-get update && apt-get install -y virtualenv python-dev - - ./bin/install-ansible - - ./bin/run-all-tests + - echo "Running tests in 9 batches of 3 scenarios (max) each" + - parallel: + - step: + name: Molecule test batch 1 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 1 + - step: + name: Molecule test batch 2 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 2 + - step: + name: Molecule test batch 3 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 3 + - step: + name: Molecule test batch 4 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 4 + - step: + name: Molecule test batch 5 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 5 + - step: + name: Molecule test batch 6 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 6 + - step: + name: Molecule test batch 7 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 7 + - step: + name: Molecule test batch 8 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 8 + - step: + name: Molecule test batch 9 + services: + - docker + script: + - apt-get update && apt-get install -y virtualenv python-dev + - ./bin/install-ansible + - ./bin/run-all-tests --batch 9 +