Skip to content

Commit

Permalink
t/t2602-job-shell: Add output redirect tests
Browse files Browse the repository at this point in the history
Add job output redirection tests.
  • Loading branch information
chu11 committed Sep 26, 2019
1 parent 82a6798 commit ca91585
Showing 1 changed file with 230 additions and 0 deletions.
230 changes: 230 additions & 0 deletions t/t2602-job-shell.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ test_description='Test flux-shell'

. `dirname $0`/sharness.sh

jq=$(which jq 2>/dev/null)
test -n "$jq" && test_set_prereq HAVE_JQ

test_under_flux 4 job

flux setattr log-stderr-level 1

PMI_INFO=${FLUX_BUILD_DIR}/src/common/libpmi/test_pmi_info
KVSTEST=${FLUX_BUILD_DIR}/src/common/libpmi/test_kvstest
LPTEST=${SHARNESS_TEST_DIRECTORY}/shell/lptest
TEST_SUBPROCESS_DIR=${FLUX_BUILD_DIR}/src/common/libsubprocess

hwloc_fake_config='{"0-3":{"Core":2,"cpuset":"0-1"}}'

Expand Down Expand Up @@ -206,6 +210,232 @@ test_expect_success 'job-shell: shell kill event: kill(2) failure logged' '
grep_dmesg "signal 199: Invalid argument" &&
grep status=$((15+128<<8)) kill5.finish.out
'

test_expect_success 'job-shell: generate 1-task echo jobspecs and matching R' '
flux jobspec srun -N1 -n1 ${TEST_SUBPROCESS_DIR}/test_echo -P -O foo > j1echostdout &&
flux jobspec srun -N1 -n1 ${TEST_SUBPROCESS_DIR}/test_echo -P -E bar > j1echostderr &&
flux jobspec srun -N1 -n1 ${TEST_SUBPROCESS_DIR}/test_echo -P -O -E baz > j1echoboth
'

test_expect_success 'job-shell: generate 2-task echo jobspecs and matching R' '
flux jobspec srun -N1 -n2 ${TEST_SUBPROCESS_DIR}/test_echo -P -O foo > j2echostdout &&
flux jobspec srun -N1 -n2 ${TEST_SUBPROCESS_DIR}/test_echo -P -E bar > j2echostderr &&
flux jobspec srun -N1 -n2 ${TEST_SUBPROCESS_DIR}/test_echo -P -O -E baz > j2echoboth
'

#
# 1 task output file tests
#

test_expect_success HAVE_JQ 'job-shell: run 1-task echo job (stdout file)' '
cat j1echostdout \
| $jq ".attributes.system.shell.options.output.stdout.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stdout.path = \"out0\"" \
> j1echostdout-0 &&
id=$(cat j1echostdout-0 | flux job submit) &&
flux job wait-event $id clean &&
grep stdout:foo out0
'

test_expect_success HAVE_JQ 'job-shell: run 1-task echo job (stderr file)' '
cat j1echostderr \
| $jq ".attributes.system.shell.options.output.stderr.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stderr.path = \"err1\"" \
> j1echostderr-1 &&
id=$(cat j1echostderr-1 | flux job submit) &&
flux job wait-event $id clean &&
grep stderr:bar err1
'

test_expect_success HAVE_JQ 'flux-shell: run 1-task echo job (stderr to stdout file)' '
cat j1echostderr \
| $jq ".attributes.system.shell.options.output.stdout.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stdout.path = \"out2\"" \
> j1echostderr-2 &&
id=$(cat j1echostderr-2 | flux job submit) &&
flux job wait-event $id clean &&
grep stderr:bar out2
'

test_expect_success HAVE_JQ 'job-shell: run 1-task echo job (stdout file/stderr file)' '
cat j1echoboth \
| $jq ".attributes.system.shell.options.output.stdout.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stdout.path = \"out3\"" \
| $jq ".attributes.system.shell.options.output.stderr.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stderr.path = \"err3\"" \
> j1echoboth-3 &&
id=$(cat j1echoboth-3 | flux job submit) &&
flux job wait-event $id clean &&
grep stdout:baz out3 &&
grep stderr:baz err3
'

test_expect_success HAVE_JQ 'flux-shell: run 1-task echo job (stdout & stderr to stdout file)' '
cat j1echoboth \
| $jq ".attributes.system.shell.options.output.stdout.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stdout.path = \"out4\"" \
> j1echoboth-4 &&
id=$(cat j1echoboth-4 | flux job submit) &&
flux job wait-event $id clean &&
grep stdout:baz out4 &&
grep stderr:baz out4
'

test_expect_success HAVE_JQ 'job-shell: run 1-task echo job (stdout file/stderr kvs)' '
cat j1echoboth \
| $jq ".attributes.system.shell.options.output.stdout.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stdout.path = \"out5\"" \
| $jq ".attributes.system.shell.options.output.stderr.type = \"kvs\"" \
> j1echoboth-5 &&
id=$(cat j1echoboth-5 | flux job submit) &&
flux job wait-event $id clean &&
flux job attach $id 2> err5 &&
grep stdout:baz out5 &&
grep stderr:baz err5
'

test_expect_success HAVE_JQ 'job-shell: run 1-task echo job (stdout kvs/stderr file)' '
cat j1echoboth \
| $jq ".attributes.system.shell.options.output.stderr.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stderr.path = \"err6\"" \
> j1echoboth-6 &&
id=$(cat j1echoboth-6 | flux job submit) &&
flux job wait-event $id clean &&
flux job attach $id > out6 &&
grep stdout:baz out6 &&
grep stderr:baz err6
'

#
# 2 task output file tests
#

test_expect_success HAVE_JQ 'job-shell: run 2-task echo job (stdout file)' '
cat j2echostdout \
| $jq ".attributes.system.shell.options.output.stdout.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stdout.path = \"out7\"" \
| $jq ".attributes.system.shell.options.output.stdout.label = true" \
> j2echostdout-7 &&
id=$(cat j2echostdout-7 | flux job submit) &&
flux job wait-event $id clean &&
grep "0: stdout:foo" out7 &&
grep "1: stdout:foo" out7
'

test_expect_success HAVE_JQ 'job-shell: run 2-task echo job (stderr file)' '
cat j2echostderr \
| $jq ".attributes.system.shell.options.output.stderr.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stderr.path = \"err8\"" \
| $jq ".attributes.system.shell.options.output.stderr.label = true" \
> j2echostderr-8 &&
id=$(cat j2echostderr-8 | flux job submit) &&
flux job wait-event $id clean &&
grep "0: stderr:bar" err8 &&
grep "1: stderr:bar" err8
'

test_expect_success HAVE_JQ 'job-shell: run 2-task echo job (stderr to stdout file)' '
cat j2echostderr \
| $jq ".attributes.system.shell.options.output.stdout.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stdout.path = \"out9\"" \
| $jq ".attributes.system.shell.options.output.stdout.label = true" \
> j2echostderr-9 &&
id=$(cat j2echostderr-9 | flux job submit) &&
flux job wait-event $id clean &&
grep "0: stderr:bar" out9 &&
grep "1: stderr:bar" out9
'

test_expect_success HAVE_JQ 'job-shell: run 2-task echo job (stdout file/stderr file)' '
cat j2echoboth \
| $jq ".attributes.system.shell.options.output.stdout.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stdout.path = \"out10\"" \
| $jq ".attributes.system.shell.options.output.stdout.label = true" \
| $jq ".attributes.system.shell.options.output.stderr.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stderr.path = \"err10\"" \
| $jq ".attributes.system.shell.options.output.stderr.label = true" \
> j2echoboth-10 &&
id=$(cat j2echoboth-10 | flux job submit) &&
flux job wait-event $id clean &&
grep "0: stdout:baz" out10 &&
grep "1: stdout:baz" out10 &&
grep "0: stderr:baz" err10 &&
grep "1: stderr:baz" err10
'

test_expect_success HAVE_JQ 'job-shell: run 2-task echo job (stdout & stderr to stdout file)' '
cat j2echoboth \
| $jq ".attributes.system.shell.options.output.stdout.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stdout.path = \"out11\"" \
| $jq ".attributes.system.shell.options.output.stdout.label = true" \
> j2echoboth-11 &&
id=$(cat j2echoboth-11 | flux job submit) &&
flux job wait-event $id clean &&
grep "0: stdout:baz" out11 &&
grep "1: stdout:baz" out11 &&
grep "0: stderr:baz" out11 &&
grep "1: stderr:baz" out11
'

test_expect_success HAVE_JQ 'job-shell: run 2-task echo job (stdout file/stderr kvs)' '
cat j2echoboth \
| $jq ".attributes.system.shell.options.output.stdout.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stdout.path = \"out12\"" \
| $jq ".attributes.system.shell.options.output.stdout.label = true" \
| $jq ".attributes.system.shell.options.output.stderr.type = \"kvs\"" \
> j2echoboth-12 &&
id=$(cat j2echoboth-12 | flux job submit) &&
flux job wait-event $id clean &&
flux job attach -l $id 2> err12 &&
grep "0: stdout:baz" out12 &&
grep "1: stdout:baz" out12 &&
grep "0: stderr:baz" err12 &&
grep "1: stderr:baz" err12
'

test_expect_success HAVE_JQ 'job-shell: run 2-task echo job (stdout kvs/stderr file)' '
cat j2echoboth \
| $jq ".attributes.system.shell.options.output.stderr.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stderr.path = \"err13\"" \
| $jq ".attributes.system.shell.options.output.stderr.label = true" \
> j2echoboth-13 &&
id=$(cat j2echoboth-13 | flux job submit) &&
flux job wait-event $id clean &&
flux job attach -l $id > out13 &&
grep "0: stdout:baz" out13 &&
grep "1: stdout:baz" out13 &&
grep "0: stderr:baz" err13 &&
grep "1: stderr:baz" err13
'

#
# output file mustache tests
#

test_expect_success HAVE_JQ 'job-shell: run 1-task echo job (mustache id stdout file/stderr file)' '
cat j1echoboth \
| $jq ".attributes.system.shell.options.output.stdout.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stdout.path = \"out{{id}}\"" \
| $jq ".attributes.system.shell.options.output.stderr.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stderr.path = \"err{{id}}\"" \
> j1echoboth-14 &&
id=$(cat j1echoboth-14 | flux job submit) &&
flux job wait-event $id clean &&
grep stdout:baz out${id} &&
grep stderr:baz err${id}
'

test_expect_success HAVE_JQ 'flux-shell: run 1-task echo job (mustache id stdout & stderr to stdout file)' '
cat j1echoboth \
| $jq ".attributes.system.shell.options.output.stdout.type = \"file\"" \
| $jq ".attributes.system.shell.options.output.stdout.path = \"out{{id}}\"" \
> j1echoboth-15 &&
id=$(cat j1echoboth-15 | flux job submit) &&
flux job wait-event $id clean &&
grep stdout:baz out${id}
grep stderr:baz out${id}
'

test_expect_success 'job-shell: unload job-exec & sched-simple modules' '
flux module remove -r 0 job-exec &&
flux module remove -r 0 sched-simple &&
Expand Down

0 comments on commit ca91585

Please sign in to comment.