diff --git a/t/t1009-pop-db.t b/t/t1009-pop-db.t index f80b5bd6..854781c7 100755 --- a/t/t1009-pop-db.t +++ b/t/t1009-pop-db.t @@ -20,8 +20,15 @@ test_expect_success 'start flux-accounting service' ' flux account-service -p ${DB_PATH} -t ' -test_expect_success 'create a banks.csv file containing bank information' ' - cat <<-EOF >banks.csv +test_expect_success 'try to populate flux-accounting DB with a bad filename' ' + touch foo.csv && + test_must_fail flux account pop-db -c foo.csv > error.out 2>&1 && + grep "table \"foo\" does not exist in the database" error.out +' + +test_expect_success 'create bank_table.csv' ' + cat <<-EOF >bank_table.csv + bank,parent_bank,shares root,,1 A,root,1 B,root,1 @@ -30,22 +37,23 @@ test_expect_success 'create a banks.csv file containing bank information' ' EOF ' -test_expect_success 'populate flux-accounting DB with banks.csv' ' - flux account pop-db -b banks.csv +test_expect_success 'populate flux-accounting DB with bank_table.csv' ' + flux account pop-db -c bank_table.csv ' -test_expect_success 'create a users.csv file containing user information' ' - cat <<-EOF >users.csv - user1000,1000,A,1,10,15,5,"" - user1001,1001,A,1,10,15,5,"" - user1002,1002,A,1,10,15,5,"" - user1003,1003,A,1,10,15,5,"" - user1004,1004,A,1,10,15,5,"" +test_expect_success 'create association_table.csv' ' + cat <<-EOF >association_table.csv + creation_time,username,userid,bank,default_bank,shares,max_running_jobs,max_active_jobs,max_nodes,queues + 0,user1000,1000,A,A,1,10,15,5,"" + 0,user1001,1001,A,A,1,10,15,5,"" + 0,user1002,1002,A,A,1,10,15,5,"" + 0,user1003,1003,A,A,1,10,15,5,"" + 0,user1004,1004,A,A,1,10,15,5,"" EOF ' -test_expect_success 'populate flux-accounting DB with users.csv' ' - flux account pop-db -u users.csv +test_expect_success 'populate association_table with association_table.csv' ' + flux account pop-db -c association_table.csv ' test_expect_success 'check database hierarchy to make sure all banks & users were added' ' @@ -53,18 +61,19 @@ test_expect_success 'check database hierarchy to make sure all banks & users wer test_cmp ${EXPECTED_FILES}/db_hierarchy_base.expected db_hierarchy_base.test ' -test_expect_success 'create a users.csv file with some missing optional user information' ' - cat <<-EOF >users_optional_vals.csv - user1005,1005,B,1,5,,5,"" - user1006,1006,B,,,,5,"" - user1007,1007,B,1,7,,,"" - user1008,1008,B,,,,5,"" - user1009,1009,B,1,9,,,"" +test_expect_success 'create association_table.csv with some missing user information' ' + cat <<-EOF >association_table.csv + creation_time,username,userid,bank,default_bank,shares,max_running_jobs,max_active_jobs,max_nodes,queues + 0,user1005,1005,B,B,1,5,,5,"" + 0,user1006,1006,B,B,,,,5,"" + 0,user1007,1007,B,B,1,7,,,"" + 0,user1008,1008,B,B,,,,5,"" + 0,user1009,1009,B,B,1,9,,,"" EOF ' -test_expect_success 'populate flux-accounting DB with users_optional_vals.csv' ' - flux account pop-db -u users_optional_vals.csv +test_expect_success 'populate association_table' ' + flux account pop-db -c association_table.csv ' test_expect_success 'check database hierarchy to make sure new users were added' ' diff --git a/t/t1016-export-db.t b/t/t1016-export-db.t index 41d1d760..090dde91 100755 --- a/t/t1016-export-db.t +++ b/t/t1016-export-db.t @@ -43,61 +43,28 @@ test_expect_success 'export DB information into .csv files' ' ' test_expect_success 'compare banks.csv' ' - cat <<-EOF >banks_expected.csv - root,,1 - A,root,1 - B,root,1 - C,root,1 - D,root,1 - E,D,1 - F,D,1 + cat <<-EOF >bank_table_expected.csv + bank_id,bank,active,parent_bank,shares,job_usage + 1,root,1,,1,0.0 + 2,A,1,root,1,0.0 + 3,B,1,root,1,0.0 + 4,C,1,root,1,0.0 + 5,D,1,root,1,0.0 + 6,E,1,D,1,0.0 + 7,F,1,D,1,0.0 EOF - test_cmp -b banks_expected.csv banks.csv -' - -test_expect_success 'compare users.csv' ' - cat <<-EOF >users_expected.csv - user5011,5011,A,1,5,7,2147483647, - user5012,5012,A,1,5,7,2147483647, - user5013,5013,B,1,5,7,2147483647, - user5014,5014,C,1,5,7,2147483647, - EOF - 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 -b banks.csv && - flux account pop-db -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' ' - test_cmp db1.test db2.test -' - -test_expect_success 'specify a different filename for exported users and banks .csv files' ' - flux account export-db --users foo.csv --banks bar.csv && - test_cmp -b users_expected.csv foo.csv && - test_cmp -b banks_expected.csv bar.csv + test_cmp -b bank_table_expected.csv bank_table.csv +' + +# use 'grep' checks here because the contents of association_table also +# store timestamps of when the user was added to the DB, and thus will be +# slightly different every time these tests are run +test_expect_success 'make association_table.csv is populated' ' + grep "creation_time,mod_time,active,username" association_table.csv && + grep "user5011,5011,A,A" association_table.csv && + grep "user5012,5012,A,A" association_table.csv && + grep "user5013,5013,B,B" association_table.csv && + grep "user5014,5014,C,C" association_table.csv ' test_expect_success 'shut down flux-accounting service' ' diff --git a/t/t1026-flux-account-perms.t b/t/t1026-flux-account-perms.t index e67daaeb..7f8f8249 100755 --- a/t/t1026-flux-account-perms.t +++ b/t/t1026-flux-account-perms.t @@ -151,8 +151,7 @@ test_expect_success 'pop-db should not be accessible by all users' ' ( export FLUX_HANDLE_ROLEMASK=0x2 && export FLUX_HANDLE_USERID=$newid && touch users.csv && - touch banks.csv && - test_must_fail flux account pop-db -u users.csv -b banks.csv > no_access_pop_db.out 2>&1 && + test_must_fail flux account pop-db -c association_table.csv > no_access_pop_db.out 2>&1 && grep "Request requires owner credentials" no_access_pop_db.out ) '