Skip to content

Commit

Permalink
Install Salt in the container before starting any of Salt's daemons
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Algarvio <[email protected]>
  • Loading branch information
s0undt3ch committed Oct 12, 2023
1 parent e0bc1bd commit b213670
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
16 changes: 0 additions & 16 deletions tests/pytests/integration/modules/test_virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import pytest

import salt.version
from tests.support.virt import SaltVirtMinionContainerFactory

docker = pytest.importorskip("docker")
Expand All @@ -20,19 +19,6 @@
]


def _install_salt_dependencies(container):
dependencies = []
for package, version in salt.version.dependency_information():
if package.lower() not in ("tornado", "packaging", "looseversion"):
# These are newer base dependencies which the container might not
# yet have
continue
dependencies.append(f"{package.lower()}=={version}")
if dependencies:
ret = container.run("python3", "-m", "pip", "install", *dependencies)
log.debug("Install missing dependecies ret: %s", ret)


@pytest.fixture(scope="module")
def virt_minion_0_id():
return "virt-minion-0"
Expand Down Expand Up @@ -73,7 +59,6 @@ def virt_minion_0(
skip_on_pull_failure=True,
skip_if_docker_client_not_connectable=True,
)
factory.before_start(_install_salt_dependencies, factory)
factory.after_terminate(
pytest.helpers.remove_stale_minion_key, salt_master, factory.id
)
Expand Down Expand Up @@ -111,7 +96,6 @@ def virt_minion_1(
skip_on_pull_failure=True,
skip_if_docker_client_not_connectable=True,
)
factory.before_start(_install_salt_dependencies, factory)
factory.after_terminate(
pytest.helpers.remove_stale_minion_key, salt_master, factory.id
)
Expand Down
9 changes: 9 additions & 0 deletions tests/support/virt.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import time
import uuid

Expand All @@ -7,6 +8,13 @@

from tests.conftest import CODE_DIR

log = logging.getLogger(__name__)


def _install_salt_in_container(container):
ret = container.run("python3", "-m", "pip", "install", "/salt")
log.debug("Install Salt in the container: %s", ret)


@attr.s(kw_only=True, slots=True)
class SaltVirtMinionContainerFactory(SaltMinion):
Expand Down Expand Up @@ -64,6 +72,7 @@ def __attrs_post_init__(self):
self.container_start_check(self._check_script_path_exists)
for port in (self.sshd_port, self.libvirt_tcp_port, self.libvirt_tls_port):
self.check_ports[port] = port
self.before_start(_install_salt_in_container, self, on_container=False)

def _check_script_path_exists(self, timeout_at):
while time.time() <= timeout_at:
Expand Down

0 comments on commit b213670

Please sign in to comment.