Skip to content

Commit

Permalink
t: add tests for running jobs under instance owner
Browse files Browse the repository at this point in the history
Problem: There exists no tests in flux-accounting for submitting jobs
as the instance owner with the priority plugin loaded.

Add some tests.
  • Loading branch information
cmoussa1 committed Aug 6, 2024
1 parent 3b365f0 commit 8b901aa
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ TESTSCRIPTS = \
t1036-hierarchy-small-no-tie-db.t \
t1037-hierarchy-small-tie-db.t \
t1038-hierarchy-small-tie-all-db.t \
t1039-issue476.t \
t5000-valgrind.t \
python/t1000-example.py \
python/t1001_db.py \
Expand Down
54 changes: 54 additions & 0 deletions t/t1039-issue476.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

test_description='test submitting jobs as instance owner'

. `dirname $0`/sharness.sh

mkdir -p conf.d

MULTI_FACTOR_PRIORITY=${FLUX_BUILD_DIR}/src/plugins/.libs/mf_priority.so
SUBMIT_AS=${SHARNESS_TEST_SRCDIR}/scripts/submit_as.py
ACCOUNTING_DB=$(pwd)/FluxAccountingTest.db

export TEST_UNDER_FLUX_SCHED_SIMPLE_MODE="limited=1"
test_under_flux 1 job -o,--config-path=$(pwd)/conf.d

flux setattr log-stderr-level 1

test_expect_success 'allow guest access to testexec' '
flux config load <<-EOF
[exec.testexec]
allow-guests = true
EOF
'
test_expect_success 'create flux-accounting DB, start flux-accounting service' '
flux account -p ${ACCOUNTING_DB} create-db &&
flux account-service -p ${ACCOUNTING_DB} -t
'

test_expect_success 'load multi-factor priority plugin' '
flux jobtap load -r .priority-default ${MULTI_FACTOR_PRIORITY} &&
flux jobtap list | grep mf_priority
'

test_expect_success 'send flux-accounting information to plugin' '
flux account-priority-update -p ${ACCOUNTING_DB}
'

test_expect_success 'submit a job as instance owner' '
username=$(whoami) &&
uid=$(id -u) &&
job=$(flux python ${SUBMIT_AS} ${uid} hostname) &&
flux job wait-event -vt 5 ${job} alloc &&
flux cancel ${job}
'

test_expect_success 'shut down flux-accounting service' '
flux python -c "import flux; flux.Flux().rpc(\"accounting.shutdown_service\").get()"
'

test_expect_success 'remove flux-accounting DB' '
rm ${ACCOUNTING_DB}
'

test_done

0 comments on commit 8b901aa

Please sign in to comment.