From ab4d5955c13e2d80932de8fc4905d8f00dd39dc5 Mon Sep 17 00:00:00 2001 From: Brett Logan Date: Sat, 23 Nov 2019 16:29:53 -0500 Subject: [PATCH] [FAB-17132] Add Parallel Strategy to Integration Tests This change splits the integration suite into multiple parallel jobs. Under this framework the build finishes in approximately 40 minutes as opposed to nearly 2 hours today Signed-off-by: Brett Logan --- ci/azure-pipelines.yml | 13 +++++---- ci/install_deps.yml | 2 +- scripts/run-integration-tests.sh | 49 +++++++++++++++++++------------- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 5d6250b1933..435567d2d1b 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -16,7 +16,7 @@ variables: jobs: - job: VerifyBuild pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-18.04 steps: - template: install_deps.yml - checkout: self @@ -27,7 +27,7 @@ jobs: - job: DocBuild pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-18.04 container: image: n42org/tox:3.4.0 steps: @@ -41,7 +41,7 @@ jobs: - job: UnitTests pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-18.04 steps: - template: install_deps.yml - checkout: self @@ -54,8 +54,10 @@ jobs: - job: IntegrationTests pool: - vmImage: ubuntu-16.04 - timeoutInMinutes: 120 + vmImage: ubuntu-18.04 + strategy: + parallel: 5 + timeoutInMinutes: 90 steps: - template: install_deps.yml - checkout: self @@ -63,3 +65,4 @@ jobs: displayName: Checkout Fabric Code - script: make integration-test displayName: Run Integration Tests + diff --git a/ci/install_deps.yml b/ci/install_deps.yml index 59a7c5877f7..caee041ea13 100644 --- a/ci/install_deps.yml +++ b/ci/install_deps.yml @@ -6,7 +6,7 @@ steps: - script: | sudo apt-get clean sudo apt-get update - sudo apt-get install -y libtool gcc make haveged + sudo apt-get install -y libtool gcc make displayName: Install Dependencies - task: GoTool@0 inputs: diff --git a/scripts/run-integration-tests.sh b/scripts/run-integration-tests.sh index 20b0f915bc7..ba22030b523 100755 --- a/scripts/run-integration-tests.sh +++ b/scripts/run-integration-tests.sh @@ -12,23 +12,32 @@ set -e -u fabric_dir="$(cd "$(dirname "$0")/.." && pwd)" -# find packages that contain "integration" in the import path -integration_dirs() { - local packages="$1" - - go list -f '{{.Dir}}' "$packages" | grep -E '/integration($|/)' | sed "s,${fabric_dir},.,g" -} - -main() { - cd "$fabric_dir" - - local -a dirs=("$@") - if [ "${#dirs[@]}" -eq 0 ]; then - while IFS=$'\n' read -r pkg; do dirs+=("$pkg"); done < <(integration_dirs "./...") - fi - - echo "Running integration tests..." - ginkgo -keepGoing --slowSpecThreshold 60 "${dirs[@]}" -} - -main "$@" +cd "$fabric_dir" + +dirs=() +if [ "${#}" -eq 0 ]; then + specs=() + specs=("$(grep -Ril --exclude-dir=vendor --exclude-dir=scripts "RunSpecs" . | grep integration)") + for spec in ${specs[*]}; do + dirs+=("$(dirname "${spec}")") + done +else + dirs=("$@") +fi + +totalAgents=${SYSTEM_TOTALJOBSINPHASE:-0} # standard VSTS variables available using parallel execution; total number of parallel jobs running +agentNumber=${SYSTEM_JOBPOSITIONINPHASE:-0} # current job position +testCount=${#dirs[@]} + +# below conditions are used if parallel pipeline is not used. i.e. pipeline is running with single agent (no parallel configuration) +if [ "$totalAgents" -eq 0 ]; then totalAgents=1; fi +if [ "$agentNumber" -eq 0 ]; then agentNumber=1; fi + +declare -a files +for ((i = "$agentNumber"; i <= "$testCount"; )); do + files+=("${dirs[$i - 1]}") + i=$((${i} + ${totalAgents})) +done + +echo "Running the following test suites: ${files[*]}" +ginkgo -keepGoing --slowSpecThreshold 60 ${files[*]}