Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FAST_BUILD] Test unset in run-hooks #2022

Merged
merged 1 commit into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/docker-stacks-foundation/run-hooks-unset/a.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

export MY_VAR=123
echo "Inside a.sh MY_VAR variable has ${MY_VAR} value"
7 changes: 7 additions & 0 deletions tests/docker-stacks-foundation/run-hooks-unset/b.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

echo "Inside b.sh MY_VAR variable has ${MY_VAR} value"
echo "Unsetting MY_VAR"
unset MY_VAR
5 changes: 5 additions & 0 deletions tests/docker-stacks-foundation/run-hooks-unset/c.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

echo "Inside c.sh MY_VAR variable has ${MY_VAR} value"
22 changes: 22 additions & 0 deletions tests/docker-stacks-foundation/test_run_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,25 @@ def test_run_hooks_with_failures(container: TrackedContainer) -> None:
)

assert "OTHER_VAR=456" in logs


def test_run_hooks_unset(container: TrackedContainer) -> None:
host_data_dir = THIS_DIR / "run-hooks-unset"
cont_data_dir = "/home/jovyan/data"
# https://forums.docker.com/t/all-files-appear-as-executable-in-file-paths-using-bind-mount/99921
# Unfortunately, Docker treats all files in mounter dir as executable files
# So we make a copy of mounted dir inside a container
command = (
"cp -r /home/jovyan/data/ /home/jovyan/data-copy/ &&"
"source /usr/local/bin/run-hooks.sh /home/jovyan/data-copy/"
)
logs = container.run_and_wait(
timeout=5,
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}},
tty=True,
command=["bash", "-c", command],
)
assert "Inside a.sh MY_VAR variable has 123 value" in logs
assert "Inside b.sh MY_VAR variable has 123 value" in logs
assert "Unsetting MY_VAR" in logs
assert "Inside c.sh MY_VAR variable has value" in logs