From 0b3a54da48058e82b1332114fed384b2a2ae7fcf Mon Sep 17 00:00:00 2001 From: cmoussa1 Date: Mon, 29 Jul 2024 08:28:29 -0700 Subject: [PATCH 1/4] view-bank: add --parsable option Problem: The "view-bank" command does not have an option to print out the database hierarchy in a parsable format. Add an option to print out a pipe-delimited ('|') hierarchy of the flux-accounting database, starting with the bank passed in. --- .../fluxacct/accounting/bank_subcommands.py | 56 +++++++++++++++---- src/cmd/flux-account-service.py | 1 + src/cmd/flux-account.py | 9 +++ 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/bindings/python/fluxacct/accounting/bank_subcommands.py b/src/bindings/python/fluxacct/accounting/bank_subcommands.py index 13a8b6885..9c18e307a 100644 --- a/src/bindings/python/fluxacct/accounting/bank_subcommands.py +++ b/src/bindings/python/fluxacct/accounting/bank_subcommands.py @@ -176,6 +176,38 @@ def print_hierarchy(cur, bank, hierarchy_str, indent=""): return hierarchy_str +def print_parsable_hierarchy(cur, bank, hierarchy_str, indent=""): + # look for all sub banks under this parent bank + select_stmt = "SELECT bank,shares,job_usage FROM bank_table WHERE parent_bank=?" + cur.execute(select_stmt, (bank,)) + sub_banks = cur.fetchall() + + if len(sub_banks) == 0: + # we've reached a bank with no sub banks, so print out every user + # under this bank + cur.execute( + "SELECT username,shares,job_usage,fairshare FROM association_table WHERE bank=?", + (bank,), + ) + users = cur.fetchall() + if users: + for user in users: + hierarchy_str += ( + f"{indent} {bank}|{user[0]}|{user[1]}|{user[2]}|{user[3]}\n" + ) + else: + # continue traversing the hierarchy + for sub_bank in sub_banks: + hierarchy_str += ( + f"{indent} {str(sub_bank[0])}||{str(sub_bank[1])}|{str(sub_bank[2])}\n" + ) + hierarchy_str = print_parsable_hierarchy( + cur, sub_bank[0], hierarchy_str, indent + " " + ) + + return hierarchy_str + + ############################################################### # # # Subcommand Functions # @@ -229,7 +261,7 @@ def add_bank(conn, bank, shares, parent_bank=""): raise sqlite3.IntegrityError(f"bank {bank} already exists in bank_table") -def view_bank(conn, bank, tree=False, users=False): +def view_bank(conn, bank, tree=False, users=False, parsable=False): cur = conn.cursor() bank_str = "" try: @@ -241,18 +273,18 @@ def view_bank(conn, bank, tree=False, users=False): else: raise ValueError(f"bank {bank} not found in bank_table") - # print out the hierarchy view with the specified bank as the root of the tree - if tree is True: - # get specific information about bank passed in - cur.execute( - "SELECT bank,shares,job_usage FROM bank_table WHERE bank=?", (bank,) - ) - parent_bank = cur.fetchall() - name = parent_bank[0][0] - shares = parent_bank[0][1] - usage = parent_bank[0][2] + name = result[0][1] + shares = result[0][4] + usage = result[0][5] - # create headers for the hierarchy string + if parsable is True: + # print out the database hierarchy starting with the bank passed in + hierarchy_str = "Bank|Username|RawShares|RawUsage|Fairshare\n" + hierarchy_str += f"{name}||{str(shares)}|{str(round(usage, 2))}\n" + hierarchy_str = print_parsable_hierarchy(cur, bank, hierarchy_str, "") + return hierarchy_str + if tree is True: + # print out the hierarchy view with the specified bank as the root of the tree hierarchy_str = ( "Bank".ljust(20) + "Username".rjust(20) diff --git a/src/cmd/flux-account-service.py b/src/cmd/flux-account-service.py index 140b01efc..2d3f3ee87 100755 --- a/src/cmd/flux-account-service.py +++ b/src/cmd/flux-account-service.py @@ -242,6 +242,7 @@ def view_bank(self, handle, watcher, msg, arg): msg.payload["bank"], msg.payload["tree"], msg.payload["users"], + msg.payload["parsable"], ) payload = {"view_bank": val} diff --git a/src/cmd/flux-account.py b/src/cmd/flux-account.py index 6dffe14a1..c68a8f36c 100755 --- a/src/cmd/flux-account.py +++ b/src/cmd/flux-account.py @@ -297,6 +297,14 @@ def add_view_bank_arg(subparsers): help="list all potential users under bank", metavar="USERS", ) + subparser_view_bank.add_argument( + "-P", + "--parsable", + action="store_const", + const=True, + help="list all sub banks in a parsable format with specified bank as root of tree", + metavar="PARSABLE", + ) def add_delete_bank_arg(subparsers): @@ -617,6 +625,7 @@ def select_accounting_function(args, output_file, parser): "bank": args.bank, "tree": args.tree, "users": args.users, + "parsable": args.parsable, } return_val = flux.Flux().rpc("accounting.view_bank", data).get() elif args.func == "delete_bank": From 81d30854ba7e1ccbda6159ed32960ab89a0f4f20 Mon Sep 17 00:00:00 2001 From: cmoussa1 Date: Mon, 29 Jul 2024 08:33:47 -0700 Subject: [PATCH 2/4] t: break up t1000 into separate files Problem: flux-accounting has two identical ways to print out the hierarchy of its accounting database: the flux account-shares command (a .cpp file) and an optional argument passed into the "view-bank" command. It would be less confusing to have two different options that do the same thing, especially since the .cpp file requires a dash '-' in between "account" and "shares", which doesn't match the rest of the flux-accounting commands. Convert the sharness tests in t1000-print-hierarchy.t into multiple, smaller sets of tests. Use the "-t" option from the "view-bank" command instead of calling "flux account-shares". Since the "-t" optional argument in the "view-bank" command prints job usage values with more precision, edit the expected files to match this precision. --- t/Makefile.am | 4 +- t/expected/print_hierarchy/small_no_tie.txt | 28 +-- .../print_hierarchy/small_no_tie_parsable.txt | 25 +-- t/expected/print_hierarchy/small_tie.txt | 30 ++-- t/expected/print_hierarchy/small_tie_all.txt | 32 ++-- .../small_tie_all_parsable.txt | 29 +-- .../print_hierarchy/small_tie_parsable.txt | 27 +-- t/t1000-print-hierarchy.t | 168 ------------------ t/t1036-hierarchy-small-no-tie-db.t | 69 +++++++ t/t1037-hierarchy-small-tie-db.t | 70 ++++++++ t/t1038-hierarchy-small-tie-all-db.t | 73 ++++++++ 11 files changed, 308 insertions(+), 247 deletions(-) delete mode 100755 t/t1000-print-hierarchy.t create mode 100755 t/t1036-hierarchy-small-no-tie-db.t create mode 100755 t/t1037-hierarchy-small-tie-db.t create mode 100755 t/t1038-hierarchy-small-tie-all-db.t diff --git a/t/Makefile.am b/t/Makefile.am index c3b30f007..55c6dd9f8 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -1,7 +1,6 @@ # This list is included in both TESTS and dist_check_SCRIPTS. TESTSCRIPTS = \ t0000-sharness.t \ - t1000-print-hierarchy.t \ t1001-mf-priority-basic.t \ t1002-mf-priority-small-no-tie.t \ t1003-mf-priority-small-tie.t \ @@ -36,6 +35,9 @@ TESTSCRIPTS = \ t1033-mf-priority-update-job.t \ t1034-mf-priority-config.t \ t1035-flux-account-scrub-old-jobs.t \ + t1036-hierarchy-small-no-tie-db.t \ + t1037-hierarchy-small-tie-db.t \ + t1038-hierarchy-small-tie-all-db.t \ t5000-valgrind.t \ python/t1000-example.py \ python/t1001_db.py \ diff --git a/t/expected/print_hierarchy/small_no_tie.txt b/t/expected/print_hierarchy/small_no_tie.txt index b336f46db..f7c6165b0 100644 --- a/t/expected/print_hierarchy/small_no_tie.txt +++ b/t/expected/print_hierarchy/small_no_tie.txt @@ -1,12 +1,16 @@ -Account Username RawShares RawUsage Fairshare -root 1000 133 - account1 1000 121 - account1 leaf.1.1 10000 100 0.285714 - account1 leaf.1.2 1000 11 0.142857 - account1 leaf.1.3 100000 10 0.428571 - account2 100 11 - account2 leaf.2.1 100000 8 0.714286 - account2 leaf.2.2 10000 3 0.571429 - account3 10 1 - account3 leaf.3.1 100 0 1 - account3 leaf.3.2 10 1 0.857143 +bank_id bank active parent_bank shares job_usage +1 root 1 1000 133.0 + +Bank Username RawShares RawUsage Fairshare +root 1000 133.0 + account1 1000 121.0 + account1 leaf.1.1 10000 100.0 0.285714 + account1 leaf.1.2 1000 11.0 0.142857 + account1 leaf.1.3 100000 10.0 0.428571 + account2 100 11.0 + account2 leaf.2.1 100000 8.0 0.714286 + account2 leaf.2.2 10000 3.0 0.571429 + account3 10 1.0 + account3 leaf.3.1 100 0.0 1.0 + account3 leaf.3.2 10 1.0 0.857143 + diff --git a/t/expected/print_hierarchy/small_no_tie_parsable.txt b/t/expected/print_hierarchy/small_no_tie_parsable.txt index eb7b3b77a..3f5aa490b 100644 --- a/t/expected/print_hierarchy/small_no_tie_parsable.txt +++ b/t/expected/print_hierarchy/small_no_tie_parsable.txt @@ -1,12 +1,13 @@ -Account|Username|RawShares|RawUsage|Fairshare -root||1000|133 - account1||1000|121 - account1|leaf.1.1|10000|100|0.285714 - account1|leaf.1.2|1000|11|0.142857 - account1|leaf.1.3|100000|10|0.428571 - account2||100|11 - account2|leaf.2.1|100000|8|0.714286 - account2|leaf.2.2|10000|3|0.571429 - account3||10|1 - account3|leaf.3.1|100|0|1 - account3|leaf.3.2|10|1|0.857143 +Bank|Username|RawShares|RawUsage|Fairshare +root||1000|133.0 + account1||1000|121.0 + account1|leaf.1.1|10000|100.0|0.285714 + account1|leaf.1.2|1000|11.0|0.142857 + account1|leaf.1.3|100000|10.0|0.428571 + account2||100|11.0 + account2|leaf.2.1|100000|8.0|0.714286 + account2|leaf.2.2|10000|3.0|0.571429 + account3||10|1.0 + account3|leaf.3.1|100|0.0|1.0 + account3|leaf.3.2|10|1.0|0.857143 + diff --git a/t/expected/print_hierarchy/small_tie.txt b/t/expected/print_hierarchy/small_tie.txt index 1cfc0e44e..382c3a213 100644 --- a/t/expected/print_hierarchy/small_tie.txt +++ b/t/expected/print_hierarchy/small_tie.txt @@ -1,13 +1,17 @@ -Account Username RawShares RawUsage Fairshare -root 1000 133 - account1 1000 120 - account1 leaf.1.1 10000 100 0.5 - account1 leaf.1.2 1000 10 0.5 - account1 leaf.1.3 100000 10 0.75 - account2 100 12 - account2 leaf.2.1 10000 10 0.5 - account2 leaf.2.2 1000 1 0.5 - account2 leaf.2.3 100000 1 0.75 - account3 10 1 - account3 leaf.3.1 100 0 1 - account3 leaf.3.2 10 1 0.875 +bank_id bank active parent_bank shares job_usage +1 root 1 1000 133.0 + +Bank Username RawShares RawUsage Fairshare +root 1000 133.0 + account1 1000 120.0 + account1 leaf.1.1 10000 100.0 0.5 + account1 leaf.1.2 1000 10.0 0.5 + account1 leaf.1.3 100000 10.0 0.75 + account2 100 12.0 + account2 leaf.2.1 10000 10.0 0.5 + account2 leaf.2.2 1000 1.0 0.5 + account2 leaf.2.3 100000 1.0 0.75 + account3 10 1.0 + account3 leaf.3.1 100 0.0 1.0 + account3 leaf.3.2 10 1.0 0.875 + diff --git a/t/expected/print_hierarchy/small_tie_all.txt b/t/expected/print_hierarchy/small_tie_all.txt index f0e401882..5d40fd21b 100644 --- a/t/expected/print_hierarchy/small_tie_all.txt +++ b/t/expected/print_hierarchy/small_tie_all.txt @@ -1,14 +1,18 @@ -Account Username RawShares RawUsage Fairshare -root 1000 1332 - account1 1000 120 - account1 leaf.1.1 10000 100 0.666667 - account1 leaf.1.2 1000 10 0.666667 - account1 leaf.1.3 100000 10 1 - account2 100 12 - account2 leaf.2.1 10000 10 0.666667 - account2 leaf.2.2 1000 1 0.666667 - account2 leaf.2.3 100000 1 1 - account3 10000 1200 - account3 leaf.3.1 10000 1000 0.666667 - account3 leaf.3.2 1000 100 0.666667 - account3 leaf.3.3 100000 100 1 +bank_id bank active parent_bank shares job_usage +1 root 1 1000 1332.0 + +Bank Username RawShares RawUsage Fairshare +root 1000 1332.0 + account1 1000 120.0 + account1 leaf.1.1 10000 100.0 0.666667 + account1 leaf.1.2 1000 10.0 0.666667 + account1 leaf.1.3 100000 10.0 1.0 + account2 100 12.0 + account2 leaf.2.1 10000 10.0 0.666667 + account2 leaf.2.2 1000 1.0 0.666667 + account2 leaf.2.3 100000 1.0 1.0 + account3 10000 1200.0 + account3 leaf.3.1 10000 1000.0 0.666667 + account3 leaf.3.2 1000 100.0 0.666667 + account3 leaf.3.3 100000 100.0 1.0 + diff --git a/t/expected/print_hierarchy/small_tie_all_parsable.txt b/t/expected/print_hierarchy/small_tie_all_parsable.txt index ddeeb5362..25f06f48e 100644 --- a/t/expected/print_hierarchy/small_tie_all_parsable.txt +++ b/t/expected/print_hierarchy/small_tie_all_parsable.txt @@ -1,14 +1,15 @@ -Account|Username|RawShares|RawUsage|Fairshare -root||1000|1332 - account1||1000|120 - account1|leaf.1.1|10000|100|0.666667 - account1|leaf.1.2|1000|10|0.666667 - account1|leaf.1.3|100000|10|1 - account2||100|12 - account2|leaf.2.1|10000|10|0.666667 - account2|leaf.2.2|1000|1|0.666667 - account2|leaf.2.3|100000|1|1 - account3||10000|1200 - account3|leaf.3.1|10000|1000|0.666667 - account3|leaf.3.2|1000|100|0.666667 - account3|leaf.3.3|100000|100|1 +Bank|Username|RawShares|RawUsage|Fairshare +root||1000|1332.0 + account1||1000|120.0 + account1|leaf.1.1|10000|100.0|0.666667 + account1|leaf.1.2|1000|10.0|0.666667 + account1|leaf.1.3|100000|10.0|1.0 + account2||100|12.0 + account2|leaf.2.1|10000|10.0|0.666667 + account2|leaf.2.2|1000|1.0|0.666667 + account2|leaf.2.3|100000|1.0|1.0 + account3||10000|1200.0 + account3|leaf.3.1|10000|1000.0|0.666667 + account3|leaf.3.2|1000|100.0|0.666667 + account3|leaf.3.3|100000|100.0|1.0 + diff --git a/t/expected/print_hierarchy/small_tie_parsable.txt b/t/expected/print_hierarchy/small_tie_parsable.txt index a9b2f74f1..f5ca378fb 100644 --- a/t/expected/print_hierarchy/small_tie_parsable.txt +++ b/t/expected/print_hierarchy/small_tie_parsable.txt @@ -1,13 +1,14 @@ -Account|Username|RawShares|RawUsage|Fairshare -root||1000|133 - account1||1000|120 - account1|leaf.1.1|10000|100|0.5 - account1|leaf.1.2|1000|10|0.5 - account1|leaf.1.3|100000|10|0.75 - account2||100|12 - account2|leaf.2.1|10000|10|0.5 - account2|leaf.2.2|1000|1|0.5 - account2|leaf.2.3|100000|1|0.75 - account3||10|1 - account3|leaf.3.1|100|0|1 - account3|leaf.3.2|10|1|0.875 +Bank|Username|RawShares|RawUsage|Fairshare +root||1000|133.0 + account1||1000|120.0 + account1|leaf.1.1|10000|100.0|0.5 + account1|leaf.1.2|1000|10.0|0.5 + account1|leaf.1.3|100000|10.0|0.75 + account2||100|12.0 + account2|leaf.2.1|10000|10.0|0.5 + account2|leaf.2.2|1000|1.0|0.5 + account2|leaf.2.3|100000|1.0|0.75 + account3||10|1.0 + account3|leaf.3.1|100|0.0|1.0 + account3|leaf.3.2|10|1.0|0.875 + diff --git a/t/t1000-print-hierarchy.t b/t/t1000-print-hierarchy.t deleted file mode 100755 index a3c2729cd..000000000 --- a/t/t1000-print-hierarchy.t +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/bash - -test_description='Test print-hierarchy command' - -. `dirname $0`/sharness.sh - -EXPECTED_FILES=${SHARNESS_TEST_SRCDIR}/expected/print_hierarchy -SMALL_NO_TIE=${SHARNESS_TEST_SRCDIR}/expected/test_dbs/small_no_tie.db -SMALL_TIE=${SHARNESS_TEST_SRCDIR}/expected/test_dbs/small_tie.db -SMALL_TIE_ALL=${SHARNESS_TEST_SRCDIR}/expected/test_dbs/small_tie_all.db -OUT_OF_INSERT_ORDER=${SHARNESS_TEST_SRCDIR}/expected/test_dbs/out_of_insert_order.db -DB_PATH=$(pwd)/FluxAccountingTestHierarchy.db - -export TEST_UNDER_FLUX_NO_JOB_EXEC=y -export TEST_UNDER_FLUX_SCHED_SIMPLE_MODE="limited=1" -test_under_flux 1 job - -flux setattr log-stderr-level 1 - -test_expect_success 'create flux-accounting DB' ' - flux account -p $(pwd)/FluxAccountingTestHierarchy.db create-db -' - -test_expect_success 'start flux-accounting service' ' - flux account-service -p ${DB_PATH} -t -' - -test_expect_success 'create hierarchy output from C++ - small_no_tie.db' ' - flux account-shares -p ${SMALL_NO_TIE} > test_small_no_tie.txt -' - -test_expect_success 'compare hierarchy outputs - small_no_tie.db' ' - test_cmp ${EXPECTED_FILES}/small_no_tie.txt test_small_no_tie.txt -' - -test_expect_success 'create hierarchy output from C++ - small_tie.db' ' - flux account-shares -p ${SMALL_TIE} > test_small_tie.txt -' - -test_expect_success 'compare hierarchy outputs - small_tie.db' ' - test_cmp ${EXPECTED_FILES}/small_tie.txt test_small_tie.txt -' - -test_expect_success 'create hierarchy output from C++ - small_tie_all.db' ' - flux account-shares -p ${SMALL_TIE_ALL} > test_small_tie_all.txt -' - -test_expect_success 'compare hierarchy outputs - small_tie_all.db' ' - test_cmp ${EXPECTED_FILES}/small_tie_all.txt test_small_tie_all.txt -' - -test_expect_success 'create parsable hierarchy output from C++ - small_no_tie.db' ' - flux account-shares -P "|" -p ${SMALL_NO_TIE} > test_small_no_tie_parsable.txt -' - -test_expect_success 'compare parsable hierarchy outputs - small_no_tie.db' ' - test_cmp ${EXPECTED_FILES}/small_no_tie_parsable.txt test_small_no_tie_parsable.txt -' - -test_expect_success 'create parsable hierarchy output from C++ - small_tie.db' ' - flux account-shares -P "|" -p ${SMALL_TIE} > test_small_tie_parsable.txt -' - -test_expect_success 'compare parsable hierarchy outputs - small_tie.db' ' - test_cmp ${EXPECTED_FILES}/small_tie_parsable.txt test_small_tie_parsable.txt -' - -test_expect_success 'create parsable hierarchy output from C++ - small_tie_all.db' ' - flux account-shares -P "|" -p ${SMALL_TIE_ALL} > test_small_tie_all_parsable.txt -' - -test_expect_success 'compare parsable hierarchy outputs - small_tie_all.db' ' - test_cmp ${EXPECTED_FILES}/small_tie_all_parsable.txt test_small_tie_all_parsable.txt -' - -test_expect_success 'create custom parsable hierarchy output from C++ - small_tie.db' ' - flux account-shares -P , -p ${SMALL_TIE} > test_custom_small_tie_parsable.txt -' - -test_expect_success 'compare custom parsable hierarchy outputs - small_tie_all.db' ' - test_cmp ${EXPECTED_FILES}/custom_small_tie_parsable.txt test_custom_small_tie_parsable.txt -' - -test_expect_success 'output help message for flux-shares' ' - flux account-shares -h > test_help_message.txt -' - -test_expect_success 'compare help message for flux-shares' ' - test_cmp ${EXPECTED_FILES}/help_message.txt test_help_message.txt -' - -test_expect_failure 'output help message for flux-shares when a bad argument is passed in' ' - flux account-shares --bad-arg > test_bad_argument.txt -' - -test_expect_success 'compare help message for flux-shares when a bad argument is passed in' ' - test_cmp ${EXPECTED_FILES}/help_message.txt test_bad_argument.txt -' - -test_expect_success 'create hierarchy output from C++ - out_of_insert_order.db' ' - flux account-shares -p ${OUT_OF_INSERT_ORDER} > test_out_of_insert_order.txt -' - -test_expect_success 'compare hierarchy outputs - out_of_insert_order.db' ' - test_cmp ${EXPECTED_FILES}/out_of_insert_order.txt test_out_of_insert_order.txt -' - -test_expect_success 'add some banks and users' ' - flux account add-bank root 1 && - flux account add-bank --parent-bank=root A 1 && - flux account add-bank --parent-bank=root B 1 && - flux account add-bank --parent-bank=root C 1 && - flux account add-user --username=user5011 --userid=5011 --bank=A && - flux account add-user --username=user5012 --userid=5012 --bank=A && - flux account add-user --username=user5013 --userid=5013 --bank=B && - flux account add-user --username=user5014 --userid=5014 --bank=C -' - -test_expect_success 'print hierarchy' ' - flux account-shares -p ${DB_PATH} > before_delete.test && - test_cmp ${EXPECTED_FILES}/before_delete.expected before_delete.test -' - -test_expect_success 'delete a user' ' - flux account delete-user user5012 A -' - -test_expect_success 'print hierarchy again and check that deleted user does not show up in hierarchy' ' - flux account-shares -p ${DB_PATH} > after_delete.test && - test_cmp ${EXPECTED_FILES}/after_delete.expected after_delete.test -' - -test_expect_success 'delete a bank' ' - flux account delete-bank A -' - -test_expect_success 'print hierarchy again and check that deleted bank or users do not show up in hierarchy' ' - flux account-shares -p ${DB_PATH} > after_bank_delete.test && - test_cmp ${EXPECTED_FILES}/after_bank_delete.expected after_bank_delete.test -' - -test_expect_success 'add some sub banks and some users' ' - flux account add-bank --parent-bank=root D 1 && - flux account add-bank --parent-bank=root E 1 && - flux account add-bank --parent-bank=D F 1 && - flux account add-user --username=user1001 --userid=1001 --bank=F && - flux account add-user --username=user1002 --userid=1002 --bank=F -' - -test_expect_success 'check hierarchy before changing parent bank of F' ' - flux account-shares -p ${DB_PATH} > before_parent_bank_change.test && - test_cmp ${EXPECTED_FILES}/before_parent_bank_change.expected before_parent_bank_change.test -' - -test_expect_success 'change parent bank of F' ' - flux account edit-bank F --parent-bank=E -' - -test_expect_success 'check hierarchy after changing parent bank of F' ' - flux account-shares -p ${DB_PATH} > after_parent_bank_change.test && - test_cmp ${EXPECTED_FILES}/after_parent_bank_change.expected after_parent_bank_change.test -' - -test_expect_success 'shut down flux-accounting service' ' - flux python -c "import flux; flux.Flux().rpc(\"accounting.shutdown_service\").get()" -' - -test_done diff --git a/t/t1036-hierarchy-small-no-tie-db.t b/t/t1036-hierarchy-small-no-tie-db.t new file mode 100755 index 000000000..8c174ea41 --- /dev/null +++ b/t/t1036-hierarchy-small-no-tie-db.t @@ -0,0 +1,69 @@ +#!/bin/bash + +test_description='test printing the DB hierarchy with no job usage ties' + +. `dirname $0`/sharness.sh +SMALL_NO_TIE=$(pwd)/small_no_tie.db + +EXPECTED_FILES=${SHARNESS_TEST_SRCDIR}/expected/print_hierarchy +UPDATE_USAGE=${SHARNESS_TEST_SRCDIR}/scripts/update_usage_column.py + +export TEST_UNDER_FLUX_NO_JOB_EXEC=y +export TEST_UNDER_FLUX_SCHED_SIMPLE_MODE="limited=1" +test_under_flux 1 job + +flux setattr log-stderr-level 1 + +test_expect_success 'create small_no_tie flux-accounting DB' ' + flux account -p ${SMALL_NO_TIE} create-db +' + +test_expect_success 'start flux-accounting service on small_no_tie DB' ' + flux account-service -p ${SMALL_NO_TIE} -t +' + +test_expect_success 'add users/banks to DB' ' + flux account add-bank root 1000 && + flux account add-bank --parent-bank root account1 1000 && + flux account add-bank --parent-bank root account2 100 && + flux account add-bank --parent-bank root account3 10 && + flux account add-user --username leaf.1.1 --bank account1 --shares 10000 && + flux account add-user --username leaf.1.2 --bank account1 --shares 1000 && + flux account add-user --username leaf.1.3 --bank account1 --shares 100000 && + flux account add-user --username leaf.2.1 --bank account2 --shares 100000 && + flux account add-user --username leaf.2.2 --bank account2 --shares 10000 && + flux account add-user --username leaf.3.1 --bank account3 --shares 100 && + flux account add-user --username leaf.3.2 --bank account3 --shares 10 +' + +test_expect_success 'update usage and fair-share for the users/banks' ' + flux python ${UPDATE_USAGE} ${SMALL_NO_TIE} leaf.1.1 100 && + flux python ${UPDATE_USAGE} ${SMALL_NO_TIE} leaf.1.2 11 && + flux python ${UPDATE_USAGE} ${SMALL_NO_TIE} leaf.1.3 10 && + flux python ${UPDATE_USAGE} ${SMALL_NO_TIE} leaf.2.1 8 && + flux python ${UPDATE_USAGE} ${SMALL_NO_TIE} leaf.2.2 3 && + flux python ${UPDATE_USAGE} ${SMALL_NO_TIE} leaf.3.1 0 && + flux python ${UPDATE_USAGE} ${SMALL_NO_TIE} leaf.3.2 1 && + flux account update-usage && + flux account-update-fshare -p ${SMALL_NO_TIE} +' + +test_expect_success 'view database hierarchy' ' + flux account view-bank -t root > small_no_tie.test && + test_cmp ${EXPECTED_FILES}/small_no_tie.txt small_no_tie.test +' + +test_expect_success 'view database hierarchy in a parseable format' ' + flux account view-bank -P root > small_no_tie_parsable.test && + test_cmp ${EXPECTED_FILES}/small_no_tie_parsable.txt small_no_tie_parsable.test +' + +test_expect_success 'remove flux-accounting DB' ' + rm ${SMALL_NO_TIE} +' + +test_expect_success 'shut down flux-accounting service' ' + flux python -c "import flux; flux.Flux().rpc(\"accounting.shutdown_service\").get()" +' + +test_done diff --git a/t/t1037-hierarchy-small-tie-db.t b/t/t1037-hierarchy-small-tie-db.t new file mode 100755 index 000000000..9e7ec0cfa --- /dev/null +++ b/t/t1037-hierarchy-small-tie-db.t @@ -0,0 +1,70 @@ +#!/bin/bash + +test_description='test printing the DB hierarchy with some job usage ties' + +. `dirname $0`/sharness.sh +SMALL_TIE=$(pwd)/small_tie.db + +EXPECTED_FILES=${SHARNESS_TEST_SRCDIR}/expected/print_hierarchy +UPDATE_USAGE=${SHARNESS_TEST_SRCDIR}/scripts/update_usage_column.py + +export TEST_UNDER_FLUX_NO_JOB_EXEC=y +export TEST_UNDER_FLUX_SCHED_SIMPLE_MODE="limited=1" +test_under_flux 1 job + +flux setattr log-stderr-level 1 + +test_expect_success 'create small_no_tie flux-accounting DB' ' + flux account -p ${SMALL_TIE} create-db +' + +test_expect_success 'start flux-accounting service on small_no_tie DB' ' + flux account-service -p ${SMALL_TIE} -t +' + +test_expect_success 'add users/banks to DB' ' + flux account add-bank root 1000 && + flux account add-bank --parent-bank root account1 1000 && + flux account add-bank --parent-bank root account2 100 && + flux account add-bank --parent-bank root account3 10 && + flux account add-user --username leaf.1.1 --bank account1 --shares 10000 && + flux account add-user --username leaf.1.2 --bank account1 --shares 1000 && + flux account add-user --username leaf.1.3 --bank account1 --shares 100000 && + flux account add-user --username leaf.2.1 --bank account2 --shares 10000 && + flux account add-user --username leaf.2.2 --bank account2 --shares 1000 && + flux account add-user --username leaf.2.3 --bank account2 --shares 100000 && + flux account add-user --username leaf.3.1 --bank account3 --shares 100 && + flux account add-user --username leaf.3.2 --bank account3 --shares 10 +' + +test_expect_success 'update usage and fair-share for the users/banks' ' + flux python ${UPDATE_USAGE} ${SMALL_TIE} leaf.1.1 100 && + flux python ${UPDATE_USAGE} ${SMALL_TIE} leaf.1.2 10 && + flux python ${UPDATE_USAGE} ${SMALL_TIE} leaf.1.3 10 && + flux python ${UPDATE_USAGE} ${SMALL_TIE} leaf.2.1 10 && + flux python ${UPDATE_USAGE} ${SMALL_TIE} leaf.2.2 1 && + flux python ${UPDATE_USAGE} ${SMALL_TIE} leaf.2.3 1 && + flux python ${UPDATE_USAGE} ${SMALL_TIE} leaf.3.2 1 && + flux account update-usage && + flux account-update-fshare -p ${SMALL_TIE} +' + +test_expect_success 'view database hierarchy' ' + flux account view-bank -t root > small_tie.test && + test_cmp ${EXPECTED_FILES}/small_tie.txt small_tie.test +' + +test_expect_success 'view database hierarchy in a parseable format' ' + flux account view-bank -P root > small_tie_parsable.test && + test_cmp ${EXPECTED_FILES}/small_tie_parsable.txt small_tie_parsable.test +' + +test_expect_success 'remove flux-accounting DB' ' + rm ${SMALL_TIE} +' + +test_expect_success 'shut down flux-accounting service' ' + flux python -c "import flux; flux.Flux().rpc(\"accounting.shutdown_service\").get()" +' + +test_done diff --git a/t/t1038-hierarchy-small-tie-all-db.t b/t/t1038-hierarchy-small-tie-all-db.t new file mode 100755 index 000000000..910767d6d --- /dev/null +++ b/t/t1038-hierarchy-small-tie-all-db.t @@ -0,0 +1,73 @@ +#!/bin/bash + +test_description='test printing the DB hierarchy with all job usage ties' + +. `dirname $0`/sharness.sh +SMALL_TIE_ALL=$(pwd)/small_tie_all.db + +EXPECTED_FILES=${SHARNESS_TEST_SRCDIR}/expected/print_hierarchy +UPDATE_USAGE=${SHARNESS_TEST_SRCDIR}/scripts/update_usage_column.py + +export TEST_UNDER_FLUX_NO_JOB_EXEC=y +export TEST_UNDER_FLUX_SCHED_SIMPLE_MODE="limited=1" +test_under_flux 1 job + +flux setattr log-stderr-level 1 + +test_expect_success 'create small_no_tie flux-accounting DB' ' + flux account -p ${SMALL_TIE_ALL} create-db +' + +test_expect_success 'start flux-accounting service on small_no_tie DB' ' + flux account-service -p ${SMALL_TIE_ALL} -t +' + +test_expect_success 'add users/banks to DB' ' + flux account add-bank root 1000 && + flux account add-bank --parent-bank root account1 1000 && + flux account add-bank --parent-bank root account2 100 && + flux account add-bank --parent-bank root account3 10000 && + flux account add-user --username leaf.1.1 --bank account1 --shares 10000 && + flux account add-user --username leaf.1.2 --bank account1 --shares 1000 && + flux account add-user --username leaf.1.3 --bank account1 --shares 100000 && + flux account add-user --username leaf.2.1 --bank account2 --shares 10000 && + flux account add-user --username leaf.2.2 --bank account2 --shares 1000 && + flux account add-user --username leaf.2.3 --bank account2 --shares 100000 && + flux account add-user --username leaf.3.1 --bank account3 --shares 10000 && + flux account add-user --username leaf.3.2 --bank account3 --shares 1000 && + flux account add-user --username leaf.3.3 --bank account3 --shares 100000 +' + +test_expect_success 'update usage and fair-share for the users/banks' ' + flux python ${UPDATE_USAGE} ${SMALL_TIE_ALL} leaf.1.1 100 && + flux python ${UPDATE_USAGE} ${SMALL_TIE_ALL} leaf.1.2 10 && + flux python ${UPDATE_USAGE} ${SMALL_TIE_ALL} leaf.1.3 10 && + flux python ${UPDATE_USAGE} ${SMALL_TIE_ALL} leaf.2.1 10 && + flux python ${UPDATE_USAGE} ${SMALL_TIE_ALL} leaf.2.2 1 && + flux python ${UPDATE_USAGE} ${SMALL_TIE_ALL} leaf.2.3 1 && + flux python ${UPDATE_USAGE} ${SMALL_TIE_ALL} leaf.3.1 1000 && + flux python ${UPDATE_USAGE} ${SMALL_TIE_ALL} leaf.3.2 100 && + flux python ${UPDATE_USAGE} ${SMALL_TIE_ALL} leaf.3.3 100 && + flux account update-usage && + flux account-update-fshare -p ${SMALL_TIE_ALL} +' + +test_expect_success 'view database hierarchy' ' + flux account view-bank -t root > small_tie_all.test && + test_cmp ${EXPECTED_FILES}/small_tie_all.txt small_tie_all.test +' + +test_expect_success 'view database hierarchy in a parseable format' ' + flux account view-bank -P root > small_tie_all_parsable.test && + test_cmp ${EXPECTED_FILES}/small_tie_all_parsable.txt small_tie_all_parsable.test +' + +test_expect_success 'remove flux-accounting DB' ' + rm ${SMALL_TIE_ALL} +' + +test_expect_success 'shut down flux-accounting service' ' + flux python -c "import flux; flux.Flux().rpc(\"accounting.shutdown_service\").get()" +' + +test_done From 65963f7c8d7d0086e1165fe41019b394ce1c1640 Mon Sep 17 00:00:00 2001 From: cmoussa1 Date: Mon, 29 Jul 2024 08:39:38 -0700 Subject: [PATCH 3/4] t: use "-t" option of view-bank Problem: There are a couple of instances throughout the testsuite that call "flux account-shares", but there is a cleaner option to just use the "-t" optional argument from the "view-bank" command. Convert the calls from "flux account-shares" to just use "view-bank -t". Edit the expected files in the testsuite to account for the precision that "view-bank -t" includes in its output of the database hierarchy. --- t/expected/pop_db/db_hierarchy_base.expected | 26 ++++++++------ .../pop_db/db_hierarchy_new_users.expected | 36 ++++++++++--------- .../update_fshare/post_fshare_update.expected | 28 ++++++++------- .../update_fshare/pre_fshare_update.expected | 28 ++++++++------- t/t1006-update-fshare.t | 18 ++++++++-- t/t1009-pop-db.t | 4 +-- t/t1011-job-archive-interface.t | 2 +- t/t1016-export-db.t | 18 ++++++++-- 8 files changed, 101 insertions(+), 59 deletions(-) diff --git a/t/expected/pop_db/db_hierarchy_base.expected b/t/expected/pop_db/db_hierarchy_base.expected index 7094fb6e1..c3cfb42d5 100644 --- a/t/expected/pop_db/db_hierarchy_base.expected +++ b/t/expected/pop_db/db_hierarchy_base.expected @@ -1,11 +1,15 @@ -Account Username RawShares RawUsage Fairshare -root 1 0 - A 1 0 - A user1000 1 0 0.5 - A user1001 1 0 0.5 - A user1002 1 0 0.5 - A user1003 1 0 0.5 - A user1004 1 0 0.5 - B 1 0 - C 1 0 - D 1 0 +bank_id bank active parent_bank shares job_usage +1 root 1 1 0.0 + +Bank Username RawShares RawUsage Fairshare +root 1 0.0 + A 1 0.0 + A user1000 1 0.0 0.5 + A user1001 1 0.0 0.5 + A user1002 1 0.0 0.5 + A user1003 1 0.0 0.5 + A user1004 1 0.0 0.5 + B 1 0.0 + C 1 0.0 + D 1 0.0 + diff --git a/t/expected/pop_db/db_hierarchy_new_users.expected b/t/expected/pop_db/db_hierarchy_new_users.expected index 720b2a5e6..3a4c0e68a 100644 --- a/t/expected/pop_db/db_hierarchy_new_users.expected +++ b/t/expected/pop_db/db_hierarchy_new_users.expected @@ -1,16 +1,20 @@ -Account Username RawShares RawUsage Fairshare -root 1 0 - A 1 0 - A user1000 1 0 0.5 - A user1001 1 0 0.5 - A user1002 1 0 0.5 - A user1003 1 0 0.5 - A user1004 1 0 0.5 - B 1 0 - B user1005 1 0 0.5 - B user1006 1 0 0.5 - B user1007 1 0 0.5 - B user1008 1 0 0.5 - B user1009 1 0 0.5 - C 1 0 - D 1 0 +bank_id bank active parent_bank shares job_usage +1 root 1 1 0.0 + +Bank Username RawShares RawUsage Fairshare +root 1 0.0 + A 1 0.0 + A user1000 1 0.0 0.5 + A user1001 1 0.0 0.5 + A user1002 1 0.0 0.5 + A user1003 1 0.0 0.5 + A user1004 1 0.0 0.5 + B 1 0.0 + B user1005 1 0.0 0.5 + B user1006 1 0.0 0.5 + B user1007 1 0.0 0.5 + B user1008 1 0.0 0.5 + B user1009 1 0.0 0.5 + C 1 0.0 + D 1 0.0 + diff --git a/t/expected/update_fshare/post_fshare_update.expected b/t/expected/update_fshare/post_fshare_update.expected index ee7e24703..51479e108 100644 --- a/t/expected/update_fshare/post_fshare_update.expected +++ b/t/expected/update_fshare/post_fshare_update.expected @@ -1,12 +1,16 @@ -Account Username RawShares RawUsage Fairshare -root 1000 180 - account1 1000 121 - account1 leaf.1.1 10000 100 0.571429 - account1 leaf.1.2 1000 11 0.428571 - account1 leaf.1.3 100000 10 0.714286 - account2 100 58 - account2 leaf.2.1 100000 55 0.142857 - account2 leaf.2.2 10000 3 0.285714 - account3 10 1 - account3 leaf.3.1 100 0 1 - account3 leaf.3.2 10 1 0.857143 +bank_id bank active parent_bank shares job_usage +1 root 1 1000 180.0 + +Bank Username RawShares RawUsage Fairshare +root 1000 180.0 + account1 1000 121.0 + account1 leaf.1.1 10000 100.0 0.571429 + account1 leaf.1.2 1000 11.0 0.428571 + account1 leaf.1.3 100000 10.0 0.714286 + account2 100 58.0 + account2 leaf.2.1 100000 55.0 0.142857 + account2 leaf.2.2 10000 3.0 0.285714 + account3 10 1.0 + account3 leaf.3.1 100 0.0 1.0 + account3 leaf.3.2 10 1.0 0.857143 + diff --git a/t/expected/update_fshare/pre_fshare_update.expected b/t/expected/update_fshare/pre_fshare_update.expected index b336f46db..f7c6165b0 100644 --- a/t/expected/update_fshare/pre_fshare_update.expected +++ b/t/expected/update_fshare/pre_fshare_update.expected @@ -1,12 +1,16 @@ -Account Username RawShares RawUsage Fairshare -root 1000 133 - account1 1000 121 - account1 leaf.1.1 10000 100 0.285714 - account1 leaf.1.2 1000 11 0.142857 - account1 leaf.1.3 100000 10 0.428571 - account2 100 11 - account2 leaf.2.1 100000 8 0.714286 - account2 leaf.2.2 10000 3 0.571429 - account3 10 1 - account3 leaf.3.1 100 0 1 - account3 leaf.3.2 10 1 0.857143 +bank_id bank active parent_bank shares job_usage +1 root 1 1000 133.0 + +Bank Username RawShares RawUsage Fairshare +root 1000 133.0 + account1 1000 121.0 + account1 leaf.1.1 10000 100.0 0.285714 + account1 leaf.1.2 1000 11.0 0.142857 + account1 leaf.1.3 100000 10.0 0.428571 + account2 100 11.0 + account2 leaf.2.1 100000 8.0 0.714286 + account2 leaf.2.2 10000 3.0 0.571429 + account3 10 1.0 + account3 leaf.3.1 100 0.0 1.0 + account3 leaf.3.2 10 1.0 0.857143 + diff --git a/t/t1006-update-fshare.t b/t/t1006-update-fshare.t index b8ddd393f..08104948a 100755 --- a/t/t1006-update-fshare.t +++ b/t/t1006-update-fshare.t @@ -8,6 +8,12 @@ EXPECTED_FILES=${SHARNESS_TEST_SRCDIR}/expected/update_fshare CREATE_TEST_DB=${SHARNESS_TEST_SRCDIR}/scripts/create_test_db.py UPDATE_USAGE_COL=${SHARNESS_TEST_SRCDIR}/scripts/update_usage_column.py +export TEST_UNDER_FLUX_NO_JOB_EXEC=y +export TEST_UNDER_FLUX_SCHED_SIMPLE_MODE="limited=1" +test_under_flux 1 job + +flux setattr log-stderr-level 1 + test_expect_success 'trying to run update-fshare with bad DBPATH should return an error' ' test_must_fail flux account-update-fshare -p foo.db > failure.out 2>&1 && test_debug "cat failure.out" && @@ -18,16 +24,21 @@ test_expect_success 'create t_small_no_tie.db' ' flux python ${CREATE_TEST_DB} $(pwd)/t_small_no_tie.db ' +test_expect_success 'start flux-accounting service on small_no_tie DB' ' + flux account-service -p $(pwd)/t_small_no_tie.db -t +' + test_expect_success 'create hierarchy output from t_small_no_tie.db' ' - flux account-shares -p $(pwd)/t_small_no_tie.db + flux account view-bank root -t ' test_expect_success 'run update fshare script - small_no_tie.db' ' + flux account update-usage && flux account-update-fshare -p $(pwd)/t_small_no_tie.db ' test_expect_success 'create hierarchy output from C++ - small_no_tie.db' ' - flux account-shares -p $(pwd)/t_small_no_tie.db > pre_fshare_update.test + flux account view-bank root -t > pre_fshare_update.test ' test_expect_success 'compare hierarchy outputs' ' @@ -39,11 +50,12 @@ test_expect_success 'update usage column in t_small_no_tie.db' ' ' test_expect_success 'run update fshare script - small_no_tie.db' ' + flux account update-usage && flux account-update-fshare -p $(pwd)/t_small_no_tie.db ' test_expect_success 'create hierarchy output from C++ - small_no_tie.db' ' - flux account-shares -p $(pwd)/t_small_no_tie.db > post_fshare_update.test + flux account view-bank root -t > post_fshare_update.test ' test_expect_success 'compare hierarchy outputs' ' diff --git a/t/t1009-pop-db.t b/t/t1009-pop-db.t index 6e22da98f..e3cc8e529 100755 --- a/t/t1009-pop-db.t +++ b/t/t1009-pop-db.t @@ -49,7 +49,7 @@ test_expect_success 'populate flux-accounting DB with users.csv' ' ' test_expect_success 'check database hierarchy to make sure all banks & users were added' ' - flux account-shares -p ${DB_PATH} > db_hierarchy_base.test && + flux account view-bank root -t > db_hierarchy_base.test && test_cmp ${EXPECTED_FILES}/db_hierarchy_base.expected db_hierarchy_base.test ' @@ -68,7 +68,7 @@ test_expect_success 'populate flux-accounting DB with users_optional_vals.csv' ' ' test_expect_success 'check database hierarchy to make sure new users were added' ' - flux account-shares -p ${DB_PATH} > db_hierarchy_new_users.test && + flux account view-bank root -t > db_hierarchy_new_users.test && test_cmp ${EXPECTED_FILES}/db_hierarchy_new_users.expected db_hierarchy_new_users.test ' diff --git a/t/t1011-job-archive-interface.t b/t/t1011-job-archive-interface.t index e44b16a20..a2f18ea08 100755 --- a/t/t1011-job-archive-interface.t +++ b/t/t1011-job-archive-interface.t @@ -152,7 +152,7 @@ test_expect_success 'run update-usage and update-fshare commands' ' ' test_expect_success 'check that job usage and fairshare values get updated' ' - flux account-shares -p $(pwd)/FluxAccountingTest.db > post_update1.test && + flux account view-bank account1 -t > post_update1.test && grep "account1" post_update1.test | grep "4" | grep "0.25" ' diff --git a/t/t1016-export-db.t b/t/t1016-export-db.t index 99645dd09..6f7bc3f98 100755 --- a/t/t1016-export-db.t +++ b/t/t1016-export-db.t @@ -65,18 +65,32 @@ test_expect_success 'compare users.csv' ' test_cmp -b users_expected.csv users.csv ' +test_expect_success 'create hierarchy output of the flux-accounting DB and store it in a file' ' + flux account view-bank root -t > db1.test +' + +test_expect_success 'shut down flux-accounting service' ' + flux python -c "import flux; flux.Flux().rpc(\"accounting.shutdown_service\").get()" +' + test_expect_success 'create a new flux-accounting DB' ' flux account -p $(pwd)/FluxAccountingTestv2.db create-db ' +test_expect_success 'restart service against new DB' ' + flux account-service -p ${DB_PATHv2} -t +' + test_expect_success 'import information into new DB' ' flux account-pop-db -p ${DB_PATHv2} -b banks.csv && flux account-pop-db -p ${DB_PATHv2} -u users.csv ' +test_expect_success 'create hierarchy output of the new DB and store it in a file' ' + flux account view-bank root -t > db2.test +' + test_expect_success 'compare DB hierarchies to make sure they are the same' ' - flux account-shares -p ${DB_PATHv1} > db1.test && - flux account-shares -p ${DB_PATHv2} > db2.test && test_cmp db1.test db2.test ' From 3cf62827952885127a207f7da38a338d2beb1ab5 Mon Sep 17 00:00:00 2001 From: cmoussa1 Date: Mon, 29 Jul 2024 08:41:57 -0700 Subject: [PATCH 4/4] src: remove flux_account_shares.cpp Problem: flux_account_shares.cpp is no longer needed by flux-accounting since its function is replicated by the "-t" option in the "view-bank" command. Remove flux_account_shares.cpp from flux-accounting as well as any references to it throughout documentation. --- doc/guide/accounting-guide.rst | 32 +++++++------- src/Makefile.am | 4 +- src/cmd/flux_account_shares.cpp | 78 --------------------------------- 3 files changed, 17 insertions(+), 97 deletions(-) delete mode 100644 src/cmd/flux_account_shares.cpp diff --git a/doc/guide/accounting-guide.rst b/doc/guide/accounting-guide.rst index 11af9d86b..b4e01dc45 100644 --- a/doc/guide/accounting-guide.rst +++ b/doc/guide/accounting-guide.rst @@ -252,27 +252,27 @@ consists of the following tables: | | share calculation | +--------------------------+--------------------------------------------------+ -To view all associations in a flux-accounting database, the ``flux -account-shares`` command will print this DB information in a hierarchical -format. An example is shown below: +To view all associations in a flux-accounting database, the ``view-bank`` +command will print this DB information in a hierarchical format. An example is +shown below showing all associations under the root bank: .. code-block:: console - $ flux account-shares + $ flux account view-bank root -t Account Username RawShares RawUsage Fairshare - root 1 0 - bank_A 1 0 - bank_A user_1 1 0 0.5 - bank_B 1 0 - bank_B user_2 1 0 0.5 - bank_B user_3 1 0 0.5 - bank_C 1 0 - bank_C_a 1 0 - bank_C_a user_4 1 0 0.5 - bank_C_b 1 0 - bank_C_b user_5 1 0 0.5 - bank_C_b user_6 1 0 0.5 + root 1 0.0 + bank_A 1 0.0 + bank_A user_1 1 0.0 0.5 + bank_B 1 0.0 + bank_B user_2 1 0.0 0.5 + bank_B user_3 1 0.0 0.5 + bank_C 1 0.0 + bank_C_a 1 0.0 + bank_C_a user_4 1 0.0 0.5 + bank_C_b 1 0.0 + bank_C_b user_5 1 0.0 0.5 + bank_C_b user_6 1 0.0 0.5 **************************** diff --git a/src/Makefile.am b/src/Makefile.am index 5fc17dd16..475411f1b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -105,8 +105,7 @@ accounting_test01_t_LDADD = \ $(JANSSON_LIBS) noinst_PROGRAMS = \ - cmd/flux-account-update-fshare \ - cmd/flux-account-shares + cmd/flux-account-update-fshare cmd_flux_account_update_fshare_SOURCES = cmd/flux_account_update_fshare.cpp @@ -138,7 +137,6 @@ dist_fluxcmd_SCRIPTS = \ cmd/flux-account.py \ cmd/flux-account-update-fshare \ cmd/flux-account-priority-update.py \ - cmd/flux-account-shares \ cmd/flux-account-pop-db.py \ cmd/flux-account-export-db.py \ cmd/flux-account-update-db.py \ diff --git a/src/cmd/flux_account_shares.cpp b/src/cmd/flux_account_shares.cpp deleted file mode 100644 index a6d59ad15..000000000 --- a/src/cmd/flux_account_shares.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************\ - * Copyright 2021 Lawrence Livermore National Security, LLC - * (c.f. AUTHORS, NOTICE.LLNS, COPYING) - * - * This file is part of the Flux resource manager framework. - * For details, see https://github.com/flux-framework. - * - * SPDX-License-Identifier: LGPL-3.0 -\************************************************************/ -#include -#include - -extern "C" { -#if HAVE_CONFIG_H -#include "config.h" -#endif -} - -#include "src/fairness/writer/data_writer_stdout.hpp" - -using namespace Flux::accounting; -using namespace Flux::writer; - -const std::string DBPATH = std::string (X_LOCALSTATEDIR) - + "/lib/flux/FluxAccounting.db"; - -static void show_usage () -{ - std::cout << "usage: flux shares [-P DELIMITER] [-p DB_PATH]\n" - << "optional arguments:\n" - << "\t-h,--help\t\t\tShow this help message\n" - << "\t-P DELIMITER" - << "\t\tPrint the database hierarchy in a parsable format\n" - << "\t-p DB_PATH" - << "\t\t\tSpecify location of the flux-accounting database" - << std::endl; -} - - -int main (int argc, char** argv) -{ - std::string filepath = ""; - int rc = 0; - std::shared_ptr root; - std::string indent, delimiter = ""; - bool parsable = false; - - for (int i = 1; i < argc; ++i) { - std::string arg = argv[i]; - if (arg == "-p") { - filepath = argv[i + 1]; - i++; - } else if (arg == "-P") { - parsable = true; - if (std::string (argv[i + 1]).length () > 1) { - rc = -1; - return rc; - } - delimiter = std::string (argv[i + 1]); - i++; - } else if (arg == "-h" || arg == "--help") { - show_usage (); - return rc; - } else { - show_usage (); - rc = -1; - return rc; - } - } - - if (filepath == "") - filepath = DBPATH; - - data_writer_stdout_t data_writer (indent, parsable, delimiter); - rc = data_writer.write_acct_info (filepath, root); - - return rc; -}