Skip to content

Commit abd28d9

Browse files
committed
testsuite: add flux-jobs per-resource=core tests
Problem: There is no coverage for flux-jobs ntasks output for the special cases when per-resource.type is set to "core". Add tests to t2260-job-list.t.
1 parent 0290e60 commit abd28d9

File tree

1 file changed

+66
-1
lines changed

1 file changed

+66
-1
lines changed

t/t2260-job-list.t

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,10 @@ test_expect_success HAVE_JQ 'flux job list outputs ntasks correctly (tasks-per-n
711711
echo $obj | jq -e ".ntasks == 6"
712712
'
713713

714-
test_expect_success 'flux jobs list outputs ntasks correctly (per-resource.type=node)' '
714+
# N.B. As of this test writing, tasks-per-node uses
715+
# per-resource.type=node. But write more direct test in case of
716+
# future changes.
717+
test_expect_success HAVE_JQ 'flux job list outputs ntasks correctly (per-resource.type=node)' '
715718
nnodes=$(flux resource list -s up -no {nnodes}) &&
716719
ncores=$(flux resource list -s up -no {ncores}) &&
717720
extra=$((ncores / nnodes + 2)) &&
@@ -727,6 +730,54 @@ test_expect_success 'flux jobs list outputs ntasks correctly (per-resource.type=
727730
echo $obj | jq -e ".ntasks == ${expected}"
728731
'
729732

733+
test_expect_success HAVE_JQ 'flux job list outputs ntasks correctly (cores / tasks-per-core)' '
734+
jobid=`flux mini submit --wait --cores=4 --tasks-per-core=2 hostname | flux job id` &&
735+
echo $jobid > taskcount7.id &&
736+
wait_jobid_state $jobid inactive &&
737+
obj=$(flux job list -s inactive | grep $jobid) &&
738+
echo $obj | jq -e ".ntasks == 8"
739+
'
740+
741+
test_expect_success HAVE_JQ 'flux job list outputs ntasks correctly (tasks / cores-per-task)' '
742+
jobid=$(flux mini submit --wait -n2 --cores-per-task=2 \
743+
-o per-resource.type=core \
744+
-o per-resource.count=2 \
745+
hostname | flux job id) &&
746+
echo $jobid > taskcount8.id &&
747+
wait_jobid_state $jobid inactive &&
748+
obj=$(flux job list -s inactive | grep $jobid) &&
749+
echo $obj | jq -e ".ntasks == 8"
750+
'
751+
752+
test_expect_success HAVE_JQ 'flux job list outputs ntasks correctly (nodes / tasks-per-core 2)' '
753+
nnodes=$(flux resource list -s up -no {nnodes}) &&
754+
ncores=$(flux resource list -s up -no {ncores}) &&
755+
jobid=`flux mini submit --wait -N ${nnodes} --tasks-per-core=2 hostname | flux job id` &&
756+
echo $jobid > taskcount9.id &&
757+
wait_jobid_state $jobid inactive &&
758+
expected=$((ncores * 2)) &&
759+
echo ${expected} > per_resource_type_core_ntasks1.exp &&
760+
obj=$(flux job list -s inactive | grep $jobid) &&
761+
echo $obj | jq -e ".ntasks == ${expected}"
762+
'
763+
764+
# N.B. As of this test writing, tasks-per-core uses
765+
# per-resource.type=core. But write direct test in case of future
766+
# changes.
767+
test_expect_success HAVE_JQ 'flux job list outputs ntasks correctly (cores / per-resource.type=core)' '
768+
ncores=$(flux resource list -s up -no {ncores}) &&
769+
jobid=$(flux mini submit --wait --cores=${ncores} \
770+
-o per-resource.type=core \
771+
-o per-resource.count=2 \
772+
hostname | flux job id) &&
773+
echo $jobid > taskcount10.id &&
774+
wait_jobid_state $jobid inactive &&
775+
obj=$(flux job list -s inactive | grep $jobid) &&
776+
expected=$((ncores * 2)) &&
777+
echo ${expected} > per_resource_type_core_ntasks2.exp &&
778+
echo $obj | jq -e ".ntasks == ${expected}"
779+
'
780+
730781
test_expect_success 'reload the job-list module' '
731782
flux module reload job-list
732783
'
@@ -738,6 +789,10 @@ test_expect_success HAVE_JQ 'verify task count preserved across restart' '
738789
jobid4=`cat taskcount4.id` &&
739790
jobid5=`cat taskcount5.id` &&
740791
jobid6=`cat taskcount6.id` &&
792+
jobid7=`cat taskcount7.id` &&
793+
jobid8=`cat taskcount8.id` &&
794+
jobid9=`cat taskcount9.id` &&
795+
jobid10=`cat taskcount10.id` &&
741796
obj=$(flux job list -s inactive | grep ${jobid1}) &&
742797
echo $obj | jq -e ".ntasks == 1" &&
743798
obj=$(flux job list -s inactive | grep ${jobid2}) &&
@@ -750,6 +805,16 @@ test_expect_success HAVE_JQ 'verify task count preserved across restart' '
750805
echo $obj | jq -e ".ntasks == 6" &&
751806
obj=$(flux job list -s inactive | grep ${jobid6}) &&
752807
expected=$(cat per_resource_type_node_ntasks.exp) &&
808+
echo $obj | jq -e ".ntasks == ${expected}" &&
809+
obj=$(flux job list -s inactive | grep ${jobid7}) &&
810+
echo $obj | jq -e ".ntasks == 8" &&
811+
obj=$(flux job list -s inactive | grep ${jobid8}) &&
812+
echo $obj | jq -e ".ntasks == 8" &&
813+
obj=$(flux job list -s inactive | grep ${jobid9}) &&
814+
expected=$(cat per_resource_type_core_ntasks1.exp) &&
815+
echo $obj | jq -e ".ntasks == ${expected}" &&
816+
obj=$(flux job list -s inactive | grep ${jobid10}) &&
817+
expected=$(cat per_resource_type_core_ntasks2.exp) &&
753818
echo $obj | jq -e ".ntasks == ${expected}"
754819
'
755820

0 commit comments

Comments
 (0)