diff --git a/tests/conftest.py b/tests/conftest.py index b7795e7..057c01d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,6 +2,7 @@ import os import pytest +from pytest_kind import KindCluster from saltfactories.utils import random_string from saltext.kubernetes import PACKAGE_ROOT @@ -9,6 +10,15 @@ # 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= @@ -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() diff --git a/tests/functional/modules/test_kubernetesmod.py b/tests/functional/modules/test_kubernetesmod.py index 35e41fb..021c3a5 100644 --- a/tests/functional/modules/test_kubernetesmod.py +++ b/tests/functional/modules/test_kubernetesmod.py @@ -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): """