From 25ee2a2cff6a777843a61b0c275cd6011fed53be Mon Sep 17 00:00:00 2001 From: Weii Wang Date: Thu, 6 Jul 2023 00:35:53 +0800 Subject: [PATCH] Update ops/testing.py documents Co-authored-by: Ben Hoyt --- ops/testing.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ops/testing.py b/ops/testing.py index eb56d8933..e254e5f84 100755 --- a/ops/testing.py +++ b/ops/testing.py @@ -1425,15 +1425,17 @@ def trigger_secret_expiration(self, secret_id: str, revision: int, *, def get_filesystem_root(self, container: Union[str, Container]) -> pathlib.Path: """Return the path of the temporary directory the harness will use to simulate the container filesystem. - In the container runtime, each container is running in an isolated root filesystem. - To simulate this behavior, the testing harness creates a temporary directory for - each container. Any filesystem-related API calls through Pebble will be translated - and mapped to this temporary directory, as if the temporary directory is the container's - filesystem root. This process is quite similar to the ``chroot`` command. You should - treat the return directory as the root directory (``/``) of the container in your - unit tests. The testing harness will not create any files or directories inside the - simulated container's root directory. You should populate the container's root directory - with any files or directories necessary for the charm. + In a real container runtime, each container has an isolated root filesystem. + To simulate this behaviour, the testing harness manages a temporary directory for + each container. Any Pebble filesystem API calls will be translated + and mapped to this directory, as if the directory was the container's + filesystem root. + + This process is quite similar to the ``chroot`` command. Charm tests should + treat the returned directory as the container's root directory (``/``). + The testing harness will not create any files or directories inside the + simulated container's root directory; it's up to the test to populate the container's root directory + with any files or directories the charm needs. Example usage: