You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Distribute the tests in VSTS pipeline across multiple agents
3
+
Distribute tests across multiple agents in VSTS pipeline
4
4
.DESCRIPTION
5
-
This script slices tests files across multiple agents for faster execution.
6
-
We search for specific type of file structure (in this example test*), and slice them according to agent number
7
-
If we encounter multiple files [file1..file10] and if we have 2 agents, agent1 executes tests odd number of files while agent2 executes even number of files
8
-
For detalied slicing info: https://docs.microsoft.com/en-us/vsts/pipelines/test/parallel-testing-any-test-runner
5
+
This script divides test files among multiple agents for faster execution. It searches for files matching a specific pattern (for example, `test*`) and assigns them based on the agent number.
6
+
For example, if there are multiple files [test1..test10] and 2 agents:
7
+
- Agent 1 runs tests from odd-numbered files.
8
+
- Agent 2 runs tests from even-numbered files.
9
+
For detailed slicing information, see https://docs.microsoft.com/en-us/vsts/pipelines/test/parallel-testing-any-test-runner
9
10
#>
10
11
11
-
$tests=Get-ChildItem .\tests\ -File #search for test files with specific pattern.
12
-
$totalAgents= [int]$Env:SYSTEM_TOTALJOBSINPHASE#standard VSTS variables available using parallel execution; total number of parallel jobs running
13
-
$agentNumber= [int]$Env:SYSTEM_JOBPOSITIONINPHASE#current job position
12
+
$tests=Get-ChildItem .\tests\ -Filter *.m -File #Search for test files matching the specified pattern
13
+
$totalAgents= [int]$Env:SYSTEM_TOTALJOBSINPHASE#Standard VSTS variable containing the number of parallel jobs
14
+
$agentNumber= [int]$Env:SYSTEM_JOBPOSITIONINPHASE#Current job position
14
15
$testCount=$tests.Count
15
16
16
-
#below conditions are used if parallel pipeline is not used. i.e. pipeline is running with single agent (no parallel configuration)
17
+
#Handle cases where the pipeline runs without parallel configuration (single agent)
Copy file name to clipboardExpand all lines: AzureDevOps/DistributeTests.sh
+13-11Lines changed: 13 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -5,26 +5,29 @@
5
5
#
6
6
# USAGE: ./distribute_tests.sh
7
7
#
8
-
# DESCRIPTION: This script slices tests files across multiple agents for faster execution.
9
-
# We search for specific type of file structure (in this example test*), and slice them according to agent number
10
-
# If we encounter multiple files [file1..file10] and if we have 2 agents, agent1 executes tests odd number of files while agent2 executes even number of files
8
+
# DESCRIPTION: This script divides test files among multiple agents for faster execution. It searches for files matching a specific pattern (for example, `test*`) and assigns them based on the agent number.
9
+
# For example, if there are multiple files [test1..test10] and 2 agents:
10
+
# - Agent 1 runs tests from odd-numbered files.
11
+
# - Agent 2 runs tests from even-numbered files.
12
+
# For detailed slicing information, see https://docs.microsoft.com/en-us/vsts/pipelines/test/parallel-testing-any-test-runner
0 commit comments