Skip to content

Commit

Permalink
test env variables for containers
Browse files Browse the repository at this point in the history
  • Loading branch information
bernt-matthias committed Sep 12, 2023
1 parent 6105547 commit e5bcf1c
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 13 deletions.
4 changes: 2 additions & 2 deletions test/functional/tools/job_environment_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Expand Down
4 changes: 2 additions & 2 deletions test/functional/tools/job_environment_default_legacy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Expand All @@ -26,6 +27,7 @@ touch "\${TMPDIR:-/tmp}/job_tmpdir"
<data name="tmp" format="txt" label="tmp" />
<data name="some_env_var" format="txt" label="env_var" />
<data name="jobconf_env_var" format="txt" label="jobconf_env_var" />
<data name="container_env_var" format="txt" label="container_env_var" />
</outputs>
<tests>
</tests>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Expand All @@ -26,6 +27,7 @@ touch "\${TMPDIR:-/tmp}/job_tmpdir"
<data name="tmp" format="txt" label="tmp" />
<data name="some_env_var" format="txt" label="env_var" />
<data name="jobconf_env_var" format="txt" label="jobconf_env_var" />
<data name="container_env_var" format="txt" label="container_env_var" />
</outputs>
<tests>
</tests>
Expand Down
2 changes: 1 addition & 1 deletion test/integration/dockerized_job_conf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions test/integration/simple_job_conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

<destinations>
<destination id="local_dest" runner="local">
<env id="JOBCONF_ENV_VAR">YEAH</env>
<param id="docker_env_CONTAINER_VAR">CONTAINER_VAR_VALUE</param>
<param id="singularity_env_CONTAINER_VAR">CONTAINER_VAR_VALUE</param>
</destination>
</destinations>

Expand Down
2 changes: 1 addition & 1 deletion test/integration/singularity_job_conf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions test/integration/test_containerized_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand All @@ -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:
"""
Expand All @@ -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:
"""
Expand All @@ -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:
"""
Expand Down
6 changes: 5 additions & 1 deletion test/integration/test_job_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e5bcf1c

Please sign in to comment.