Skip to content

Commit

Permalink
[FAB-17132] Add Parallel Strategy to Integration Tests
Browse files Browse the repository at this point in the history
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 <Brett.T.Logan@ibm.com>
  • Loading branch information
Brett Logan authored and mastersingh24 committed Nov 30, 2019
1 parent ea93b8f commit ab4d595
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 26 deletions.
13 changes: 8 additions & 5 deletions ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ variables:
jobs:
- job: VerifyBuild
pool:
vmImage: ubuntu-16.04
vmImage: ubuntu-18.04
steps:
- template: install_deps.yml
- checkout: self
Expand All @@ -27,7 +27,7 @@ jobs:

- job: DocBuild
pool:
vmImage: ubuntu-16.04
vmImage: ubuntu-18.04
container:
image: n42org/tox:3.4.0
steps:
Expand All @@ -41,7 +41,7 @@ jobs:

- job: UnitTests
pool:
vmImage: ubuntu-16.04
vmImage: ubuntu-18.04
steps:
- template: install_deps.yml
- checkout: self
Expand All @@ -54,12 +54,15 @@ 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
path: 'go/src/github.com/hyperledger/fabric'
displayName: Checkout Fabric Code
- script: make integration-test
displayName: Run Integration Tests

2 changes: 1 addition & 1 deletion ci/install_deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
49 changes: 29 additions & 20 deletions scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[*]}

0 comments on commit ab4d595

Please sign in to comment.