Skip to content

Commit

Permalink
fail fast: update tests
Browse files Browse the repository at this point in the history
lgarrison committed Nov 27, 2024
1 parent eb6f5fb commit 3879bd2
Showing 2 changed files with 35 additions and 28 deletions.
32 changes: 19 additions & 13 deletions tests/test_slurm/run.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
#!/bin/bash

set -e
exit_fail() {
err=$?
echo "Slurm test failed! Output is in $workdir"
exit $err
}

trap exit_fail ERR

workdir=$(mktemp -d -p ./ disbatch-test.XXXX)
cp Tasks $workdir
workdir=$(mktemp -d -p $PWD disbatch-test.XXXX)
cp Tasks Tasks_failfast $workdir
cd $workdir

# Run the test
salloc -n 2 disBatch Tasks

# Check that all 3 tasks ran,
# which means A.txt, B.txt, and C.txt exist
success=0
[[ -f A.txt && -f B.txt && -f C.txt ]] || success=$?
[[ -f A.txt && -f B.txt && -f C.txt ]]

cd - > /dev/null
rm -f A.txt B.txt C.txt

if [[ $success -eq 0 ]]; then
echo "Slurm test passed."
rm -rf $workdir
else
echo "Slurm test failed! Output is in $workdir"
fi
# disBatch is expected to exit with a non-zero exit code here
salloc -n 2 disbatch --fail-fast Tasks_failfast || true

# check that we failed fast and didn't run any more tasks
[[ ! -f A.txt ]]

exit $success
trap - ERR
echo "Slurm test passed."
rm -rf $workdir
31 changes: 16 additions & 15 deletions tests/test_ssh/run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/bin/bash

set -e
exit_fail() {
err=$?
echo "SSH test failed! Output is in $workdir"
exit $err
}

trap exit_fail ERR

workdir=$(mktemp -d -p ./ disbatch-test.XXXX)
workdir=$(mktemp -d -p $PWD disbatch-test.XXXX)
cp Tasks Tasks_failfast $workdir
cd $workdir

@@ -12,20 +18,15 @@ disBatch -s localhost:2 Tasks
# Check that all 3 tasks ran,
# which means A.txt, B.txt, and C.txt exist
[[ -f A.txt && -f B.txt && -f C.txt ]]
success=$?

rm A.txt B.txt C.txt
disbatch -s localhost:2 --fail-fast Tasks_failfast
[[ ! -f A.txt ]]
success=$((success + $?))
rm -f A.txt B.txt C.txt

cd - > /dev/null
# disBatch is expected to exit with a non-zero exit code here
disbatch -s localhost:2 --fail-fast Tasks_failfast || true

if [[ $success -eq 0 ]]; then
echo "SSH test passed."
rm -rf $workdir
else
echo "SSH test failed! Output is in $workdir"
fi
# check that we failed fast and didn't run any more tasks
[[ ! -f A.txt ]]

exit $success
trap - ERR
echo "SSH test passed."
rm -rf $workdir

0 comments on commit 3879bd2

Please sign in to comment.