Skip to content

Commit d1fc85f

Browse files
committed
t2700-mini-cmd.t: add tests for per-resource alloc options
Problem: No tests in the testsuite exercise the "per resource" options present in flux-mini run and flux-mini submit. Add a set of tests that exercise this interface including expected errors to t2700-mini-cmd.t.
1 parent 3de28df commit d1fc85f

File tree

1 file changed

+131
-0
lines changed

1 file changed

+131
-0
lines changed

t/t2700-mini-cmd.t

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,135 @@ test_expect_success HAVE_JQ 'flux-mini submit does not substitute {} without --c
305305
--dry-run true > nocc.json &&
306306
jq -e ".attributes.system.test == {}" < nocc.json
307307
'
308+
test_expect_success HAVE_JQ 'flux-mini submit --tasks-per-node works' '
309+
flux mini submit \
310+
--env=-* \
311+
-N 2 \
312+
--tasks-per-node=2 \
313+
--dry-run true > ntasks-per-node.json &&
314+
jq -e \
315+
".attributes.system.shell.options.\"per-resource\".type == \"node\"" &&
316+
jq -e \
317+
".attributes.system.shell.options.\"per-resource\".count == 2"
318+
'
319+
320+
# Per-resource expected failure tests
321+
cat <<EOF >per-resource-failure.txt
322+
\
323+
--tasks-per-core=1 --tasks-per-node=1 \
324+
==Do not specify both the number of tasks per node and per core
325+
\
326+
--tasks-per-node=0 \
327+
==--tasks-per-node must be >= 1
328+
\
329+
--tasks-per-core=0 \
330+
==--tasks-per-core must be >= 1
331+
\
332+
--cores=-4 \
333+
==ncores must be an integer >= 1
334+
\
335+
--nodes=1 --gpus-per-node=-1 \
336+
==gpus_per_node must be an integer >= 0
337+
\
338+
--gpus-per-node=1 \
339+
==gpus-per-node requires --nodes
340+
\
341+
--cores=4 --exclusive \
342+
==exclusive can only be set with a node count
343+
\
344+
--nodes=4 --cores=2 \
345+
==number of cores cannot be less than nnodes
346+
\
347+
--nodes=5 --cores=9 \
348+
==number of cores must be evenly divisible by node count
349+
\
350+
--cores=2 --cores-per-task=1 \
351+
==Per-resource options.*per-task options
352+
\
353+
--cores=1 --ntasks=1 \
354+
==Per-resource options.*per-task options
355+
\
356+
--nodes=1 --tasks-per-node=1 --gpus-per-task=1 \
357+
==Per-resource options.*per-task options
358+
\
359+
--nodes=1 --tasks-per-core=1 --cores-per-task=1 \
360+
==Per-resource options.*per-task options
361+
EOF
362+
363+
while read line; do
364+
args=$(echo $line | awk -F== '{print $1}' | sed 's/ *$//')
365+
expected=$(echo $line | awk -F== '{print $2}')
366+
test_expect_success "per-resource: $args error: $expected" '
367+
output=per-resource-error.${test_count}.out &&
368+
test_must_fail flux mini run $args --env=-* --dry-run hostname \
369+
>${output} 2>&1 &&
370+
test_debug "cat $output" &&
371+
grep -- "$expected" $output
372+
'
373+
done < per-resource-failure.txt
374+
375+
376+
# Per-resource expected success tests
377+
cat <<EOF >per-resource-args.txt
378+
\
379+
-N2 --cores=2 \
380+
==nnodes=2 nslots=2 slot_size=1 slot_gpus=0 exclusive=false duration=0.0 \
381+
==
382+
\
383+
-N2 --cores=2 --tasks-per-node=2 \
384+
==nnodes=2 nslots=2 slot_size=1 slot_gpus=0 exclusive=false duration=0.0 \
385+
=={"type": "node", "count": 2}
386+
\
387+
-N2 --cores=2 --tasks-per-core=2 \
388+
==nnodes=2 nslots=2 slot_size=1 slot_gpus=0 exclusive=false duration=0.0 \
389+
=={"type": "core", "count": 2}
390+
\
391+
--cores=16 \
392+
==nnodes=0 nslots=16 slot_size=1 slot_gpus=0 exclusive=false duration=0.0 \
393+
==
394+
\
395+
--cores=16 --tasks-per-node=1 \
396+
==nnodes=0 nslots=16 slot_size=1 slot_gpus=0 exclusive=false duration=0.0 \
397+
=={"type": "node", "count": 1}
398+
\
399+
--cores=5 --tasks-per-core=2 \
400+
==nnodes=0 nslots=5 slot_size=1 slot_gpus=0 exclusive=false duration=0.0 \
401+
=={"type": "core", "count": 2}
402+
\
403+
--nodes=2 --tasks-per-node=2 \
404+
==nnodes=2 nslots=2 slot_size=1 slot_gpus=0 exclusive=true duration=0.0 \
405+
=={"type": "node", "count": 2}
406+
\
407+
--nodes=2 --tasks-per-core=1 \
408+
==nnodes=2 nslots=2 slot_size=1 slot_gpus=0 exclusive=true duration=0.0 \
409+
=={"type": "core", "count": 1}
410+
\
411+
-N1 --gpus-per-node=2 \
412+
==nnodes=1 nslots=1 slot_size=1 slot_gpus=2 exclusive=true duration=0.0 \
413+
==
414+
\
415+
-N2 --cores=4 --tasks-per-node=1 --gpus-per-node=1 \
416+
==nnodes=2 nslots=2 slot_size=2 slot_gpus=1 exclusive=false duration=0.0 \
417+
=={"type": "node", "count": 1}
418+
EOF
419+
420+
jj=${FLUX_BUILD_DIR}/t/sched-simple/jj-reader
421+
while read line; do
422+
args=$(echo $line | awk -F== '{print $1}' | sed 's/ *$//')
423+
expected=$(echo $line | awk -F== '{print $2}')
424+
per_resource=$(echo $line | awk -F== '{print $3}' | sed 's/ *$//')
425+
test_expect_success HAVE_JQ "per-resource: $args" '
426+
echo $expected >expected.$test_count &&
427+
flux mini run $args --dry-run hostname > jobspec.$test_count &&
428+
$jj < jobspec.$test_count >output.$test_count &&
429+
test_debug "cat output.$test_count" &&
430+
test_cmp expected.$test_count output.$test_count &&
431+
if test -n "$per_resource"; then
432+
test_debug "echo expected $per_resource" &&
433+
jq -e ".attributes.system.shell.options.per_resource == \
434+
$per_resource"
435+
fi
436+
'
437+
done < per-resource-args.txt
438+
308439
test_done

0 commit comments

Comments
 (0)