]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
run-make-check: Enable ctest resource allocation
authorluo rixin <luorixin@huawei.com>
Wed, 7 Feb 2024 03:33:44 +0000 (11:33 +0800)
committerluo rixin <luorixin@huawei.com>
Wed, 21 Feb 2024 02:36:21 +0000 (10:36 +0800)
Co-authored-by: Kefu Chai <tchaikov@gmail.com>
Signed-off-by: luo rixin <luorixin@huawei.com>
run-make-check.sh

index 0ebe2b5de6bdf70f9c2d1e24cad4bb1db7373f82..c4190a6426c53a8e42d10b0d0c486dc750219129 100755 (executable)
@@ -22,6 +22,14 @@ source src/script/run-make.sh
 
 set -e
 
+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() {
     # to prevent OSD EMFILE death on tests, make sure ulimit >= 1024
     $DRY_RUN ulimit -n $(ulimit -Hn)
@@ -43,14 +51,16 @@ function run() {
     fi
 
     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