Skip to content

Commit

Permalink
t: add tests for max-preempt-after optional arg
Browse files Browse the repository at this point in the history
Problem: There are no tests for adding/editing banks in the bank_table
with max-preempt-after values.

Add some tests.
  • Loading branch information
cmoussa1 committed Dec 20, 2024
1 parent 22424a7 commit c358048
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ TESTSCRIPTS = \
t1041-view-jobs-by-project.t \
t1042-issue508.t \
t1043-view-jobs-by-bank.t \
t1044-issue553.t \
t5000-valgrind.t \
python/t1000-example.py \
python/t1001_db.py \
Expand Down
73 changes: 73 additions & 0 deletions t/t1044-issue553.t
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

0 comments on commit c358048

Please sign in to comment.