From 8faa637b1ee31601f368e07650a26202f6edc68c Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Sat, 31 Mar 2018 09:57:22 -0700 Subject: [PATCH] t/t2000-wreck-env.t: add tests for wreck global environment Add tests for wreck global environment lwj.environ, and corresponding commands to manipulate and use that environemnt. Note: the test is split from t2000-wreck.t but still prefixed with t2000 for easier test devlepment, parallel tests, etc. Since this is short-lived code, it is probably ok for now. --- t/Makefile.am | 2 ++ t/t2000-wreck-env.t | 51 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100755 t/t2000-wreck-env.t diff --git a/t/Makefile.am b/t/Makefile.am index 93a975bba0e7..a14888e581ac 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -61,6 +61,7 @@ TESTS = \ t1104-kz.t \ t1105-proxy.t \ t2000-wreck.t \ + t2000-wreck-env.t \ t2001-jsc.t \ t2002-pmi.t \ t2003-recurse.t \ @@ -137,6 +138,7 @@ check_SCRIPTS = \ t1104-kz.t \ t1105-proxy.t \ t2000-wreck.t \ + t2000-wreck-env.t \ t2001-jsc.t \ t2002-pmi.t \ t2003-recurse.t \ diff --git a/t/t2000-wreck-env.t b/t/t2000-wreck-env.t new file mode 100755 index 000000000000..ee9407eea6bb --- /dev/null +++ b/t/t2000-wreck-env.t @@ -0,0 +1,51 @@ +#!/bin/sh +# + +test_description='Test basic wreck functionality + +Test basic functionality of wreckrun facility. +' + +. `dirname $0`/sharness.sh +SIZE=${FLUX_TEST_SIZE:-4} +test_under_flux ${SIZE} wreck + +# Return the previous jobid +last_job_id() { + flux wreck last-jobid +} +# Return previous job path in kvs +last_job_path() { + flux wreck last-jobid -p +} + +test_expect_success 'flux-wreck: setenv/getenv works' ' + flux wreck setenv FOO=BAR && + flux wreck getenv FOO +' +test_expect_success 'flux-wreck: unsetenv works' ' + flux wreck unsetenv FOO && + test "$(flux wreck getenv FOO)" = "FOO=" +' +test_expect_success 'flux-wreck: setenv all' ' + flux wreck setenv all && + flux env /usr/bin/env | sort | grep -ve FLUX_URI -e HOSTNAME -e ENVIRONMENT > env.expected && + flux wreck getenv | sort > env.output && + test_cmp env.expected env.output +' +test_expect_success 'wreck: global lwj.environ exported to jobs' ' + flux wreck setenv FOO=bar && + test "$(flux wreckrun -n1 printenv FOO)" = "bar" +' +test_expect_success 'wreck: wreckrun exports environment vars not in global env' ' + BAR=baz flux wreckrun -n1 printenv BAR > printenv.out && + test "$(cat printenv.out)" = "baz" +' +test_expect_success 'wreck: wreckrun --skip-env works' ' + ( export BAR=baz && + test_must_fail flux wreckrun --skip-env -n1 printenv BAR > printenv2.out + ) && + test "$(cat printenv2.out)" = "" +' + +test_done