Skip to content

Commit

Permalink
testsuite: enhance shell tests with .so plugins
Browse files Browse the repository at this point in the history
Run test with real shell plugins in testsuite.
  • Loading branch information
grondo committed Sep 20, 2019
1 parent b52b4c5 commit aaf7262
Showing 1 changed file with 78 additions and 5 deletions.
83 changes: 78 additions & 5 deletions t/t2603-job-shell-initrc.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test_under_flux 2
FLUX_SHELL="${FLUX_BUILD_DIR}/src/shell/flux-shell"

INITRC_TESTDIR="${SHARNESS_TEST_SRCDIR}/shell/initrc"
INITRC_PLUGINPATH="${SHARNESS_TEST_DIRECTORY}/shell/plugins/.libs"

# test initrc files need to be able to find fluxometer.lua:
export LUA_PATH="$LUA_PATH;${SHARNESS_TEST_DIRECTORY}/?.lua"
Expand All @@ -32,7 +33,8 @@ test_expect_success 'flux-shell: initrc: failed initrc causes termination' '
=
EOT
test_expect_code 1 ${FLUX_SHELL} -v -s -r 0 -j j1 -R R1 \
--initrc=${name}.lua 0 2>&1 | tee ${name}.log &&
--initrc=${name}.lua 0 > ${name}.log 2>&1 &&
test_debug "cat ${name}.log" &&
grep "unexpected symbol" ${name}.log
'
test_expect_success 'flux-shell: initrc: access task in non-task context fails' '
Expand All @@ -41,7 +43,8 @@ test_expect_success 'flux-shell: initrc: access task in non-task context fails'
print (task.info)
EOT
test_expect_code 1 ${FLUX_SHELL} -v -s -r 0 -j j1 -R R1 \
--initrc=${name}.lua 0 2>&1 | tee ${name}.log &&
--initrc=${name}.lua 0 > ${name}.log 2>&1 &&
test_debug "cat ${name}.log" &&
grep "attempt to access task outside of task context" ${name}.log
'
test_expect_success 'flux-shell: initrc: bad plugin.register usage fails' '
Expand All @@ -50,7 +53,8 @@ test_expect_success 'flux-shell: initrc: bad plugin.register usage fails' '
plugin.register {}
EOT
test_expect_code 1 ${FLUX_SHELL} -v -s -r 0 -j j1 -R R1 \
--initrc=${name}.lua 0 2>&1 | tee ${name}.log &&
--initrc=${name}.lua 0 > ${name}.log 2>&1 &&
test_debug "cat ${name}.log" &&
grep "required handlers table missing" ${name}.log
'
test_expect_success 'flux-shell: initrc: return false from plugin aborts shell' '
Expand All @@ -64,7 +68,8 @@ test_expect_success 'flux-shell: initrc: return false from plugin aborts shell'
}
EOT
test_expect_code 1 ${FLUX_SHELL} -v -s -r 0 -j j1 -R R1 \
--initrc=${name}.lua 0 2>&1 | tee ${name}.log &&
--initrc=${name}.lua 0 > ${name}.log 2>&1 &&
test_debug "cat ${name}.log" &&
grep "plugin.*: shell.init failed" ${name}.log
'

Expand All @@ -74,6 +79,74 @@ for initrc in ${INITRC_TESTDIR}/tests/*.lua; do
'
done


test_expect_success 'flux-shell: initrc: loads single .so successfully' '
name=conftest-success &&
cat >${name}.lua <<-EOT &&
plugin.searchpath = "${INITRC_PLUGINPATH}"
plugin.load { file = "dummy.so", conf = { result = 0 } }
EOT
test_expect_code 0 ${FLUX_SHELL} -v -s -r 0 -j j1 -R R1 \
--initrc=${name}.lua 0 > ${name}.log 2>&1 &&
test_debug "cat ${name}.log" &&
grep "dummy: OK result=0" ${name}.log
'
test_expect_success 'flux-shell: initrc: script fails on plugin.load failure' '
name=conftest-failure &&
cat >${name}.lua <<-EOT &&
plugin.searchpath = "${INITRC_PLUGINPATH}"
plugin.load { file = "dummy.so", conf = { result = -1 } }
EOT
test_expect_code 1 ${FLUX_SHELL} -v -s -r 0 -j j1 -R R1 \
--initrc=${name}.lua 0 > ${name}.log 2>&1 &&
test_debug "cat ${name}.log" &&
grep "dummy: OK result=-1" ${name}.log
'
test_expect_success 'flux-shell: initrc: plugin pattern nomatch not fatal' '
name=nomatch-noprob &&
cat >${name}.lua <<-EOT &&
plugin.load { file = "nofile*.so" }
EOT
test_expect_code 0 ${FLUX_SHELL} -v -s -r 0 -j j1 -R R1 \
--initrc=${name}.lua 0 > ${name}.log 2>&1 &&
test_debug "cat ${name}.log" &&
grep "0: Hi" ${name}.log
'
test_expect_success 'flux-shell: initrc: plugin nonpattern nomatch fatal' '
name=nomatch-prob &&
cat >${name}.lua <<-EOT &&
plugin.load { file = "nofile.so" }
EOT
test_expect_code 1 ${FLUX_SHELL} -v -s -r 0 -j j1 -R R1 \
--initrc=${name}.lua 0 > ${name}.log 2>&1 &&
test_debug "cat ${name}.log" &&
grep "nofile.so: File not found" ${name}.log
'
test_expect_success 'flux-shell: initrc: plugin.load passes conf to plugin' '
name=conftest &&
cat >${name}.lua <<-EOT &&
plugin.searchpath = "${INITRC_PLUGINPATH}"
plugin.load { file = "conftest.so",
conf = { keys = { "one", "two", "three" },
one = "foo",
two = "two",
three = "bar" }
}
EOT
${FLUX_SHELL} -v -s -r 0 -j j1 -R R1 \
--initrc=${name}.lua 0 > ${name}.log 2>&1 &&
test_debug "cat ${name}.log" &&
grep "conftest: one=foo" ${name}.log &&
grep "conftest: two=two" ${name}.log &&
grep "conftest: three=bar" ${name}.log
'
test_expect_success 'flux-shell: initrc: load invalid args plugins' '
name=invalid-args &&
cat >${name}.lua <<-EOT &&
plugin.searchpath = "${INITRC_PLUGINPATH}"
plugin.load { file = "invalid-args.so" }
EOT
${FLUX_SHELL} -v -s -r 0 -j j1 -R R1 \
--initrc=${name}.lua 0
'

test_done

0 comments on commit aaf7262

Please sign in to comment.