From c0b23fdd7372ff6fc0921c072ebac793fcecf3eb Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Tue, 12 Sep 2023 16:06:34 +0200 Subject: [PATCH] test env variables for containers --- test/functional/tools/job_environment_default.xml | 4 ++-- .../tools/job_environment_default_legacy.xml | 4 ++-- .../tools/job_environment_explicit_isolated_home.xml | 4 +++- .../tools/job_environment_explicit_shared_home.xml | 4 +++- test/integration/dockerized_job_conf.yml | 2 +- test/integration/simple_job_conf.xml | 3 +++ test/integration/singularity_job_conf.yml | 2 +- test/integration/test_containerized_jobs.py | 12 ++++++++---- test/integration/test_job_environments.py | 6 +++++- 9 files changed, 28 insertions(+), 13 deletions(-) diff --git a/test/functional/tools/job_environment_default.xml b/test/functional/tools/job_environment_default.xml index 700e4419432f..4ce47e1680d8 100644 --- a/test/functional/tools/job_environment_default.xml +++ b/test/functional/tools/job_environment_default.xml @@ -12,8 +12,8 @@ echo \$(pwd) > '$pwd' && echo "\$HOME" > '$home' && echo "\$TMP" > '$tmp' && echo "\$SOME_ENV_VAR" > '$some_env_var' && -echo "\$JOBCONF_ENV_VAR" > '$jobconf_env_var' && -echo "\$CONTAINER_ENV_VAR" > '$container_env_var' && +echo "\${JOBCONF_ENV_VAR:-UNSET}" > '$jobconf_env_var' && +echo "\${CONTAINER_ENV_VAR:-UNSET}" > '$container_env_var' && touch "\$_GALAXY_JOB_TMP_DIR/tmp_test" && touch "\$HOME/home_test" && diff --git a/test/functional/tools/job_environment_default_legacy.xml b/test/functional/tools/job_environment_default_legacy.xml index 6a2fec19d6d1..b63972fa642b 100644 --- a/test/functional/tools/job_environment_default_legacy.xml +++ b/test/functional/tools/job_environment_default_legacy.xml @@ -10,8 +10,8 @@ echo \$(pwd) > '$pwd' && echo "\$HOME" > '$home' && echo "\$TMP" > '$tmp' && echo "\$SOME_ENV_VAR" > '$some_env_var' && -echo "\$JOBCONF_ENV_VAR" > '$jobconf_env_var' && -echo "\$CONTAINER_ENV_VAR" > '$container_env_var' && +echo "\${JOBCONF_ENV_VAR:-UNSET}" > '$jobconf_env_var' && +echo "\${CONTAINER_ENV_VAR:-UNSET}" > '$container_env_var' && touch "\${TMP:-/tmp}/job_tmp" && touch "\${TEMP:-/tmp}/job_temp" && diff --git a/test/functional/tools/job_environment_explicit_isolated_home.xml b/test/functional/tools/job_environment_explicit_isolated_home.xml index d09713595dff..48f5ed2398aa 100644 --- a/test/functional/tools/job_environment_explicit_isolated_home.xml +++ b/test/functional/tools/job_environment_explicit_isolated_home.xml @@ -10,7 +10,8 @@ echo \$(pwd) > '$pwd' && echo "\$HOME" > '$home' && echo "\$TMP" > '$tmp' && echo "\$SOME_ENV_VAR" > '$some_env_var' && -echo "\$JOBCONF_ENV_VAR" > '$jobconf_env_var' && +echo "\${JOBCONF_ENV_VAR:-UNSET}" > '$jobconf_env_var' && +echo "\${CONTAINER_ENV_VAR:-UNSET}" > '$container_env_var' && touch "\${TMP:-/tmp}/job_tmp" && touch "\${TEMP:-/tmp}/job_temp" && @@ -26,6 +27,7 @@ touch "\${TMPDIR:-/tmp}/job_tmpdir" + diff --git a/test/functional/tools/job_environment_explicit_shared_home.xml b/test/functional/tools/job_environment_explicit_shared_home.xml index 680981dfb449..bf7bb101d0f8 100644 --- a/test/functional/tools/job_environment_explicit_shared_home.xml +++ b/test/functional/tools/job_environment_explicit_shared_home.xml @@ -10,7 +10,8 @@ echo \$(pwd) > '$pwd' && echo "\$HOME" > '$home' && echo "\$TMP" > '$tmp' && echo "\$SOME_ENV_VAR" > '$some_env_var' && -echo "\$JOBCONF_ENV_VAR" > '$jobconf_env_var' && +echo "\${JOBCONF_ENV_VAR:-UNSET}" > '$jobconf_env_var' && +echo "\${CONTAINER_ENV_VAR:-UNSET}" > '$container_env_var' && touch "\${TMP:-/tmp}/job_tmp" && touch "\${TEMP:-/tmp}/job_temp" && @@ -26,6 +27,7 @@ touch "\${TMPDIR:-/tmp}/job_tmpdir" + diff --git a/test/integration/dockerized_job_conf.yml b/test/integration/dockerized_job_conf.yml index 5c8c37a35604..5b17eb57ae51 100644 --- a/test/integration/dockerized_job_conf.yml +++ b/test/integration/dockerized_job_conf.yml @@ -14,7 +14,7 @@ execution: value: 'YEAH' - execute: 'true' # just check that this does not confuse env setup docker_enabled: true - docker_env_CONTAINER_VAR: "DOCKER_VAR_VALUE" + docker_env_CONTAINER_ENV_VAR: "CONTAINER_VAR_VALUE" require_container: true tmp_dir: '$(mktemp -d)' local_docker_inline_container_resolvers: diff --git a/test/integration/simple_job_conf.xml b/test/integration/simple_job_conf.xml index 032c2b0fec16..649170f2ff64 100644 --- a/test/integration/simple_job_conf.xml +++ b/test/integration/simple_job_conf.xml @@ -10,6 +10,9 @@ + YEAH + CONTAINER_VAR_VALUE + CONTAINER_VAR_VALUE diff --git a/test/integration/singularity_job_conf.yml b/test/integration/singularity_job_conf.yml index 8ea57e90ab58..6f5e4f182c86 100644 --- a/test/integration/singularity_job_conf.yml +++ b/test/integration/singularity_job_conf.yml @@ -13,7 +13,7 @@ execution: - name: 'JOBCONF_ENV_VAR' value: 'YEAH' singularity_enabled: true - singularity_env_CONTAINER_VAR: "SINGULARITY_VAR_VALUE" + singularity_env_CONTAINER_ENV_VAR: "CONTAINER_VAR_VALUE" # Since tests run in /tmp/ , we apparently need to forbid the default mounting of /tmp singularity_run_extra_arguments: '--no-mount tmp' require_container: true diff --git a/test/integration/test_containerized_jobs.py b/test/integration/test_containerized_jobs.py index 4c7f784456c5..24967c1862b3 100644 --- a/test/integration/test_containerized_jobs.py +++ b/test/integration/test_containerized_jobs.py @@ -122,7 +122,8 @@ def test_container_job_environment(self) -> None: assert job_env.pwd.endswith("/working") assert job_env.home.startswith(self.jobs_directory) assert job_env.home.endswith("/home") - assert job_env.jobconf_env_var == "YEAH" + assert job_env.jobconf_env_var == "UNSET" + assert job_env.container_env_var == "CONTAINER_VAR_VALUE" def test_container_job_environment_legacy(self) -> None: """ @@ -140,7 +141,8 @@ def test_container_job_environment_legacy(self) -> None: assert job_env.pwd.endswith("/working") assert not job_env.home.startswith(self.jobs_directory) assert not job_env.home.endswith("/home") - assert job_env.jobconf_env_var == "YEAH" + assert job_env.jobconf_env_var == "UNSET" + assert job_env.container_env_var == "CONTAINER_VAR_VALUE" def test_container_job_environment_explicit_shared_home(self) -> None: """ @@ -153,7 +155,8 @@ def test_container_job_environment_explicit_shared_home(self) -> None: assert job_env.pwd.endswith("/working") assert not job_env.home.startswith(self.jobs_directory) assert not job_env.home.endswith("/home"), job_env.home - assert job_env.jobconf_env_var == "YEAH" + assert job_env.jobconf_env_var == "UNSET" + assert job_env.container_env_var == "CONTAINER_VAR_VALUE" def test_container_job_environment_explicit_isolated_home(self) -> None: """ @@ -166,7 +169,8 @@ def test_container_job_environment_explicit_isolated_home(self) -> None: assert job_env.pwd.endswith("/working") assert job_env.home.startswith(self.jobs_directory) assert job_env.home.endswith("/home"), job_env.home - assert job_env.jobconf_env_var == "YEAH" + assert job_env.jobconf_env_var == "UNSET" + assert job_env.container_env_var == "CONTAINER_VAR_VALUE" def test_build_mulled(self) -> None: """ diff --git a/test/integration/test_job_environments.py b/test/integration/test_job_environments.py index 100b5c532c05..d3bb0c4485ee 100644 --- a/test/integration/test_job_environments.py +++ b/test/integration/test_job_environments.py @@ -63,7 +63,7 @@ def _environment_properties(self, history_id): tmp = self.dataset_populator.get_history_dataset_content(history_id, hid=5).strip() some_env = self.dataset_populator.get_history_dataset_content(history_id, hid=6).strip() jobconf_env_var = self.dataset_populator.get_history_dataset_content(history_id, hid=7).strip() - container_env_var = self.dataset_populator.get_history_dataset_content(history_id, hid=7).strip() + container_env_var = self.dataset_populator.get_history_dataset_content(history_id, hid=8).strip() return JobEnvironmentProperties(user_id, group_id, pwd, home, tmp, some_env, jobconf_env_var, container_env_var) def _check_completed_history(self, history_id): @@ -92,6 +92,10 @@ def test_default_environment_1801(self): assert job_env.pwd.startswith(self.jobs_directory) assert job_env.pwd.endswith("/working") + # check that env variables job + assert job_env.jobconf_env_var =="YEAH" + assert job_env.container_env_var =="UNSET" + # Newer tools get isolated home directories in job_directory/home job_directory = os.path.dirname(job_env.pwd) assert job_env.home == os.path.join(job_directory, "home"), job_env.home