Skip to content

Commit

Permalink
testsuite: add t2620-job-shell-mustache.t
Browse files Browse the repository at this point in the history
Problem: There are no specific tests for testing shell mustache
template expansion.

Add t2620-job-shell-mustache.t for this purpose.
  • Loading branch information
grondo committed Dec 18, 2024
1 parent ac3eb4c commit a91c89c
Show file tree
Hide file tree
Showing 2 changed files with 47 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 @@ -216,6 +216,7 @@ TESTSCRIPTS = \
t2617-job-shell-stage-in.t \
t2618-job-shell-signal.t \
t2619-job-shell-hwloc.t \
t2620-job-shell-mustache.t \
t2710-python-cli-submit.t \
t2711-python-cli-run.t \
t2713-python-cli-bulksubmit.t \
Expand Down
46 changes: 46 additions & 0 deletions t/t2620-job-shell-mustache.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh
#
test_description='Test flux-shell mustache template rendering'

. `dirname $0`/sharness.sh

test_under_flux 2 job

test_expect_success 'mustache: templates are rendered in job arguments' '
flux run -N2 -n4 \
echo {{id.words}}: size={{size}} nnodes={{nnodes}} name={{name}} \
>output.1 &&
test_debug "cat output.1" &&
grep "size=4 nnodes=2 name=echo" output.1
'
test_expect_success 'mustache: per-task tags work' '
flux run -N2 -n4 --label-io \
echo rank={{task.rank}} index={{task.index}} \
| sort >output.2 &&
test_debug "cat output.2" &&
cat <<-EOF >expected.2 &&
0: rank=0 index=0
1: rank=1 index=1
2: rank=2 index=0
3: rank=3 index=1
EOF
test_cmp expected.2 output.2
'
test_expect_success 'mustache: per-node tags work' '
flux run -N2 -n2 --label-io \
echo id={{node.id}} name={{node.name}} cores={{node.cores}}[{{node.ncores}}] \
| sort >output.3 &&
test_debug "cat output.3" &&
cat <<-EOF >expected.3 &&
0: id=0 name=$(hostname) cores=0[1]
1: id=1 name=$(hostname) cores=0[1]
EOF
test_cmp expected.3 output.3
'
test_expect_success 'mustache: unsupported tag is left alone' '
flux run echo {{foo}} {{node.foo}} {{task.foo}} >output.4 &&
test_debug "cat output.4" &&
test "$(cat output.4)" = "{{foo}} {{node.foo}} {{task.foo}}"
'

test_done

0 comments on commit a91c89c

Please sign in to comment.