From c4ee6d09721a9ff2f7eb59e311668a92862269a8 Mon Sep 17 00:00:00 2001 From: cmoussa1 Date: Tue, 6 Aug 2024 16:10:11 -0700 Subject: [PATCH] t: add tests for calling view-user --list-banks Problem: There exists no tests for calling view-user with the --list-banks option. Add some tests. --- t/Makefile.am | 1 + t/t1040-issue478.t | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100755 t/t1040-issue478.t diff --git a/t/Makefile.am b/t/Makefile.am index ffb17827..287e6ae0 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -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 \ diff --git a/t/t1040-issue478.t b/t/t1040-issue478.t new file mode 100755 index 00000000..2dd29f1a --- /dev/null +++ b/t/t1040-issue478.t @@ -0,0 +1,50 @@ +#!/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-banks --list-banks' ' + flux account view-user testuser --list-banks > list_banks.out && + grep -E "bankA|bankB|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