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 Oct 16, 2024
1 parent 5ae34bc commit 0f8f2d2
Show file tree
Hide file tree
Showing 2 changed files with 50 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 @@ -42,6 +42,7 @@ TESTSCRIPTS = \
t1040-mf-priority-projects.t \
t1041-view-jobs-by-project.t \
t1042-issue508.t \
t1043-issue478.t \
t5000-valgrind.t \
python/t1000-example.py \
python/t1001_db.py \
Expand Down
49 changes: 49 additions & 0 deletions t/t1043-issue478.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

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

. `dirname $0`/sharness.sh

mkdir -p conf.d

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 > banks.out &&
grep "bankA" banks.out &&
grep "bankB" banks.out &&
grep "bankC" 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 0f8f2d2

Please sign in to comment.