-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
t: add tests for max-preempt-after optional arg
Problem: There are no tests for adding/editing banks in the bank_table with max-preempt-after values. Add some tests.
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
|
||
test_description='test configuring max-preempt-after values for banks' | ||
|
||
. `dirname $0`/sharness.sh | ||
DB_PATH=$(pwd)/FluxAccountingTest.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 ${DB_PATH} create-db | ||
' | ||
|
||
test_expect_success 'start flux-accounting service' ' | ||
flux account-service -p ${DB_PATH} -t | ||
' | ||
|
||
test_expect_success 'add root bank to the DB' ' | ||
flux account add-bank root 1 | ||
' | ||
|
||
test_expect_success 'add a sub bank with max-preempt in seconds' ' | ||
flux account add-bank --parent-bank=root --max-preempt-after=60s A 1 && | ||
flux account view-bank A > A.test && | ||
grep "60.0" A.test | ||
' | ||
|
||
test_expect_success 'add a sub bank with max-preempt in hours' ' | ||
flux account add-bank --parent-bank=root --max-preempt-after=1h B 1 && | ||
flux account view-bank B > B.test && | ||
grep "3600.0" B.test | ||
' | ||
|
||
test_expect_success 'add a sub bank with max-preempt in days' ' | ||
flux account add-bank --parent-bank=root --max-preempt-after=1d C 1 && | ||
flux account view-bank C > C.test && | ||
grep "86400.0" C.test | ||
' | ||
|
||
test_expect_success 'add a sub bank with no max-preempt specified' ' | ||
flux account add-bank --parent-bank=root D 1 && | ||
flux account view-bank D > D.test && | ||
grep "None" D.test | ||
' | ||
|
||
test_expect_success 'trying to add a sub bank with a bad FSD will raise an error' ' | ||
test_must_fail flux account add-bank \ | ||
--parent-bank=root \ | ||
--max-preempt-after=foo E 1 > error.out 2>&1 && | ||
grep "error in add_bank: invalid Flux standard duration" error.out | ||
' | ||
|
||
test_expect_success 'edit max-preempt-after for a bank' ' | ||
flux account edit-bank A --max-preempt-after=200s && | ||
flux account view-bank A > A_edited.test && | ||
grep "200.0" A_edited.test | ||
' | ||
|
||
test_expect_success 'clear max-preempt-after for a bank' ' | ||
flux account edit-bank A --max-preempt-after=-1 && | ||
flux account view-bank A > A_cleared.test && | ||
grep "None" A_cleared.test | ||
' | ||
|
||
test_expect_success 'shut down flux-accounting service' ' | ||
flux python -c "import flux; flux.Flux().rpc(\"accounting.shutdown_service\").get()" | ||
' | ||
|
||
test_done |