From 210418351c938baf315946a82358c305cc2330cb Mon Sep 17 00:00:00 2001 From: Abe Garcia <44239562+abe21412@users.noreply.github.com> Date: Fri, 8 Sep 2023 18:15:23 -0400 Subject: [PATCH] feat(integration-tests): updated version of kind and added images for k8s v1.19 - v1.28 for the tests to run against in parallel (#6039) Co-authored-by: abe garcia --- .github/workflows/integration-tests-kubernetes.yml | 13 ++++++++++++- .../clouddriver-kubernetes.gradle | 1 + .../clouddriver/kubernetes/it/BaseTest.java | 1 + .../clouddriver/kubernetes/it/DeployManifestIT.java | 13 +++++++++++-- .../kubernetes/it/containers/KubernetesCluster.java | 2 +- .../kubernetes/it/utils/KubeTestUtils.java | 8 ++++++++ 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration-tests-kubernetes.yml b/.github/workflows/integration-tests-kubernetes.yml index 7ffb1255eb5..729762714fc 100644 --- a/.github/workflows/integration-tests-kubernetes.yml +++ b/.github/workflows/integration-tests-kubernetes.yml @@ -10,7 +10,16 @@ jobs: strategy: matrix: kubernetes-image: + - "kindest/node:v1.28.0@sha256:9f3ff58f19dcf1a0611d11e8ac989fdb30a28f40f236f59f0bea31fb956ccf5c" + - "kindest/node:v1.27.3@sha256:9dd3392d79af1b084671b05bcf65b21de476256ad1dcc853d9f3b10b4ac52dde" + - "kindest/node:v1.26.6@sha256:5e5d789e90c1512c8c480844e0985bc3b4da4ba66179cc5b540fe5b785ca97b5" + - "kindest/node:v1.25.11@sha256:ca7371d5d1f680778e40e9bcbbea06c3c61ac6f0e1a29cba5c58ff2dae1ba7f5" + - "kindest/node:v1.24.15@sha256:24473777a1eef985dc405c23ab9f4daddb1352ca23db60b75de9e7c408096491" + - "kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac" + - "kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047" - "kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6" + - "kindest/node:v1.20.7@sha256:cbeaf907fc78ac97ce7b625e4bf0de16e3ea725daf6b04f930bd14c67c671ff9" + - "kindest/node:v1.19.11@sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -42,4 +51,6 @@ jobs: restore-keys: | ${{ runner.os }}-cd-it-${{ github.event.before }} - name: Kubernetes Provider Integration Tests - run: ./gradlew --build-cache :clouddriver-kubernetes:integrationTest -Pkubernetes-image=${{ matrix.kubernetes-image }} + run: | + version=$(echo '${{ matrix.kubernetes-image }}' | grep -o 'v[0-9]*\.[0-9]*') + ./gradlew --build-cache :clouddriver-kubernetes:integrationTest -Pkubernetes-image=${{ matrix.kubernetes-image }} -Pkubernetes-version=${version} diff --git a/clouddriver-kubernetes/clouddriver-kubernetes.gradle b/clouddriver-kubernetes/clouddriver-kubernetes.gradle index 93d245ad54d..3dd27f66f97 100644 --- a/clouddriver-kubernetes/clouddriver-kubernetes.gradle +++ b/clouddriver-kubernetes/clouddriver-kubernetes.gradle @@ -131,6 +131,7 @@ task integrationTest(type: Test) { environment "IT_BUILD_HOME", "$project.buildDir/it" environment "IMAGE", project.getProperties().get("kubernetes-image") + environment "KUBERNETES_VERSION", project.getProperties().get("kubernetes-version") useJUnitPlatform() testClassesDirs = sourceSets.integration.output.classesDirs diff --git a/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/BaseTest.java b/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/BaseTest.java index c3caaac70b5..371a794d01b 100644 --- a/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/BaseTest.java +++ b/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/BaseTest.java @@ -41,6 +41,7 @@ public abstract class BaseTest { public static final String APP2_NAME = "testApp2"; public static final String ACCOUNT1_NAME = "account1"; public static final String ACCOUNT2_NAME = "account2"; + public static final String KUBERNETES_VERSION = System.getenv("KUBERNETES_VERSION"); @LocalServerPort int port; diff --git a/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/DeployManifestIT.java b/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/DeployManifestIT.java index 8afd1dae2d5..9075054887a 100644 --- a/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/DeployManifestIT.java +++ b/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/DeployManifestIT.java @@ -1366,12 +1366,18 @@ public void shouldBindRequiredCronJobDockerImage() throws IOException, Interrupt System.out.println("> Using namespace: " + account1Ns + ", appName: " + appName); String imageNoTag = "index.docker.io/library/alpine"; String imageWithTag = "index.docker.io/library/alpine:3.12"; + String apiVersion = "batch/v1beta1"; + + if (KubeTestUtils.compareVersion(KUBERNETES_VERSION, "v1.20") > 0) { + apiVersion = "batch/v1"; + } List> manifest = KubeTestUtils.loadYaml("classpath:manifests/cronJob.yml") .withValue("metadata.namespace", account1Ns) .withValue("metadata.name", DEPLOYMENT_1_NAME) .withValue("spec.jobTemplate.spec.template.spec.containers[0].image", imageNoTag) + .withValue("apiVersion", apiVersion) .asList(); Map artifact = KubeTestUtils.loadJson("classpath:requests/artifact.json") @@ -1407,11 +1413,14 @@ public void shouldBindRequiredCronJobDockerImage() throws IOException, Interrupt @DisplayName( ".\n===\n" - + "Given a v1beta1 CRD manifest\n" + + "Given k8s version < 1.22.0 and a v1beta1 CRD manifest\n" + "When sending deploy manifest request\n" + "Then a v1beta1 CRD is created\n===") @Test - public void shouldDeployCrdV1beta1() throws IOException, InterruptedException { + public void shouldDeployCrdV1beta1IfSupported() throws IOException, InterruptedException { + if (KubeTestUtils.compareVersion(KUBERNETES_VERSION, "v1.21") > 0) { + return; + } // ------------------------- given -------------------------- final String crdName = "crontabs.stable.example.com"; final List> manifest = diff --git a/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/containers/KubernetesCluster.java b/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/containers/KubernetesCluster.java index 108d81784dc..aba0c926ac6 100644 --- a/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/containers/KubernetesCluster.java +++ b/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/containers/KubernetesCluster.java @@ -36,7 +36,7 @@ public class KubernetesCluster { private static KubernetesCluster INSTANCE; private static final String IMAGE = System.getenv("IMAGE"); - private static final String KIND_VERSION = "0.11.1"; + private static final String KIND_VERSION = "0.20.0"; private static final String KUBECTL_VERSION = "1.22.17"; private static final Path IT_BUILD_HOME = Paths.get(System.getenv("IT_BUILD_HOME")); private static final Path KUBECFG_PATH = Paths.get(IT_BUILD_HOME.toString(), "kubecfg.yml"); diff --git a/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/utils/KubeTestUtils.java b/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/utils/KubeTestUtils.java index cae89026ab4..bcf1cc89980 100644 --- a/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/utils/KubeTestUtils.java +++ b/clouddriver-kubernetes/src/integration/java/com/netflix/spinnaker/clouddriver/kubernetes/it/utils/KubeTestUtils.java @@ -44,6 +44,7 @@ import java.util.stream.StreamSupport; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.ResourceLoader; +import org.testcontainers.utility.ComparableVersion; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.SafeConstructor; @@ -498,4 +499,11 @@ public static void deployIfMissing( deployAndWaitStable(baseUrl, account, namespace, kind, name, app, image); } + + public static int compareVersion(String sv1, String sv2) { + ComparableVersion v1 = new ComparableVersion(sv1.replace("v", "")); + ComparableVersion v2 = new ComparableVersion(sv2.replace("v", "")); + + return v1.compareTo(v2); + } }