Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable testing on K8S 1.30.x, Istio 1.22 #63

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def set_properties(project):
project.depends_on("openapi-spec-validator", "~=0.3")
project.depends_on("json-log-formatter", "~=0.3")
project.depends_on("platformdirs", "~=4.2")
project.depends_on("requests", "~=2.25")
project.depends_on("requests", "~=2.31.0")
project.depends_on("jsonpatch", "~=1.32")
project.depends_on("jsonpath-ng", "~=1.6.1")
project.depends_on("jinja2", "~=3.1")
Expand Down
2 changes: 1 addition & 1 deletion src/integrationtest/python/full_smoke_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_full_smoke(self):
test_dir = Path(__file__).parent / "full_smoke"

for k8s_version, istio_version in ((self.K8S_TEST_VERSIONS[0], "1.10.6"),
(self.K8S_TEST_VERSIONS[-1], "1.20.0")):
(self.K8S_TEST_VERSIONS[-1], "1.22.0")):
with self.subTest(k8s_version=k8s_version, istio_version=istio_version):
os.environ["K8S_VERSION"] = k8s_version
os.environ["ISTIO_VERSION"] = istio_version
Expand Down
2 changes: 1 addition & 1 deletion src/integrationtest/python/issue_23_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_issue_23(self):
test_dir = Path(__file__).parent / "issue_23"

for k8s_version, istio_version in ((self.K8S_TEST_VERSIONS[0], "1.10.6"),
(self.K8S_TEST_VERSIONS[-1], "1.20.0")):
(self.K8S_TEST_VERSIONS[-1], "1.22.0")):
with self.subTest(k8s_version=k8s_version, istio_version=istio_version):
os.environ["K8S_VERSION"] = k8s_version
os.environ["ISTIO_VERSION"] = istio_version
Expand Down
4 changes: 2 additions & 2 deletions src/integrationtest/python/issue_52_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Issue52Test(IntegrationTestSupport):
def test_issue_52(self):
test_dir = Path(__file__).parent / "issue_23"

for k8s_version, istio_version in ((self.K8S_TEST_VERSIONS[-2], "1.20.4"),
(self.K8S_TEST_VERSIONS[-1], "1.21.0")):
for k8s_version, istio_version in ((self.K8S_TEST_VERSIONS[-3], "1.20.4"),
(self.K8S_TEST_VERSIONS[-1], "1.22.0")):
with self.subTest(k8s_version=k8s_version, istio_version=istio_version):
os.environ["K8S_VERSION"] = k8s_version
os.environ["ISTIO_VERSION"] = istio_version
Expand Down
4 changes: 2 additions & 2 deletions src/integrationtest/python/test_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
class IntegrationTestSupport(unittest.TestCase):
K8S_TEST_VERSIONS = ["1.20.15", "1.21.14", "1.22.17",
"1.23.17", "1.24.17", "1.25.16",
"1.26.15", "1.27.13", "1.28.9",
"1.29.4"]
"1.26.15", "1.27.14", "1.28.10",
"1.29.5", "1.30.1"]

def load_json_logs(self, log_file):
decoder = json.JSONDecoder()
Expand Down
16 changes: 15 additions & 1 deletion src/main/python/kubernator/plugins/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ def final_resource_validator(resources: Sequence[K8SResource],
resource, resource.source)


def normalize_pkg_version(v: str):
v_split = v.split(".")
rev = v_split[-1]
if not rev.isdigit():
new_rev = ""
for c in rev:
if not c.isdigit():
break
new_rev += c
v_split[-1] = new_rev
return tuple(map(int, v_split))


class KubernetesPlugin(KubernatorPlugin, K8SResourcePluginMixin):
logger = logger

Expand Down Expand Up @@ -193,7 +206,8 @@ def _setup_client(self):
k8s.server_git_version = git_version

logger.info("Found Kubernetes %s on %s", k8s.server_git_version, k8s.client.configuration.host)
K8SResource._k8s_client_version = tuple(map(int, pkg_version("kubernetes").split(".")))

K8SResource._k8s_client_version = normalize_pkg_version(pkg_version("kubernetes"))
K8SResource._k8s_field_validation = k8s.field_validation
K8SResource._k8s_field_validation_patched = not k8s.disable_client_patches
K8SResource._logger = self.logger
Expand Down
32 changes: 32 additions & 0 deletions src/unittest/python/issue64_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
#
# Copyright 2020 Express Systems USA, Inc
# Copyright 2024 Karellen, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#


from gevent.monkey import patch_all, is_anything_patched

if not is_anything_patched():
patch_all()

import unittest
from kubernator.plugins.k8s import normalize_pkg_version


class Issue64Testcase(unittest.TestCase):
def test_issue64(self):
self.assertEqual((1, 2, 3), normalize_pkg_version("1.2.3"))
self.assertEqual((1, 2, 3), normalize_pkg_version("1.2.3a1"))