From 9e10afcace97a3be6da9ad13bb201e7b90fc99c2 Mon Sep 17 00:00:00 2001 From: luo rixin Date: Wed, 7 Feb 2024 11:33:44 +0800 Subject: [PATCH] run-make-check: Enable ctest resource allocation Co-authored-by: Kefu Chai Signed-off-by: luo rixin (cherry picked from commit 5aa832c5c60e0469127647570bb102ff64a3fe32) (cherry picked from commit 6097aa619db5a8489a672a6c156c033106ba7d90) --- run-make-check.sh | 63 +++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/run-make-check.sh b/run-make-check.sh index 62743038739..54a7a61029a 100755 --- a/run-make-check.sh +++ b/run-make-check.sh @@ -22,8 +22,12 @@ source src/script/run-make.sh set -e -function in_jenkins() { - test -n "$JENKINS_HOME" +function gen_ctest_resource_file() { + local file_name=$(mktemp /tmp/ctest-resource-XXXXXX) + local max_cpuid=$(($(nproc) - 1)) + jq -n '$ARGS.positional | map({id:., slots:1}) | {cpus:.} | {version: {major:1, minor:0}, local:[.]}' \ + --args $(seq 0 $max_cpuid) > $file_name + echo "$file_name" } function run() { @@ -37,20 +41,27 @@ function run() { # increase the aio-max-nr, which is by default 65536. we could reach this # limit while running seastar tests and bluestore tests. local m=16 - if [ $(nproc) -gt $m ]; then - m=$(nproc) + local procs="$(($(get_processors) * 2))" + if [ "${procs}" -gt $m ]; then + m="${procs}" + fi + local aiomax="$((65536 * procs))" + if [ "$(/sbin/sysctl -n fs.aio-max-nr )" -lt "${aiomax}" ]; then + wrap_sudo + $DRY_RUN $SUDO /sbin/sysctl -q -w fs.aio-max-nr="${aiomax}" || true fi - $DRY_RUN sudo /sbin/sysctl -q -w fs.aio-max-nr=$((65536 * $(nproc))) CHECK_MAKEOPTS=${CHECK_MAKEOPTS:-$DEFAULT_MAKEOPTS} + CTEST_RESOURCE_FILE=$(gen_ctest_resource_file) + CHECK_MAKEOPTS+=" --resource-spec-file ${CTEST_RESOURCE_FILE}" if in_jenkins; then if ! ctest $CHECK_MAKEOPTS --no-compress-output --output-on-failure --test-output-size-failed 1024000 -T Test; then # do not return failure, as the jenkins publisher will take care of this - rm -fr ${TMPDIR:-/tmp}/ceph-asok.* + rm -fr ${TMPDIR:-/tmp}/ceph-asok.* ${CTEST_RESOURCE_FILE} fi else if ! $DRY_RUN ctest $CHECK_MAKEOPTS --output-on-failure; then - rm -fr ${TMPDIR:-/tmp}/ceph-asok.* + rm -fr ${TMPDIR:-/tmp}/ceph-asok.* ${CTEST_RESOURCE_FILE} return 1 fi fi @@ -71,43 +82,13 @@ function main() { fi # uses run-make.sh to install-deps FOR_MAKE_CHECK=1 prepare - local cxx_compiler=g++ - local c_compiler=gcc - for i in $(seq 14 -1 10); do - if type -t clang-$i > /dev/null; then - cxx_compiler="clang++-$i" - c_compiler="clang-$i" - break - fi - done - # Init defaults after deps are installed. - local cmake_opts - cmake_opts+=" -DCMAKE_CXX_COMPILER=$cxx_compiler -DCMAKE_C_COMPILER=$c_compiler" - cmake_opts+=" -DCMAKE_CXX_FLAGS_DEBUG=-Werror" - cmake_opts+=" -DENABLE_GIT_VERSION=OFF" - cmake_opts+=" -DWITH_GTEST_PARALLEL=ON" - cmake_opts+=" -DWITH_FIO=ON" - cmake_opts+=" -DWITH_CEPHFS_SHELL=ON" - cmake_opts+=" -DWITH_GRAFANA=ON" - cmake_opts+=" -DWITH_SPDK=ON" - cmake_opts+=" -DWITH_RBD_MIRROR=ON" - if [ $WITH_SEASTAR ]; then - cmake_opts+=" -DWITH_SEASTAR=ON" - fi - if [ $WITH_ZBD ]; then - cmake_opts+=" -DWITH_ZBD=ON" - fi - if [ $WITH_RBD_RWL ]; then - cmake_opts+=" -DWITH_RBD_RWL=ON" - fi - cmake_opts+=" -DWITH_RBD_SSD_CACHE=ON" - in_jenkins && echo "CI_DEBUG: Our cmake_opts are: $cmake_opts - CI_DEBUG: Running ./configure" - configure "$cmake_opts" "$@" + configure "$@" in_jenkins && echo "CI_DEBUG: Running 'build tests'" build tests echo "make check: successful build on $(git rev-parse HEAD)" FOR_MAKE_CHECK=1 run } -main "$@" +if [ "$0" = "$BASH_SOURCE" ]; then + main "$@" +fi \ No newline at end of file -- 2.39.5