diff --git a/ci/run_ctests.sh b/ci/run_ctests.sh new file mode 100755 index 000000000..26f8aae5b --- /dev/null +++ b/ci/run_ctests.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set -euo pipefail + +# Support customizing the gtests' install location +# First, try the installed location (CI/conda environments) +installed_test_location="${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libcuopt/" +# Fall back to the build directory (devcontainer environments) +devcontainers_test_location="$(dirname "$(realpath "${BASH_SOURCE[0]}")")/../cpp/build/latest/gtests/libcuopt/" + +if [[ -d "${installed_test_location}" ]]; then + GTEST_DIR="${installed_test_location}" +elif [[ -d "${devcontainers_test_location}" ]]; then + GTEST_DIR="${devcontainers_test_location}" +else + echo "Error: Test location not found. Searched:" >&2 + echo " - ${installed_test_location}" >&2 + echo " - ${devcontainers_test_location}" >&2 + exit 1 +fi + +for gt in "${GTEST_DIR}"/*_TEST; do + test_name=$(basename "${gt}") + echo "Running gtest ${test_name}" + "${gt}" "$@" +done diff --git a/ci/run_cuopt_pytests.sh b/ci/run_cuopt_pytests.sh new file mode 100755 index 000000000..c074737d2 --- /dev/null +++ b/ci/run_cuopt_pytests.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set -euo pipefail + +# It is essential to cd into python/cuopt/cuopt as `pytest-xdist` + `coverage` seem to work only at this directory level. + +# Support invoking run_cuopt_pytests.sh outside the script directory +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cuopt/cuopt/ + +pytest --cache-clear "$@" tests diff --git a/ci/run_cuopt_server_pytests.sh b/ci/run_cuopt_server_pytests.sh new file mode 100755 index 000000000..4ffd21e0f --- /dev/null +++ b/ci/run_cuopt_server_pytests.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set -euo pipefail + +# It is essential to cd into python/cuopt_server/cuopt_server as `pytest-xdist` + `coverage` seem to work only at this directory level. + +# Support invoking run_cuopt_server_pytests.sh outside the script directory +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cuopt_server/cuopt_server/ + +pytest --cache-clear "$@" tests diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 00d1c8e77..653c44133 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -48,12 +48,11 @@ EXITCODE=0 trap "EXITCODE=1" ERR set +e +# Run gtests from libcuopt-tests package +export GTEST_OUTPUT=xml:${RAPIDS_TESTS_DIR}/ + rapids-logger "Run gtests" -for gt in "$CONDA_PREFIX"/bin/gtests/libcuopt/*_TEST ; do - test_name=$(basename "${gt}") - echo "Running gtest $test_name" - timeout 20m "${gt}" --gtest_output=xml:"{RAPIDS_TESTS_DIR}" -done +timeout 40m ./ci/run_ctests.sh rapids-logger "Test script exiting with value: $EXITCODE" exit ${EXITCODE} diff --git a/ci/test_python.sh b/ci/test_python.sh index 63b485253..0a70e56fa 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -58,29 +58,21 @@ rapids-logger "Test cuopt_cli" timeout 10m bash ./python/libcuopt/libcuopt/tests/test_cli.sh rapids-logger "pytest cuopt" -pushd python/cuopt/cuopt -timeout 30m pytest \ - --cache-clear \ +timeout 30m ./ci/run_cuopt_pytests.sh \ --junitxml="${RAPIDS_TESTS_DIR}/junit-cuopt.xml" \ --cov-config=.coveragerc \ --cov=cuopt \ --cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cuopt-coverage.xml" \ --cov-report=term \ - --ignore=raft \ - tests -popd + --ignore=raft rapids-logger "pytest cuopt-server" -pushd python/cuopt_server/cuopt_server -timeout 20m pytest \ - --cache-clear \ +timeout 20m ./ci/run_cuopt_server_pytests.sh \ --junitxml="${RAPIDS_TESTS_DIR}/junit-cuopt-server.xml" \ --cov-config=.coveragerc \ --cov=cuopt_server \ --cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cuopt-server-coverage.xml" \ - --cov-report=term \ - tests -popd + --cov-report=term rapids-logger "Test script exiting with value: $EXITCODE" exit ${EXITCODE} diff --git a/ci/test_wheel_cuopt.sh b/ci/test_wheel_cuopt.sh index 2e466d5dc..b5faa8496 100755 --- a/ci/test_wheel_cuopt.sh +++ b/ci/test_wheel_cuopt.sh @@ -62,7 +62,7 @@ timeout 10m bash ./python/libcuopt/libcuopt/tests/test_cli.sh # Due to race condition in certain cases UCX might not be able to cleanup properly, so we set the number of threads to 1 export OMP_NUM_THREADS=1 -RAPIDS_DATASET_ROOT_DIR=./datasets timeout 30m python -m pytest --verbose --capture=no ./python/cuopt/cuopt/tests/ +timeout 30m ./ci/run_cuopt_pytests.sh --verbose --capture=no # run thirdparty integration tests for only nightly builds if [[ "${RAPIDS_BUILD_TYPE}" == "nightly" ]]; then diff --git a/ci/test_wheel_cuopt_server.sh b/ci/test_wheel_cuopt_server.sh index 0e65887d7..68e3aa931 100755 --- a/ci/test_wheel_cuopt_server.sh +++ b/ci/test_wheel_cuopt_server.sh @@ -27,8 +27,10 @@ rapids-pip-retry install \ ./datasets/linear_programming/download_pdlp_test_dataset.sh ./datasets/mip/download_miplib_test_dataset.sh +RAPIDS_DATASET_ROOT_DIR="$(realpath datasets)" +export RAPIDS_DATASET_ROOT_DIR -RAPIDS_DATASET_ROOT_DIR=./datasets timeout 30m python -m pytest --verbose --capture=no ./python/cuopt_server/cuopt_server/tests/ +timeout 30m ./ci/run_cuopt_server_pytests.sh --verbose --capture=no # Run documentation tests ./ci/test_doc_examples.sh