|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +test_description='Test job dependency singleton support' |
| 4 | + |
| 5 | +. $(dirname $0)/sharness.sh |
| 6 | + |
| 7 | + |
| 8 | +flux version | grep -q libflux-security && test_set_prereq FLUX_SECURITY |
| 9 | + |
| 10 | +test_under_flux 2 job |
| 11 | + |
| 12 | +flux setattr log-stderr-level 1 |
| 13 | + |
| 14 | +submit_as_alternate_user() |
| 15 | +{ |
| 16 | + FAKE_USERID=42 |
| 17 | + flux run --dry-run "$@" | \ |
| 18 | + flux python ${SHARNESS_TEST_SRCDIR}/scripts/sign-as.py $FAKE_USERID \ |
| 19 | + >job.signed |
| 20 | + FLUX_HANDLE_USERID=$FAKE_USERID \ |
| 21 | + flux job submit --flags=signed job.signed |
| 22 | +} |
| 23 | + |
| 24 | +test_expect_success 'dependency=singleton rejects job with no job name' ' |
| 25 | + test_expect_code 1 flux submit --dependency=singleton true 2>s1.err && |
| 26 | + grep "require a job name" s1.err |
| 27 | +' |
| 28 | +test_expect_success 'jobs without a dependency run' ' |
| 29 | + flux run true |
| 30 | +' |
| 31 | +test_expect_success 'submit 5 singleton jobs at once' ' |
| 32 | + flux submit -n1 --watch --quiet --cc=1-5 --job-name=test \ |
| 33 | + --dependency=singleton echo {cc} > 5jobs.out && |
| 34 | + test_debug "cat 5jobs.out" && |
| 35 | + test_seq 1 5 >5jobs.expected && |
| 36 | + test_cmp 5jobs.expected 5jobs.out |
| 37 | +' |
| 38 | +test_expect_success 'submit a held job' ' |
| 39 | + heldid=$(flux submit -n1 --urgency=hold --job-name=foo hostname) |
| 40 | +' |
| 41 | +test_expect_success 'singleton job is stuck in DEPEND state' ' |
| 42 | + id=$(flux submit -n1 --job-name=foo --dependency=singleton true) && |
| 43 | + flux job wait-event -vt 30 $id dependency-add && |
| 44 | + test $(flux jobs -no {state} $id) = DEPEND |
| 45 | +' |
| 46 | +test_expect_success 'jobtap plugin query works' ' |
| 47 | + flux jobtap query .dependency-singleton | jq && |
| 48 | + flux jobtap query .dependency-singleton \ |
| 49 | + | jq -e ".[\"$(id -u):foo\"].count == 2" |
| 50 | +' |
| 51 | +test_expect_success 'singleton job with a different name runs' ' |
| 52 | + id2=$(flux submit -n1 --job-name=bar --dependency=singleton true) && |
| 53 | + flux job wait-event -vt 30 $id2 clean |
| 54 | +' |
| 55 | +test_expect_success FLUX_SECURITY 'allow guest access to testexec' ' |
| 56 | + echo exec.testexec.allow-guests=true | flux config load |
| 57 | +' |
| 58 | +test_expect_success FLUX_SECURITY 'singleton job as another user with same name runs' ' |
| 59 | + id3=$(submit_as_alternate_user -n1 --job-name=foo \ |
| 60 | + --dependency=singleton -Sexec.test.run_duration=0.1s true) && |
| 61 | + echo "submitted $id3" && |
| 62 | + flux job wait-event -vt 30 $id3 clean |
| 63 | +' |
| 64 | +test_expect_success 'release held job, singleton should now run' ' |
| 65 | + test $(flux jobs -no {state} $id) = DEPEND && |
| 66 | + flux job urgency $heldid default && |
| 67 | + flux job wait-event -vt30 $id clean |
| 68 | +' |
| 69 | +test_done |
0 commit comments