Skip to content

Commit

Permalink
Add environment-agnostic scripts for running ctests and pytests (#14992)
Browse files Browse the repository at this point in the history
This PR adds environment-agnostic `run_*_{ctests,pytests}.sh` scripts, and updates `test_*_{cpp,python}.sh` to call them.

The `test_*_{cpp,python}.sh` scripts assume they're running in our CI environment, and they do more than just run the tests.

This PR allows devs and downstream consumers to only run the tests, and skip the unrelated logic in `test_*_{cpp,python}.sh`.

Authors:
  - Paul Taylor (https://github.com/trxcllnt)

Approvers:
  - Jake Awe (https://github.com/AyodeAwe)

URL: #14992
  • Loading branch information
trxcllnt authored Feb 26, 2024
1 parent 4d26596 commit e03623a
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 71 deletions.
13 changes: 13 additions & 0 deletions ci/run_cudf_benchmark_smoketests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support customizing the ctests' install location
cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/benchmarks/libcudf/";

# Ensure that benchmarks are runnable
# Run a small Google benchmark
./MERGE_BENCH --benchmark_filter=/2/
# Run a small nvbench benchmark
./STRINGS_NVBENCH --run-once --benchmark 0 --devices 0
9 changes: 9 additions & 0 deletions ci/run_cudf_ctests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support customizing the ctests' install location
cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libcudf/";

ctest --output-on-failure --no-tests=error "$@"
9 changes: 9 additions & 0 deletions ci/run_cudf_kafka_ctests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support customizing the ctests' install location
cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libcudf_kafka/";

ctest --output-on-failure --no-tests=error "$@"
24 changes: 24 additions & 0 deletions ci/run_cudf_memcheck_ctests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -uo pipefail

EXITCODE=0
trap "EXITCODE=1" ERR

# Support customizing the ctests' install location
cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libcudf/";

export GTEST_CUDF_RMM_MODE=cuda
for gt in ./*_TEST ; do
test_name=$(basename ${gt})
# Run gtests with compute-sanitizer
if [[ "$test_name" == "ERROR_TEST" ]] || [[ "$test_name" == "STREAM_IDENTIFICATION_TEST" ]]; then
continue
fi
echo "Running compute-sanitizer on $test_name"
compute-sanitizer --tool memcheck ${gt} "$@"
done
unset GTEST_CUDF_RMM_MODE

exit ${EXITCODE}
13 changes: 13 additions & 0 deletions ci/run_cudf_pandas_pytest_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# It is essential to cd into python/cudf as `pytest-xdist` + `coverage` seem to work only at this directory level.

# Support invoking run_cudf_pandas_pytest_benchmarks.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cudf/

CUDF_BENCHMARKS_USE_PANDAS=ON \
CUDF_BENCHMARKS_DEBUG_ONLY=ON \
pytest --cache-clear "$@" benchmarks
12 changes: 12 additions & 0 deletions ci/run_cudf_pytest_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# It is essential to cd into python/cudf as `pytest-xdist` + `coverage` seem to work only at this directory level.

# Support invoking run_cudf_pytest_benchmarks.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cudf/

CUDF_BENCHMARKS_DEBUG_ONLY=ON \
pytest --cache-clear "$@" benchmarks
11 changes: 11 additions & 0 deletions ci/run_cudf_pytests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# It is essential to cd into python/cudf/cudf as `pytest-xdist` + `coverage` seem to work only at this directory level.

# Support invoking run_cudf_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cudf/cudf/

pytest --cache-clear --ignore="benchmarks" "$@" tests
11 changes: 11 additions & 0 deletions ci/run_custreamz_pytests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# It is essential to cd into python/cudf/cudf as `pytest-xdist` + `coverage` seem to work only at this directory level.

# Support invoking run_custreamz_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/custreamz/custreamz/

pytest --cache-clear "$@" tests
11 changes: 11 additions & 0 deletions ci/run_dask_cudf_pytests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# It is essential to cd into python/cudf/cudf as `pytest-xdist` + `coverage` seem to work only at this directory level.

# Support invoking run_dask_cudf_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/dask_cudf/dask_cudf/

pytest --cache-clear "$@" .
24 changes: 7 additions & 17 deletions ci/test_cpp.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/bin/bash
# Copyright (c) 2022-2024, NVIDIA CORPORATION.

source "$(dirname "$0")/test_cpp_common.sh"
# Support invoking test_cpp.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../

source ./ci/test_cpp_common.sh

EXITCODE=0
trap "EXITCODE=1" ERR
Expand All @@ -10,36 +13,23 @@ set +e
# Run libcudf and libcudf_kafka gtests from libcudf-tests package
export GTEST_OUTPUT=xml:${RAPIDS_TESTS_DIR}/

pushd $CONDA_PREFIX/bin/gtests/libcudf/
rapids-logger "Run libcudf gtests"
ctest -j20 --output-on-failure --no-tests=error
./ci/run_cudf_ctests.sh -j20
SUITEERROR=$?
popd

if (( ${SUITEERROR} == 0 )); then
pushd $CONDA_PREFIX/bin/gtests/libcudf_kafka/
rapids-logger "Run libcudf_kafka gtests"
ctest -j20 --output-on-failure --no-tests=error
./ci/run_cudf_kafka_ctests.sh -j20
SUITEERROR=$?
popd
fi

# Ensure that benchmarks are runnable
pushd $CONDA_PREFIX/bin/benchmarks/libcudf/
rapids-logger "Run tests of libcudf benchmarks"

if (( ${SUITEERROR} == 0 )); then
# Run a small Google benchmark
./MERGE_BENCH --benchmark_filter=/2/
SUITEERROR=$?
fi

if (( ${SUITEERROR} == 0 )); then
# Run a small nvbench benchmark
./STRINGS_NVBENCH --run-once --benchmark 0 --devices 0
./ci/run_cudf_benchmark_smoketests.sh
SUITEERROR=$?
fi
popd

rapids-logger "Test script exiting with value: $EXITCODE"
exit ${EXITCODE}
25 changes: 8 additions & 17 deletions ci/test_cpp_memcheck.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
#!/bin/bash
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-2024, NVIDIA CORPORATION.

source "$(dirname "$0")/test_cpp_common.sh"
# Support invoking test_cpp.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../

EXITCODE=0
trap "EXITCODE=1" ERR
set +e
source ./ci/test_cpp_common.sh

# Run gtests with compute-sanitizer
rapids-logger "Memcheck gtests with rmm_mode=cuda"
export GTEST_CUDF_RMM_MODE=cuda
COMPUTE_SANITIZER_CMD="compute-sanitizer --tool memcheck"
for gt in "$CONDA_PREFIX"/bin/gtests/libcudf/*_TEST ; do
test_name=$(basename ${gt})
if [[ "$test_name" == "ERROR_TEST" ]] || [[ "$test_name" == "STREAM_IDENTIFICATION_TEST" ]]; then
continue
fi
echo "Running compute-sanitizer on $test_name"
${COMPUTE_SANITIZER_CMD} ${gt} --gtest_output=xml:"${RAPIDS_TESTS_DIR}${test_name}.xml"
done
unset GTEST_CUDF_RMM_MODE

./ci/run_cudf_memcheck_ctests.sh \
--gtest_output=xml:"${RAPIDS_TESTS_DIR}${test_name}.xml" \
&& EXITCODE=$? || EXITCODE=$?;

rapids-logger "Test script exiting with value: $EXITCODE"
exit ${EXITCODE}
35 changes: 12 additions & 23 deletions ci/test_python_cudf.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-2024, NVIDIA CORPORATION.

# Support invoking test_python_cudf.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../;

# Common setup steps shared by Python test jobs
source "$(dirname "$0")/test_python_common.sh"
source ./ci/test_python_common.sh

rapids-logger "Check GPU usage"
nvidia-smi
Expand All @@ -12,51 +15,37 @@ trap "EXITCODE=1" ERR
set +e

rapids-logger "pytest cudf"
pushd python/cudf/cudf
# It is essential to cd into python/cudf/cudf as `pytest-xdist` + `coverage` seem to work only at this directory level.
pytest \
--cache-clear \
--ignore="benchmarks" \
./ci/run_cudf_pytests.sh \
--junitxml="${RAPIDS_TESTS_DIR}/junit-cudf.xml" \
--numprocesses=8 \
--dist=loadscope \
--cov-config=../.coveragerc \
--cov=cudf \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cudf-coverage.xml" \
--cov-report=term \
tests
popd
--cov-report=term

# Run benchmarks with both cudf and pandas to ensure compatibility is maintained.
# Benchmarks are run in DEBUG_ONLY mode, meaning that only small data sizes are used.
# Therefore, these runs only verify that benchmarks are valid.
# They do not generate meaningful performance measurements.
pushd python/cudf

rapids-logger "pytest for cudf benchmarks"
CUDF_BENCHMARKS_DEBUG_ONLY=ON \
pytest \
--cache-clear \
./ci/run_cudf_pytest_benchmarks.sh \
--numprocesses=8 \
--dist=loadscope \
--cov-config=.coveragerc \
--cov=cudf \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cudf-benchmark-coverage.xml" \
--cov-report=term \
benchmarks
--cov-report=term

rapids-logger "pytest for cudf benchmarks using pandas"
CUDF_BENCHMARKS_USE_PANDAS=ON \
CUDF_BENCHMARKS_DEBUG_ONLY=ON \
pytest \
--cache-clear \
./ci/run_cudf_pandas_pytest_benchmarks.sh \
--numprocesses=8 \
--dist=loadscope \
--cov-config=.coveragerc \
--cov=cudf \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cudf-benchmark-pandas-coverage.xml" \
--cov-report=term \
benchmarks
popd
--cov-report=term

rapids-logger "Test script exiting with value: $EXITCODE"
exit ${EXITCODE}
23 changes: 9 additions & 14 deletions ci/test_python_other.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-2024, NVIDIA CORPORATION.

# Support invoking test_python_cudf.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../

# Common setup steps shared by Python test jobs
source "$(dirname "$0")/test_python_common.sh"
source ./ci/test_python_common.sh

rapids-mamba-retry install \
--channel "${CPP_CHANNEL}" \
Expand All @@ -17,32 +20,24 @@ trap "EXITCODE=1" ERR
set +e

rapids-logger "pytest dask_cudf"
pushd python/dask_cudf/dask_cudf
pytest \
--cache-clear \
./ci/run_dask_cudf_pytests.sh \
--junitxml="${RAPIDS_TESTS_DIR}/junit-dask-cudf.xml" \
--numprocesses=8 \
--dist=loadscope \
--cov-config=../.coveragerc \
--cov=dask_cudf \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/dask-cudf-coverage.xml" \
--cov-report=term \
.
popd
--cov-report=term

rapids-logger "pytest custreamz"
pushd python/custreamz/custreamz
pytest \
--cache-clear \
./ci/run_custreamz_pytests.sh \
--junitxml="${RAPIDS_TESTS_DIR}/junit-custreamz.xml" \
--numprocesses=8 \
--dist=loadscope \
--cov-config=../.coveragerc \
--cov=custreamz \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/custreamz-coverage.xml" \
--cov-report=term \
tests
popd
--cov-report=term

rapids-logger "Test script exiting with value: $EXITCODE"
exit ${EXITCODE}

0 comments on commit e03623a

Please sign in to comment.