Skip to content

Commit 61c8c01

Browse files
committed
Test automatic loading of /etc/jupyterhub.d files
1 parent 8d95508 commit 61c8c01

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

dev-config.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ hub:
5151
memory: 0
5252
cpu: 0
5353
extraFiles:
54+
my_config:
55+
name: my_config.py
56+
mountPath: /etc/jupyterhub.d
57+
stringData: |
58+
with open("/tmp/created-by-extra-files-config.txt", "w") as f:
59+
f.write("hello world!")
5460
binaryData.txt: &binaryData
5561
mountPath: /tmp/
5662
mode: 0666

jupyterhub/schema.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ properties:
272272
```yaml
273273
hub:
274274
extraFiles:
275+
# Explicitly set the name to avoid having the file key include a .
276+
# as it can hamper our ability to use --set-file.
275277
my_image:
276278
name: my_image.png
277279
mountPath: /usr/local/share/jupyterhub/static/

tests/test_spawn.py

+21
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,27 @@ def test_hub_mounted_extra_files():
153153
), f"The hub.extraFiles configuration doesn't seem to have been honored!"
154154

155155

156+
def test_hub_etc_jupyterhub_d_folder():
157+
"""
158+
Tests that the extra jupyterhub config file put into /etc/jupyterhub.d by
159+
the hub.extraFiles configuration was loaded.
160+
"""
161+
c = subprocess.run(
162+
[
163+
"kubectl",
164+
"exec",
165+
"deploy/hub",
166+
"--",
167+
"sh",
168+
"-c",
169+
"cat /tmp/created-by-extra-files-config.txt | grep -- 'hello world' || exit 1",
170+
]
171+
)
172+
assert (
173+
c.returncode == 0
174+
), f"The hub.extraFiles configuration should have mounted a config file to /etc/jupyterhub.d which should have been loaded to write a dummy file for us!"
175+
176+
156177
def test_hub_api_request_user_spawn(
157178
api_request, jupyter_user, request_data, pebble_acme_ca_cert
158179
):

0 commit comments

Comments
 (0)