Skip to content

Commit

Permalink
t: add tests for calling view-user --list-banks
Browse files Browse the repository at this point in the history
Problem: There exists no tests for calling view-user with the
--list-banks option.

Add some tests.
  • Loading branch information
cmoussa1 committed Aug 7, 2024
1 parent d81ce8b commit 6d8ac43
Show file tree
Hide file tree
Showing 2 changed files with 53 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 @@ -39,6 +39,7 @@ TESTSCRIPTS = \
t1037-hierarchy-small-tie-db.t \
t1038-hierarchy-small-tie-all-db.t \
t1039-issue476.t \
t1040-issue478.t \
t5000-valgrind.t \
python/t1000-example.py \
python/t1001_db.py \
Expand Down
52 changes: 52 additions & 0 deletions t/t1040-issue478.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

test_description='test calling view-user with the --list-banks optional argument'

. `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 '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 'add some banks' '
flux account add-bank root 1 &&
flux account add-bank --parent-bank=root bankA 1 &&
flux account add-bank --parent-bank=root bankB 1 &&
flux account add-bank --parent-bank=root bankC 1
'

test_expect_success 'add a user' '
flux account add-user --username=testuser --bank=bankA &&
flux account add-user --username=testuser --bank=bankB &&
flux account add-user --username=testuser --bank=bankC
'

test_expect_success 'call view-user --list-banks' '
flux account view-user testuser --list-banks > list_banks.out &&
grep "bankA" list_banks.out &&
grep "bankB" list_banks.out &&
grep "bankC" list_banks.out
'

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 6d8ac43

Please sign in to comment.