-
Notifications
You must be signed in to change notification settings - Fork 26
Description
When running an integration test that uses saltfactories.daemons.container.SaltDaemon, the Python log messages emitted by the daemon do not show up in the test log. IIUC, this is because Python does not see the entry_points.txt for pytest-salt-factories so it doesn't know that it should load saltfactories.utils.saltext.log_handlers.pytest_log_handler.
One solution (that I tested successfully) is to pip install pytest-salt-factories when building the Docker image or after starting the Docker container. This assumes that pip is installed in the image, pip runs with sufficient privileges to install the package, and the version of pytest-salt-factories installed in the container is compatible with the version loaded by nox for the test.
Another solution (untested) might be to bind mount CODE_ROOT_DIR.parent instead of CODE_ROOT_DIR and add it to Python's sys.path when launching the daemon. This assumes that all of the packages in that directory are compatible with the container, which might be running a different version of Python (or even a different machine architecture).
Maybe another solution (untested) would be to bind mount CODE_ROOT_DIR.parent / "pytest_salt_factories-1.0.0rc20.dist-info" (where the specific .dist-info dir is discovered programmatically) in addition to CODE_ROOT_DIR, and add CODE_ROOT_DIR.parent to sys.path. This assumes that the pytest-salt-factories distribution is binary compatible with the container, which seems likely.
Perhaps the best solution would be to create a virtualenv inside the container and pip install all daemon dependencies plus pytest-salt-factories before starting the daemon.
Additional context: saltstack/salt#62791 (comment)