Skip to content

Commit

Permalink
Don't build the salt minion container during test runs
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
  • Loading branch information
s0undt3ch committed Aug 22, 2022
1 parent c96e61a commit 212019c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 54 deletions.
1 change: 1 addition & 0 deletions changelog/136.trivial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ CI and internal changes:
* Lock system tests to a version of nox that still works
* Bump python version to 3.9 for lint workflow
* Bumped pylint requirement to `2.14.5` and cleaned up issues
* Don't build the salt minion container during test runs, pull an existing container.
56 changes: 2 additions & 54 deletions tests/integration/factories/daemons/container/test_minion.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import io
import logging

import _pytest._version
import pytest
import salt.version

from saltfactories.daemons.container import SaltMinion
from saltfactories.utils import random_string
Expand All @@ -26,20 +24,6 @@
]


DOCKERFILE = """
FROM {from_container}
ENV LANG=en_US.UTF8
ENV VIRTUAL_ENV={virtualenv_path}
RUN virtualenv --python=python3 $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip install {requirements}
CMD . $VIRTUAL_ENV/bin/activate
"""


@pytest.fixture(scope="session")
def docker_client(salt_factories, docker_client):
if salt_factories.system_service:
Expand Down Expand Up @@ -88,41 +72,6 @@ def salt_factories_config(salt_factories_config, host_docker_network_ip_address)
return config


@pytest.fixture(scope="module")
def container_virtualenv_path():
return "/tmp/venv"


@pytest.fixture(scope="module")
def minion_image_name(salt_version):
return "salt-{}".format(salt_version)


@pytest.fixture(scope="module")
def minion_image(docker_client, salt_version, container_virtualenv_path, minion_image_name):
salt_versions_information = salt.version.versions_information()
requirements = ""
for name in ("PyZMQ", "Jinja2", "PyYAML"):
version = salt_versions_information["Dependency Versions"].get(name)
if version:
requirements += " {}=={}".format(name.lower(), version)
requirements += " salt=={}".format(salt_version)
dockerfile_contents = DOCKERFILE.format(
from_container="saltstack/ci-centos-7",
requirements=requirements.strip(),
virtualenv_path=container_virtualenv_path,
)
log.debug("GENERATED Dockerfile:\n%s", dockerfile_contents)
dockerfile_fh = io.BytesIO(dockerfile_contents.encode("utf-8"))
_, logs = docker_client.images.build(
fileobj=dockerfile_fh,
tag=minion_image_name,
pull=True,
)
log.debug("Docker container build logs:\n%s", logs)
return minion_image_name


@pytest.fixture(scope="function")
def minion_id(salt_version):
return random_string(
Expand All @@ -132,7 +81,7 @@ def minion_id(salt_version):


@pytest.fixture(scope="module")
def salt_master(salt_factories, minion_image, host_docker_network_ip_address):
def salt_master(salt_factories, host_docker_network_ip_address):
config_overrides = {
"interface": host_docker_network_ip_address,
"log_level_logfile": "quiet",
Expand All @@ -152,7 +101,6 @@ def salt_minion(
minion_id,
salt_master,
docker_client,
minion_image,
host_docker_network_ip_address,
):
config_overrides = {
Expand All @@ -169,7 +117,7 @@ def salt_minion(
extra_cli_arguments_after_first_start_failure=["--log-level=debug"],
# SaltMinion kwargs
name=minion_id,
image=minion_image,
image="ghcr.io/saltstack/salt-ci-containers/salt:3004",
docker_client=docker_client,
start_timeout=120,
pull_before_start=False,
Expand Down

0 comments on commit 212019c

Please sign in to comment.