From a14133af0e024f3523f5002e6abf48a5f26caae2 Mon Sep 17 00:00:00 2001 From: cmoussa1 Date: Thu, 12 Oct 2023 15:27:14 -0700 Subject: [PATCH] t1030: add tests that use non-default bank Problem: t1030-mf-priority-update-queue.t has no tests that test submitting a pending job under a non-default bank and changing its queue. Add some tests that do this. --- t/t1030-mf-priority-update-queue.t | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/t/t1030-mf-priority-update-queue.t b/t/t1030-mf-priority-update-queue.t index 6a3357e1..87591d8b 100755 --- a/t/t1030-mf-priority-update-queue.t +++ b/t/t1030-mf-priority-update-queue.t @@ -31,7 +31,8 @@ test_expect_success 'load multi-factor priority plugin' ' test_expect_success 'add some banks to the DB' ' flux account add-bank root 1 && - flux account add-bank --parent-bank=root A 1 + flux account add-bank --parent-bank=root A 1 && + flux account add-bank --parent-bank=root B 1 ' test_expect_success 'add some queues to the DB' ' @@ -44,6 +45,10 @@ test_expect_success 'add a user to the DB' ' flux account add-user --username=user5001 \ --userid=5001 \ --bank=A \ + --queues="bronze,silver" && + flux account add-user --username=user5001 \ + --userid=5001 \ + --bank=B \ --queues="bronze,silver" ' @@ -85,6 +90,31 @@ test_expect_success 'cancel job' ' flux job cancel $jobid1 ' +test_expect_success 'submit job for testing under non-default bank' ' + jobid2=$(flux python ${SUBMIT_AS} 5001 --setattr=bank=B --queue=bronze sleep 30) && + flux job wait-event -f json $jobid2 priority \ + | jq '.context.priority' > job2_bronze.test && + grep 1050000 job2_bronze.test +' + +test_expect_success 'update of queue of pending job under a non-default bank works' ' + flux update $jobid2 queue=silver && + flux job wait-event -f json $jobid2 priority && + flux job eventlog $jobid2 > eventlog.out && + grep "attributes.system.queue=\"silver\"" eventlog.out && + grep 2050000 eventlog.out +' + +test_expect_success 'updating a job under non-default bank using a queue the user does not belong to fails' ' + test_must_fail flux update $jobid2 queue=gold > unavail_queue.out 2>&1 && + test_debug "cat unavail_queue.out" && + grep "ERROR: mf_priority: queue not valid for user: gold" unavail_queue.out +' + +test_expect_success 'cancel job' ' + flux job cancel $jobid2 +' + test_expect_success 'shut down flux-accounting service' ' flux python -c "import flux; flux.Flux().rpc(\"accounting.shutdown_service\").get()" '