mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
The unit tests execution time within Azure Pipelines(AP) is not balanced. One test job(Base) takes ~13min, while another(XMLRPC) ~28min. Fortunately, AP supports slicing: > An agent job can be used to run a suite of tests in parallel. For example, you can run a large suite of 1000 tests on a single agent. Or, you can use two agents and run 500 tests on each one in parallel. To leverage slicing, the tasks in the job should be smart enough to understand the slice they belong to. >The step that runs the tests in a job needs to know which test slice should be run. The variables System.JobPositionInPhase and System.TotalJobsInPhase can be used for this purpose. Thus, to support this pytest should know how to split the test suite into groups(slices). For this, a new internal pytest plugin was added. About plugin. - Tests within a slice are grouped by test modules because not all of the tests within the module are independent from each other. - Slices are balanced by the number of tests within test module. - To run some module within its own environment there is a dedicated slice option (could help with extremely slow tests) Examples. - To split `test_cmdline` tests into 2 slices and run the first one: ipa-run-tests --slices=2 --slice-num=1 test_cmdline - To split tests into 2 slices, then to move one module out to its own slice and run the second one: ipa-run-tests --slices=2 --slice-dedicated=test_cmdline/test_cli.py \ --slice-num=2 test_cmdline Fixes: https://pagure.io/freeipa/issue/8008 Signed-off-by: Stanislav Levin <slev@altlinux.org> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
34 lines
1.4 KiB
YAML
34 lines
1.4 KiB
YAML
parameters:
|
|
imageName: 'freeipa-fedora-builder:latest'
|
|
containerName: 'container'
|
|
logsPath: 'logs'
|
|
taskToRun: 'run-tests'
|
|
testsToRun: ''
|
|
testsToIgnore: ''
|
|
testsToDedicate: ''
|
|
|
|
steps:
|
|
- script: |
|
|
set -e
|
|
cnt=`docker create --hostname ipa.example.test --privileged -v $(Build.Repository.LocalPath):/freeipa -t ${{parameters.imageName}} /usr/sbin/init`
|
|
echo "##vso[task.setvariable variable=containerName;isOutput=true]$cnt"
|
|
name: createContainer
|
|
displayName: Create container for running a test
|
|
- script: |
|
|
set -e
|
|
docker start $(createContainer.containerName)
|
|
docker inspect $(createContainer.containerName)
|
|
displayName: Start container for running a test
|
|
- script: |
|
|
set -e
|
|
docker exec --env TESTS_TO_RUN="${{ parameters.testsToRun }}" \
|
|
--env TESTS_TO_IGNORE="${{ parameters.testsToIgnore }}" \
|
|
--env TESTS_TO_DEDICATE="${{ parameters.testsToDedicate }}" \
|
|
--env CI_RUNNER_LOGS_DIR="${{ parameters.logsPath }}" \
|
|
--env SYSTEM_TOTALJOBSINPHASE=$(System.TotalJobsInPhase) \
|
|
--env SYSTEM_JOBPOSITIONINPHASE=$(System.JobPositionInPhase) \
|
|
--privileged -t \
|
|
$(createContainer.containerName) \
|
|
/bin/bash --noprofile --norc -x /freeipa/ipatests/azure/azure-${{parameters.taskToRun}}.sh
|
|
displayName: Run test
|