Skip to content

Commit

Permalink
testsuite: add hostlist constraint coverage
Browse files Browse the repository at this point in the history
Problem: There is no testing / coverage for the new hostlist constraint
in the job-list module.

Add some tests to t2260-job-list.t.
  • Loading branch information
chu11 committed Jan 16, 2024
1 parent 059bea4 commit 8596055
Showing 1 changed file with 107 additions and 0 deletions.
107 changes: 107 additions & 0 deletions t/t2260-job-list.t
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,113 @@ test_expect_success 'flux job list all via t_depend (3)' '
test $(cat list_constraint_all3.out | wc -l) -eq ${numlines}
'

#
# nodelist / hostlist constraint filtering
#

# N.B. all failed and timeout jobs we explicitly ran on node0, so
# tests below don't test against node0 to make things easier.

# N.B. failed.ids are jobs that failed after running, thus will have
# had a node assigned. timeout.ids obviously ran on a node, but timed
# out.
test_expect_success 'flux job list all jobs that ran on any node (1)' '
constraint="{ and: [ {hostlist:[\"node[0-3]\"]} ] }" &&
$jq -j -c -n "{max_entries:1000, attrs:[], constraint:${constraint}}" \
| $RPC job-list.list | $jq .jobs | $jq -c '.[]' | $jq .id > constraint_hostlist1.out &&
numlines=$(cat completed.ids running.ids failed.ids timeout.ids | wc -l) &&
test $(cat constraint_hostlist1.out | wc -l) -eq ${numlines}
'

test_expect_success 'flux job list all jobs that ran on any node (2)' '
constraint="{ and: [ {hostlist:[\"node[2-3]\", \"node1\", \"node0\"]} ] }" &&
$jq -j -c -n "{max_entries:1000, attrs:[], constraint:${constraint}}" \
| $RPC job-list.list | $jq .jobs | $jq -c '.[]' | $jq .id > constraint_hostlist2.out &&
numlines=$(cat completed.ids running.ids failed.ids timeout.ids | wc -l) &&
test $(cat constraint_hostlist2.out | wc -l) -eq ${numlines}
'

# We evenly distributed non-bad jobs on nodes, so should be half of the jobs
test_expect_success 'flux job list all jobs that ran on nodes[1-2] (1)' '
constraint="{ and: [ {hostlist:[\"node[1-2]\"]} ] }" &&
$jq -j -c -n "{max_entries:1000, attrs:[], constraint:${constraint}}" \
| $RPC job-list.list | $jq .jobs | $jq -c '.[]' | $jq .id > constraint_hostlist3.out &&
numlines=$(expr $(cat completed.ids running.ids | wc -l) / 2) &&
test $(cat constraint_hostlist3.out | wc -l) -eq ${numlines}
'

# We evenly distributed non-bad jobs on nodes, so should be half of the jobs
test_expect_success 'flux job list all jobs that ran on nodes[1-2] (2)' '
constraint="{ and: [ {hostlist:[\"node1\", \"node2\"]} ] }" &&
$jq -j -c -n "{max_entries:1000, attrs:[], constraint:${constraint}}" \
| $RPC job-list.list | $jq .jobs | $jq -c '.[]' | $jq .id > constraint_hostlist4.out &&
numlines=$(expr $(cat completed.ids running.ids | wc -l) / 2) &&
test $(cat constraint_hostlist4.out | wc -l) -eq ${numlines}
'

# We evenly distributed non-bad jobs on nodes, so should be quarter of the jobs
test_expect_success 'flux job list all jobs that ran on node3' '
constraint="{ and: [ {hostlist:[\"node3\"]} ] }" &&
$jq -j -c -n "{max_entries:1000, attrs:[], constraint:${constraint}}" \
| $RPC job-list.list | $jq .jobs | $jq -c '.[]' | $jq .id > constraint_hostlist5.out &&
numlines=$(expr $(cat completed.ids running.ids | wc -l) / 4) &&
test $(cat constraint_hostlist5.out | wc -l) -eq ${numlines}
'

# We evenly distributed completed jobs on nodes, so should be quarter of the jobs
test_expect_success 'flux job list completed jobs that ran on node3' '
state=`${JOB_CONV} strtostate INACTIVE` &&
constraint="{ and: [ {hostlist:[\"node3\"]}, {states:[${state}]} ] }" &&
$jq -j -c -n "{max_entries:1000, attrs:[], constraint:${constraint}}" \
| $RPC job-list.list | $jq .jobs | $jq -c '.[]' | $jq .id > constraint_hostlist6.out &&
numlines=$(expr $(cat completed.ids | wc -l) / 4) &&
test $(cat constraint_hostlist6.out | wc -l) -eq ${numlines}
'

# We evenly distributed running jobs on nodes, so should be quarter of the jobs
test_expect_success 'flux job list running jobs that ran on node3' '
state=`${JOB_CONV} strtostate RUNNING` &&
constraint="{ and: [ {hostlist:[\"node3\"]}, {states:[${state}]} ] }" &&
$jq -j -c -n "{max_entries:1000, attrs:[], constraint:${constraint}}" \
| $RPC job-list.list | $jq .jobs | $jq -c '.[]' | $jq .id > constraint_hostlist7.out &&
numlines=$(expr $(cat running.ids | wc -l) / 4) &&
test $(cat constraint_hostlist7.out | wc -l) -eq ${numlines}
'

# We evenly distributed running jobs on nodes, so should be half of the jobs
# For this test, get start time of first running job
test_expect_success 'flux job list of running jobs that ran on node[1-2] after certain time (1)' '
id=`tail -n1 running.ids` &&
t_submit=`flux job list-ids ${id} | $jq .t_submit` &&
constraint="{ and: [ {hostlist:[\"node[1-2]\"]}, {t_submit:[\">=${t_submit}\"]} ] }" &&
$jq -j -c -n "{max_entries:1000, attrs:[], constraint:${constraint}}" \
| $RPC job-list.list | $jq .jobs | $jq -c '.[]' | $jq .id > constraint_hostlist8.out &&
numlines=$(expr $(cat running.ids | wc -l) / 2) &&
test $(cat constraint_hostlist8.out | wc -l) -eq ${numlines}
'

# We evenly distributed running jobs on nodes, so should be half of the jobs
# For this test, get last inactive time of completed jobs
test_expect_success 'flux job list of running jobs that ran on node[1-2] after certain time (2)' '
id=`head -n1 completed.ids` &&
t_inactive=`flux job list-ids ${id} | $jq .t_inactive` &&
constraint="{ and: [ {hostlist:[\"node[1-2]\"]}, {t_submit:[\">${t_inactive}\"]} ] }" &&
$jq -j -c -n "{max_entries:1000, attrs:[], constraint:${constraint}}" \
| $RPC job-list.list | $jq .jobs | $jq -c '.[]' | $jq .id > constraint_hostlist9.out &&
numlines=$(expr $(cat running.ids | wc -l) / 2) &&
test $(cat constraint_hostlist9.out | wc -l) -eq ${numlines}
'

# We evenly distributed completed & running jobs on nodes, so should be half of the jobs
test_expect_success 'flux job list of all jobs that ran on node[1-2] after certain time' '
id=`head -n1 completed.ids` &&
constraint="{ and: [ {hostlist:[\"node[1-2]\"]}, {t_submit:[\">5\"]} ] }" &&
$jq -j -c -n "{max_entries:1000, attrs:[], constraint:${constraint}}" \
| $RPC job-list.list | $jq .jobs | $jq -c '.[]' | $jq .id > constraint_hostlist9.out &&
numlines=$(expr $(cat completed.ids running.ids | wc -l) / 2) &&
test $(cat constraint_hostlist9.out | wc -l) -eq ${numlines}
'

#
# legacy RPC tests
#
Expand Down

0 comments on commit 8596055

Please sign in to comment.