From f6396e94103e0103a91d8244818e7131d486163b Mon Sep 17 00:00:00 2001 From: Christopher Moussa Date: Fri, 6 Aug 2021 09:23:10 -0700 Subject: [PATCH] t: add null fairshare test Add a new test to t1001-mf-priority-basic.t that sends a fake payload with an empty fairshare key-value pair to ensure that if a job is submitted that relies on that fairshare value, an exception will be raised on that job and a priority of 0 will be set. --- t/t1001-mf-priority-basic.t | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/t/t1001-mf-priority-basic.t b/t/t1001-mf-priority-basic.t index badefcb16..ec4476989 100755 --- a/t/t1001-mf-priority-basic.t +++ b/t/t1001-mf-priority-basic.t @@ -123,4 +123,31 @@ test_expect_success 'reject job when invalid bank format is passed in' ' grep "unable to unpack bank arg" invalid_fmt.out ' +test_expect_success 'create a fake payload with an empty fairshare key-value pair' ' + cat <<-EOF >empty_fairshare.py + import flux + import pwd + import getpass + + username = getpass.getuser() + userid = pwd.getpwnam(username).pw_uid + # create a JSON payload + data = {"userid": str(userid), "bank": "account4", "default_bank": "account3", "fairshare": "", "max_jobs": "10"} + flux.Flux().rpc("job-manager.mf_priority.rec_update", data).get() + EOF +' + +test_expect_success 'update plugin with sample test data' ' + flux python empty_fairshare.py +' + +test_expect_success 'submit a job with new bank and empty fairshare results in a held job' ' + jobid=$(flux mini submit --setattr=system.bank=account4 -n1 hostname) && + flux job wait-event -f json $jobid priority | jq '.context.priority' > job7.test && + cat <<-EOF >job7.expected && + 0 + EOF + test_cmp job7.expected job7.test +' + test_done