Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
test script fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Pierce committed May 11, 2019
1 parent b6bba5b commit 9d6d39d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 57 deletions.
47 changes: 19 additions & 28 deletions scripts/parallel-test.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
#!/bin/bash
set -e # exit on failure of any "simple" command (excludes &&, ||, or | chains)
# prepare environment
PATH=$PATH:~/opt/mongodb/bin
echo "Extracting build directory..."
[[ -z "${1}" ]] && tar -zxf build.tar.gz || tar -xzf $1
cd /data/job/build
# run tests
echo "Running tests..."
CPU_CORES=$(getconf _NPROCESSORS_ONLN)
echo "$CPU_CORES cpu cores detected."
TEST_COUNT=$(ctest -N -LE _tests | grep -i 'Total Tests: ' | cut -d ':' -f 2 | awk '{print $1}')
#!/usr/bin/env bash
set -ieo pipefail
echo "+++ Extracting build directory"
[[ -f build.tar.gz ]] && tar -xzf build.tar.gz
ls -l build
cd ./build
echo "+++ Running tests"
# Counting tests available and if they get disabled for some reason, throw a failure
TEST_COUNT=$($CTEST_BIN -N -LE _tests | grep -i 'Total Tests: ' | cut -d ':' -f 2 | awk '{print $1}')
[[ $TEST_COUNT > 0 ]] && echo "$TEST_COUNT tests found." || (echo "ERROR: No tests registered with ctest! Exiting..." && exit 1)
set +e # defer ctest error handling to end
echo "$ ctest -j $CPU_CORES -LE _tests --output-on-failure -T Test"
ctest -j $CPU_CORES -LE _tests --output-on-failure -T Test
CORES=$(getconf _NPROCESSORS_ONLN)
$CTEST_BIN -j $CORES -LE _tests --output-on-failure -T Test
EXIT_STATUS=$?
[[ "$EXIT_STATUS" == 0 ]] && set -e
echo "Done running parallelizable tests."
# upload artifacts
echo "Uploading artifacts..."
XML_FILENAME="test-results.xml"
mv $(pwd)/Testing/$(ls $(pwd)/Testing/ | grep '20' | tail -n 1)/Test.xml $XML_FILENAME
buildkite-agent artifact upload config.ini
buildkite-agent artifact upload genesis.json
cd ..
cd build
buildkite-agent artifact upload $XML_FILENAME
echo "Done uploading artifacts."
# Prepare tests for artifact upload
echo "+++ Uploading artifacts"
mv -f ./Testing/$(ls ./Testing/ | grep '20' | tail -n 1)/Test.xml test-results.xml
buildkite-agent artifact upload test-results.xml
# ctest error handling
if [[ "$EXIT_STATUS" != 0 ]]; then
if [[ $EXIT_STATUS != 0 ]]; then
echo "Failing due to non-zero exit status from ctest: $EXIT_STATUS"
echo ' ^^^ scroll up for more information ^^^'
buildkite-agent artifact upload config.ini
buildkite-agent artifact upload genesis.json
exit $EXIT_STATUS
fi
fi
54 changes: 25 additions & 29 deletions scripts/serial-test.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
#!/bin/bash
set -e # exit on failure of any "simple" command (excludes &&, ||, or | chains)
# prepare environment
PATH=$PATH:~/opt/mongodb/bin
echo "Extracting build directory..."
[[ -z "${1}" ]] && tar -zxf build.tar.gz || tar -xzf $1
echo "Starting MongoDB..."
mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log
cd /data/job/build
# run tests
echo "Running tests..."
TEST_COUNT=$(ctest -N -L nonparallelizable_tests | grep -i 'Total Tests: ' | cut -d ':' -f 2 | awk '{print $1}')
#!/usr/bin/env bash
set -ieo pipefail
echo "+++ Extracting build directory"
[[ -f build.tar.gz ]] && tar -xzf build.tar.gz
ls -l build
cd ./build
if [[ -f $MONGODB_BIN ]]; then
echo "+++ Killing old MongoDB"
$(pgrep mongod | xargs kill -9) || true
echo "+++ Starting MongoDB"
PATH=$PATH:~/opt/mongodb/bin
mongod --fork --dbpath ~/data/mongodb -f ~/etc/mongod.conf --logpath "$(pwd)"/mongod.log
fi
echo "+++ Running tests"
# Counting tests available and if they get disabled for some reason, throw a failure
TEST_COUNT=$($CTEST_BIN -N -LE _tests | grep -i 'Total Tests: ' | cut -d ':' -f 2 | awk '{print $1}')
[[ $TEST_COUNT > 0 ]] && echo "$TEST_COUNT tests found." || (echo "ERROR: No tests registered with ctest! Exiting..." && exit 1)
set +e # defer ctest error handling to end
echo "$ ctest -L nonparallelizable_tests --output-on-failure -T Test"
ctest -L nonparallelizable_tests --output-on-failure -T Test
$CTEST_BIN -L nonparallelizable_tests --output-on-failure -T Test
EXIT_STATUS=$?
[[ "$EXIT_STATUS" == 0 ]] && set -e
echo "Done running non-parallelizable tests."
# upload artifacts
echo "Uploading artifacts..."
XML_FILENAME="test-results.xml"
mv $(pwd)/Testing/$(ls $(pwd)/Testing/ | grep '20' | tail -n 1)/Test.xml $XML_FILENAME
buildkite-agent artifact upload config.ini
buildkite-agent artifact upload genesis.json
cd ..
buildkite-agent artifact upload mongod.log
cd build
buildkite-agent artifact upload $XML_FILENAME
echo "Done uploading artifacts."
[[ $EXIT_STATUS == 0 ]] && set -e
echo "+++ Uploading artifacts"
mv -f ./Testing/$(ls ./Testing/ | grep '20' | tail -n 1)/Test.xml test-results.xml
buildkite-agent artifact upload test-results.xml
[[ -f $MONGODB_BIN ]] && buildkite-agent artifact upload mongod.log
# ctest error handling
if [[ "$EXIT_STATUS" != 0 ]]; then
if [[ $EXIT_STATUS != 0 ]]; then
echo "Failing due to non-zero exit status from ctest: $EXIT_STATUS"
echo ' ^^^ scroll up for more information ^^^'
buildkite-agent artifact upload config.ini
buildkite-agent artifact upload genesis.json
exit $EXIT_STATUS
fi

0 comments on commit 9d6d39d

Please sign in to comment.