-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run tests in parallel, whenever possible
using tests/run-tests-parallel.sh script like: MONERO_PARALLEL_TEST_JOBS=nproc tests/run-tests-parallel.sh New target release-test-ci and MONERO_PARALLEL_TEST_JOBS var
- Loading branch information
Showing
3 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,4 +124,4 @@ jobs: | |
- name: tests | ||
env: | ||
CTEST_OUTPUT_ON_FAILURE: ON | ||
run: make release-test -j3 | ||
run: make release-test-ci -j3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2014-2021, The Monero Project | ||
# | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without modification, are | ||
# permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, this list of | ||
# conditions and the following disclaimer. | ||
# | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list | ||
# of conditions and the following disclaimer in the documentation and/or other | ||
# materials provided with the distribution. | ||
# | ||
# 3. Neither the name of the copyright holder nor the names of its contributors may be | ||
# used to endorse or promote products derived from this software without specific | ||
# prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | ||
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
# The parallelism celing can be controlled with MONERO_PARALLEL_TEST_JOBS env variable, | ||
# for example: | ||
# | ||
# MONERO_PARALLEL_TEST_JOBS=1 tests/run-tests-parallel.sh | ||
# MONERO_PARALLEL_TEST_JOBS=nproc tests/run-tests-parallel.sh | ||
# | ||
# The minimum between the ceiling and a currently selected reasonable number of threads is used in the end. | ||
# The reasonable number is selected as a number, that delivers the solution in the shortest time. | ||
|
||
NUM_PROC_MAX_REASONABLE=2 # This might be increased, once the core_tests are divided into many more independent pieces or simply sped up | ||
TESTS_EXCLUDED_REGEX="unit_tests|functional_tests_rpc" # These tests collide with core_tests | ||
|
||
if [[ -z $MONERO_PARALLEL_TEST_JOBS ]]; then | ||
echo "No parallelism ceiling selected. Using nproc." | ||
MONERO_PARALLEL_TEST_JOBS=$(nproc) | ||
else | ||
if [[ "$MONERO_PARALLEL_TEST_JOBS" == "nproc" ]]; then | ||
MONERO_PARALLEL_TEST_JOBS=$(nproc) | ||
fi | ||
echo "Parallelism ceiling selected. Using $MONERO_PARALLEL_TEST_JOBS jobs." | ||
fi | ||
|
||
|
||
min() { | ||
RET=$(($1 < $2 ? $1 : $2)) | ||
echo $RET | ||
} | ||
|
||
run_fail_fast() { | ||
# Run the excluded tests first, then everything but excluded. | ||
# In the current situation, the excluded tests are the most probable and quickest to fail, giving an early feedback. | ||
ctest -j"${NUM_PROC_FINAL}" -R "${TESTS_EXCLUDED_REGEX}" && \ | ||
ctest -j"${NUM_PROC_FINAL}" -E "${TESTS_EXCLUDED_REGEX}" \ | ||
RET=$? | ||
echo $RET | ||
} | ||
|
||
run_all() { | ||
ctest -j"${NUM_PROC_FINAL}" -R "${TESTS_EXCLUDED_REGEX}" | ||
RET1=$? | ||
ctest -j"${NUM_PROC_FINAL}" -E "${TESTS_EXCLUDED_REGEX}" | ||
RET2=$? | ||
|
||
if (( $RET1 == 0 && $RET2 == 0 )); then | ||
echo 0 | ||
else | ||
echo 1 | ||
fi | ||
} | ||
|
||
|
||
NUM_PROC_FINAL=$(min $NUM_PROC_MAX_REASONABLE $MONERO_PARALLEL_TEST_JOBS) | ||
echo "Job number ceiling is $MONERO_PARALLEL_TEST_JOBS and the reasonable maximum is currently $NUM_PROC_MAX_REASONABLE." | ||
echo "Using the minimum of the two, so $NUM_PROC_FINAL jobs." | ||
|
||
time run_all | ||
#time run_fail_fast #TODO: Uncomment after mining / RPC random test failures are resolved | ||
|
||
|