Skip to content

Commit

Permalink
Reduce error handling verbosity in CI tests scripts (rapidsai#3258)
Browse files Browse the repository at this point in the history
This PR adds a less verbose [trap method](https://github.com/rapidsai/cugraph/blob/f2b081075704aabc789603e14ce552eac3fbe692/ci/test.sh#L19), for error handling to help ensure that we capture all potential error codes in our test scripts. It's already being used in the `ci/test.sh` and `ci/test_notebooks.sh` scripts, this PR extends the usage to rest of the test scripts.

cc @ajschmidt8

Authors:
  - Ajay Thorve (https://github.com/AjayThorve)
  - AJ Schmidt (https://github.com/ajschmidt8)

Approvers:
  - AJ Schmidt (https://github.com/ajschmidt8)

URL: rapidsai#3258
  • Loading branch information
AjayThorve authored Feb 12, 2023
1 parent 110cfb4 commit f8b8ad8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 51 deletions.
26 changes: 7 additions & 19 deletions ci/test_cpp.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2022, NVIDIA CORPORATION.
# Copyright (c) 2022-2023, NVIDIA CORPORATION.

set -euo pipefail

Expand All @@ -21,7 +21,6 @@ set -u
CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp)
RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"}/
mkdir -p "${RAPIDS_TESTS_DIR}"
SUITEERROR=0

rapids-print-env

Expand All @@ -38,34 +37,23 @@ pushd "${RAPIDS_DATASET_ROOT_DIR}"
./get_test_data.sh
popd

# Run libcugraph gtests from libcugraph-tests package
rapids-logger "Run gtests"
EXITCODE=0
trap "EXITCODE=1" ERR
set +e

# TODO: exit code handling is too verbose. Find a cleaner solution.

# Run libcugraph gtests from libcugraph-tests package
rapids-logger "Run gtests"
for gt in "$CONDA_PREFIX"/bin/gtests/libcugraph/* ; do
test_name=$(basename ${gt})
echo "Running gtest $test_name"
${gt} --gtest_output=xml:${RAPIDS_TESTS_DIR}

exitcode=$?
if (( ${exitcode} != 0 )); then
SUITEERROR=${exitcode}
echo "FAILED: GTest ${gt}"
fi
done

for ct in "$CONDA_PREFIX"/bin/gtests/libcugraph_c/CAPI_*_TEST ; do
test_name=$(basename ${ct})
echo "Running C API test $test_name"
${ct}

exitcode=$?
if (( ${exitcode} != 0 )); then
SUITEERROR=${exitcode}
echo "FAILED: C API test ${ct}"
fi
done

exit ${SUITEERROR}
rapids-logger "Test script exiting with value: $EXITCODE"
exit ${EXITCODE}
36 changes: 4 additions & 32 deletions ci/test_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python)
RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"}
RAPIDS_COVERAGE_DIR=${RAPIDS_COVERAGE_DIR:-"${PWD}/coverage-results"}
mkdir -p "${RAPIDS_TESTS_DIR}" "${RAPIDS_COVERAGE_DIR}"
SUITEERROR=0

rapids-print-env

Expand All @@ -48,6 +47,8 @@ pushd "${RAPIDS_DATASET_ROOT_DIR}"
./get_test_data.sh
popd

EXITCODE=0
trap "EXITCODE=1" ERR
set +e

rapids-logger "pytest pylibcugraph"
Expand All @@ -60,12 +61,6 @@ pytest \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/pylibcugraph-coverage.xml" \
--cov-report=term \
tests
exitcode=$?

if (( ${exitcode} != 0 )); then
SUITEERROR=${exitcode}
echo "FAILED: 1 or more tests in pylibcugraph"
fi
popd

rapids-logger "pytest cugraph"
Expand All @@ -79,12 +74,6 @@ pytest \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cugraph-coverage.xml" \
--cov-report=term \
tests
exitcode=$?

if (( ${exitcode} != 0 )); then
SUITEERROR=${exitcode}
echo "FAILED: 1 or more tests in cugraph"
fi
popd

rapids-logger "pytest cugraph benchmarks (run as tests)"
Expand All @@ -95,12 +84,6 @@ pytest \
-m "managedmem_on and poolallocator_on and tiny" \
--benchmark-disable \
cugraph/pytest-based/bench_algos.py
exitcode=$?

if (( ${exitcode} != 0 )); then
SUITEERROR=${exitcode}
echo "FAILED: 1 or more tests in cugraph benchmarks"
fi
popd

rapids-logger "pytest cugraph_pyg (single GPU)"
Expand All @@ -116,12 +99,6 @@ pytest \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cugraph-pyg-coverage.xml" \
--cov-report=term \
.
exitcode=$?

if (( ${exitcode} != 0 )); then
SUITEERROR=${exitcode}
echo "FAILED: 1 or more tests in cugraph-pyg"
fi
popd

rapids-logger "pytest cugraph-service (single GPU)"
Expand All @@ -139,12 +116,7 @@ pytest \
--benchmark-disable \
-k "not mg" \
tests
exitcode=$?

if (( ${exitcode} != 0 )); then
SUITEERROR=${exitcode}
echo "FAILED: 1 or more tests in cugraph-service"
fi
popd

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

0 comments on commit f8b8ad8

Please sign in to comment.