From 9b5d0da16555f1454637eaf4f59de05f3470d56e 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/t1045-issue478.t | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100755 t/t1045-issue478.t diff --git a/t/Makefile.am b/t/Makefile.am index 97edba86..0366d1a0 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -44,6 +44,7 @@ TESTSCRIPTS = \ t1042-issue508.t \ t1043-view-jobs-by-bank.t \ t1044-mf-priority-resource-limits.t \ + t1045-issue478.t \ t5000-valgrind.t \ python/t1000-example.py \ python/t1001_db.py \ diff --git a/t/t1045-issue478.t b/t/t1045-issue478.t new file mode 100755 index 00000000..8f85766b --- /dev/null +++ b/t/t1045-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 + +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