Skip to content

Commit

Permalink
explicit version testing rather than relying on defaults, move the en…
Browse files Browse the repository at this point in the history
…v fixture to tests/conftest.py and add a decorator to only run on linux
  • Loading branch information
djivey committed Jan 21, 2025
1 parent cf9f54f commit 694e73d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
22 changes: 22 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@
import os

import pytest
from pytest_kind import KindCluster
from saltfactories.utils import random_string

from saltext.kubernetes import PACKAGE_ROOT

# Reset the root logger to its default level(because salt changed it)
logging.root.setLevel(logging.WARNING)

# Supported Kubernetes versions for testing based on v0.25.0 of kind - kind v0.26.0 is latest
K8S_VERSIONS = [
"v1.26.15",
"v1.27.16",
"v1.28.15",
"v1.29.10",
"v1.30.6",
"v1.31.2",
]

# This swallows all logging to stdout.
# To show select logs, set --log-cli-level=<level>
Expand Down Expand Up @@ -53,3 +63,15 @@ def minion_config(): # pragma: no cover
@pytest.fixture(scope="package")
def minion(master, minion_config): # pragma: no cover
return master.salt_minion_daemon(random_string("minion-"), overrides=minion_config)


@pytest.mark.skip_unless_on_linux
@pytest.fixture(scope="module", params=K8S_VERSIONS)
def kind_cluster(request):
"""Create Kind cluster for testing with specified Kubernetes version"""
cluster = KindCluster(name="salt-test", image=f"kindest/node:{request.param}")
try:
cluster.create()
yield cluster
finally:
cluster.delete()
12 changes: 0 additions & 12 deletions tests/functional/modules/test_kubernetesmod.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import logging

import pytest
from pytest_kind import KindCluster

log = logging.getLogger(__name__)


@pytest.fixture(scope="module")
def kind_cluster():
"""Create Kind cluster for testing"""
cluster = KindCluster(name="salt-test")
try:
cluster.create()
yield cluster
finally:
cluster.delete()


@pytest.fixture(scope="module")
def master_config_overrides(kind_cluster):
"""
Expand Down

0 comments on commit 694e73d

Please sign in to comment.