Skip to content

Commit

Permalink
feat(integration-tests): updated version of kind and added images for…
Browse files Browse the repository at this point in the history
… k8s v1.19 - v1.28 for the tests to run against in parallel (#6039)

Co-authored-by: abe garcia <[email protected]>
  • Loading branch information
abe21412 and abe garcia committed Sep 8, 2023
1 parent fb0fe55 commit 2104183
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/integration-tests-kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
1 change: 1 addition & 0 deletions clouddriver-kubernetes/clouddriver-kubernetes.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Map<String, Object>> 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<String, Object> artifact =
KubeTestUtils.loadJson("classpath:requests/artifact.json")
Expand Down Expand Up @@ -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<Map<String, Object>> manifest =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}

0 comments on commit 2104183

Please sign in to comment.