Skip to content

Commit

Permalink
Update ops/testing.py documents
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Hoyt <[email protected]>
  • Loading branch information
weiiwang01 and benhoyt committed Jul 5, 2023
1 parent 6c0c537 commit 25ee2a2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ops/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 25ee2a2

Please sign in to comment.