From c5fe6a1f5fd958b85ef23e7e486501ff20d67118 Mon Sep 17 00:00:00 2001 From: rigzba21 Date: Fri, 6 Aug 2021 07:53:49 -0400 Subject: [PATCH] adding test to check if container deleted files on container bind mount --- base-notebook/test/test_container_options.py | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/base-notebook/test/test_container_options.py b/base-notebook/test/test_container_options.py index 91cce1a8..c0d163c7 100644 --- a/base-notebook/test/test_container_options.py +++ b/base-notebook/test/test_container_options.py @@ -187,3 +187,29 @@ def test_group_add(container, tmpdir): assert rv == 0 or rv["StatusCode"] == 0 logs = c.logs(stdout=True).decode("utf-8") assert "uid=1010 gid=1010 groups=1010,100(users)" in logs + +def test_container_not_delete_bind_mount(container, tmp_path): + """Container should not delete files when using the -v bind mount flag + and mappint to /home/jovyan. + """ + d = tmp_path / "data" + d.mkdir() + p = d / "foo.txt" + p.write_text("some-content") + + c = container.run( + tty=True, + user="root", + working_dir="/home/", + environment=[ + "NB_USER=user", + "CHOWN_HOME=yes", + ], + volumes={ d : {'bind': '/home/jovyan/data', 'mode': 'rw'}}, + command=["start.sh", "jupyter", "lab"] + ) + + time.sleep(10) + + assert p.read_text() == "some-content" + assert len(list(tmp_path.iterdir())) == 1