Files
dc-deployments-automation/bin/run-tests-in-batches
Varun Arbatti 522706467e Merged in DCD-621-parallelize-builds (pull request #20)
DCD-621 parallelize builds

* DCD-621: Parallelizes tests ny invoking the parralelize script

* DCD-621: Removes leading / to start jira command in product_startup role

* DCD-621: Runs a scenario by name instead of using the all parameter

* DCD-621: A better find all scenarios function to ensure we look at relevant molecule scenarios. Better logging too

* DCD-510: Parallelizes tests further, running in 26 batches on 1 each. The pipeline file is now generated using Jinja

* DCD-510: Adds a pre check stage to verify if number of batches match actual number of scenarios. This test will fail (deliberately)

* DCD-510: Adds a pre check stage to verify if number of batches match actual number of scenarios. Fixes 'test' failure

* DCD-590: Adds note to development.md on how to generate a pipeline file. Adds a makefile and updates a few script commands

* DCD-590: Better documentation in development README document. Updates YML with instructions on how to fix issues with the prevalidation stage

Approved-by: Steve Smith <ssmith@atlassian.com>
Approved-by: Ben Partridge <bpartridge@atlassian.com>
2019-08-30 06:22:53 +00:00

54 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -e
#set -x
# Install dev packages from Pipfile.lock if necessary.
pipenv sync --dev
BATCH_SIZE=1
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=( $(find roles -type f -name 'molecule.yml' -exec dirname {} ';' | sort) )
offset=$(( ${BATCH_NUMBER} - 1))
test_start_index=$(( ${offset} * $BATCH_SIZE ))
scenario_batch="${scenarios[@]:$test_start_index:$BATCH_SIZE}"
if [[ ${scenario_batch[@]} ]]; then
echo "Scenarios that will be executed as part of this batch: ${scenario_batch}"
else
echo "Scenario Batch for ${BATCH_NUMBER} is empty. Exiting (Non zero) now"
exit -1
fi
for scenario in ${scenario_batch}; do
scenario_name=$(basename ${scenario})
role_name=$(dirname $(dirname ${scenario}))
echo "Running scenario ${scenario_name} in ${role_name}"
pushd ${role_name}
pipenv run \
molecule test -s ${scenario_name}
popd
done;