From a741e4b8fb5908c584813da53c7eaddc638dd81b Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Wed, 10 Apr 2024 19:08:27 +0200 Subject: [PATCH] ci: initial fixes to run OpenShift specific pipelines --- .github/workflows/e2e-httpclient-tests.yml | 2 +- .github/workflows/e2e-tests.yml | 22 +--------- .../java/io/fabric8/openshift/AdaptIT.java | 2 + .../io/fabric8/openshift/BuildConfigIT.java | 10 ++++- .../fabric8/openshift/BuildConfigWatchIT.java | 2 + .../fabric8/openshift/DeploymentConfigIT.java | 2 + .../io/fabric8/openshift/ImageStreamIT.java | 2 + .../fabric8/openshift/ImageStreamTagIT.java | 36 ++++++++------- .../K8sAuthorizationOnOpenShiftIT.java | 10 ++--- .../openshift/OpenShiftAuthorizationIT.java | 19 ++++---- .../java/io/fabric8/openshift/ProjectIT.java | 2 + .../fabric8/openshift/ProjectRequestIT.java | 2 + .../java/io/fabric8/openshift/RouteIT.java | 2 + .../SecurityContextConstraintsIT.java | 2 + .../openshift/SelfSubjectAccessReviewIT.java | 8 ++-- .../io/fabric8/openshift/ServiceToURLIT.java | 2 + .../openshift/SubjectAccessReviewIT.java | 8 ++-- .../java/io/fabric8/openshift/TemplateIT.java | 2 + .../openshift/UserImpersonationIT.java | 7 ++- .../java/io/fabric8/openshift/VersionIT.java | 2 + .../src/test/resources/imagestreamtag-it.yml | 44 +++++++++++++++---- 21 files changed, 114 insertions(+), 74 deletions(-) diff --git a/.github/workflows/e2e-httpclient-tests.yml b/.github/workflows/e2e-httpclient-tests.yml index 275b04f09d9..7bbb609013f 100644 --- a/.github/workflows/e2e-httpclient-tests.yml +++ b/.github/workflows/e2e-httpclient-tests.yml @@ -66,7 +66,7 @@ jobs: strategy: fail-fast: false matrix: - openshift: [v3.11.0, v3.10.0] + openshift: [v3.10.0] httpclient: [jdk,jetty,vertx] steps: - name: Checkout diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 963a3ae0f52..0f9113fc4a2 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -132,28 +132,8 @@ jobs: strategy: fail-fast: false matrix: - openshift: [v3.11.0, v3.10.0] + openshift: [v3.10.0] steps: - - name: Free up Space - run: | - sudo apt list --installed - sudo apt-get purge -y \ - 'aspnetcore.*' \ - 'cabal-install.*' \ - 'clang.*' \ - 'dotnet.*' \ - 'firefox.*' \ - 'ghc.*' \ - 'google-chrome.*' \ - 'heroku.*' \ - 'libmagic.*' \ - 'libmono.*' \ - 'mono-.*' \ - 'mysql.*' \ - 'php.*' \ - 'ruby.*' - sudo apt-get autoremove - df -h - name: Checkout uses: actions/checkout@v4 - name: Setup OpenShift diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/AdaptIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/AdaptIT.java index 20699a56ec1..23539b2b7e1 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/AdaptIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/AdaptIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.openshift.api.model.Project; @@ -24,6 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(Project.class) class AdaptIT { diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/BuildConfigIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/BuildConfigIT.java index e803db80c4b..1088e33013b 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/BuildConfigIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/BuildConfigIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.LoadKubernetesManifests; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.openshift.api.model.BuildConfig; @@ -22,6 +23,7 @@ import io.fabric8.openshift.api.model.BuildConfigList; import io.fabric8.openshift.api.model.BuildSourceBuilder; import io.fabric8.openshift.client.OpenShiftClient; +import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; import java.util.Objects; @@ -32,6 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(BuildConfig.class) @LoadKubernetesManifests("/buildconfig-it.yml") class BuildConfigIT { @@ -54,8 +57,11 @@ void get() { @Test void list() { BuildConfigList bcList = client.buildConfigs().list(); - assertThat(bcList).isNotNull(); - assertTrue(bcList.getItems().size() >= 1); + assertThat(bcList) + .isNotNull() + .extracting(BuildConfigList::getItems) + .asInstanceOf(InstanceOfAssertFactories.list(BuildConfig.class)) + .hasSizeGreaterThanOrEqualTo(1); } @Test diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/BuildConfigWatchIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/BuildConfigWatchIT.java index 9d40ba4f9c0..ad4116152f8 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/BuildConfigWatchIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/BuildConfigWatchIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.LoadKubernetesManifests; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.kubernetes.client.Watch; @@ -37,6 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(BuildConfig.class) @LoadKubernetesManifests("/build-config-watch.yml") class BuildConfigWatchIT { diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/DeploymentConfigIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/DeploymentConfigIT.java index c022382936e..016c360e9d6 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/DeploymentConfigIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/DeploymentConfigIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.LoadKubernetesManifests; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.openshift.api.model.DeploymentConfig; @@ -30,6 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(DeploymentConfig.class) @LoadKubernetesManifests("/deploymentconfig-it.yml") class DeploymentConfigIT { diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamIT.java index 5e3d4e769d7..6e256bc59a1 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.LoadKubernetesManifests; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.openshift.api.model.ImageStream; @@ -31,6 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(ImageStream.class) @LoadKubernetesManifests("/imagestream-it.yml") class ImageStreamIT { diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamTagIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamTagIT.java index 1022b7d5375..2d4d4bb87a7 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamTagIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamTagIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.LoadKubernetesManifests; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.openshift.api.model.ImageStreamTag; @@ -30,6 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(ImageStreamTag.class) @LoadKubernetesManifests("/imagestreamtag-it.yml") class ImageStreamTagIT { @@ -49,20 +51,20 @@ void load() { @Test void get() { - client.imageStreams().withName("get").waitUntilCondition(is -> is != null && is.getStatus() != null && + client.imageStreams().withName("is-tag-get").waitUntilCondition(is -> is != null && is.getStatus() != null && is.getStatus().getTags().stream().anyMatch(nt -> nt.getTag().equals("1.0.12")), 30, TimeUnit.SECONDS); - ImageStreamTag getIST = client.imageStreamTags().withName("get:1.0.12").get(); + ImageStreamTag getIST = client.imageStreamTags().withName("is-tag-get:1.0.12").get(); assertNotNull(getIST); - assertEquals("get:1.0.12", getIST.getMetadata().getName()); + assertEquals("is-tag-get:1.0.12", getIST.getMetadata().getName()); assertEquals("DockerImage", getIST.getTag().getFrom().getKind()); - assertEquals("busybox:latest", getIST.getTag().getFrom().getName()); + assertEquals("quay.io/quay/busybox:latest", getIST.getTag().getFrom().getName()); } @Test void list() { - client.imageStreams().withName("list").waitUntilCondition(is -> is != null && is.getStatus() != null && + client.imageStreams().withName("is-tag-list").waitUntilCondition(is -> is != null && is.getStatus() != null && is.getStatus().getTags().stream().anyMatch(nt -> nt.getTag().equals("1.0.12")), 30, TimeUnit.SECONDS); ImageStreamTagList istagList = client.imageStreamTags().list(); @@ -70,42 +72,42 @@ void list() { assertNotNull(istagList); assertTrue(istagList.getItems().size() >= 1); Optional imageStreamTag = istagList.getItems().stream() - .filter(i -> i.getMetadata().getName().equalsIgnoreCase("list:1.0.12")).findFirst(); + .filter(i -> i.getMetadata().getName().equalsIgnoreCase("is-tag-list:1.0.12")).findFirst(); assertTrue(imageStreamTag.isPresent()); - assertEquals("list:1.0.12", imageStreamTag.get().getMetadata().getName()); + assertEquals("is-tag-list:1.0.12", imageStreamTag.get().getMetadata().getName()); assertEquals("DockerImage", imageStreamTag.get().getTag().getFrom().getKind()); - assertEquals("busybox:latest", imageStreamTag.get().getTag().getFrom().getName()); + assertEquals("quay.io/quay/busybox:latest", imageStreamTag.get().getTag().getFrom().getName()); } @Test void update() { - client.imageStreams().withName("update").waitUntilCondition(is -> is != null && is.getStatus() != null && + client.imageStreams().withName("is-tag-update").waitUntilCondition(is -> is != null && is.getStatus() != null && is.getStatus().getTags().stream().anyMatch(nt -> nt.getTag().equals("1.0.12")), 30, TimeUnit.SECONDS); - ImageStreamTag istag2 = new ImageStreamTagBuilder().withNewMetadata().withName("update:1.0.12").endMetadata() + ImageStreamTag istag2 = new ImageStreamTagBuilder().withNewMetadata().withName("is-tag-update:1.0.12").endMetadata() .withNewTag() .withNewFrom() .withKind("DockerImage") - .withName("busybox:latest") + .withName("quay.io/quay/busybox:latest") .endFrom() .endTag() .build(); - ImageStreamTag istag = client.imageStreamTags().withName("update:1.0.12").patch(istag2); + ImageStreamTag istag = client.imageStreamTags().withName("is-tag-update:1.0.12").patch(istag2); assertNotNull(istag); - assertEquals("update:1.0.12", istag.getMetadata().getName()); + assertEquals("is-tag-update:1.0.12", istag.getMetadata().getName()); assertEquals("DockerImage", istag.getTag().getFrom().getKind()); - assertEquals("busybox:latest", istag.getTag().getFrom().getName()); + assertEquals("quay.io/quay/busybox:latest", istag.getTag().getFrom().getName()); } @Test void delete() { - client.imageStreams().withName("delete").waitUntilCondition(is -> is != null && is.getStatus() != null && + client.imageStreams().withName("is-tag-delete").waitUntilCondition(is -> is != null && is.getStatus() != null && is.getStatus().getTags().stream().anyMatch(nt -> nt.getTag().equals("1.0.12")), 30, TimeUnit.SECONDS); - boolean deleted = client.imageStreamTags().withName("delete:1.0.12").delete().size() == 1; + boolean deleted = client.imageStreamTags().withName("is-tag-delete:1.0.12").delete().size() == 1; assertTrue(deleted); - client.imageStreamTags().withName("delete:1.0.12") + client.imageStreamTags().withName("is-tag-delete:1.0.12") .waitUntilCondition(r -> r == null || r.getMetadata().getDeletionTimestamp() != null, 30, TimeUnit.SECONDS); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/K8sAuthorizationOnOpenShiftIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/K8sAuthorizationOnOpenShiftIT.java index 896c9daec7e..8e863705827 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/K8sAuthorizationOnOpenShiftIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/K8sAuthorizationOnOpenShiftIT.java @@ -15,8 +15,8 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.RequireK8sSupport; -import io.fabric8.kubernetes.api.model.Namespace; import io.fabric8.kubernetes.api.model.authorization.v1.LocalSubjectAccessReview; import io.fabric8.kubernetes.api.model.authorization.v1.LocalSubjectAccessReviewBuilder; import io.fabric8.kubernetes.api.model.authorization.v1.SubjectAccessReview; @@ -38,13 +38,12 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(Project.class) class K8sAuthorizationOnOpenShiftIT { OpenShiftClient client; - Namespace namespace; - @Test void createRoleK8s() { // Given @@ -151,7 +150,7 @@ void createClusterRoleK8s() { void createLocalSubjectAccessReview() { // Given User currentUser = client.currentUser(); - String ns = namespace.getMetadata().getName(); + String ns = client.getConfiguration().getNamespace(); LocalSubjectAccessReview lsar = new LocalSubjectAccessReviewBuilder() .withNewMetadata().withNamespace(ns).endMetadata() .withNewSpec() @@ -177,10 +176,11 @@ void createLocalSubjectAccessReview() { void createSubjectAccessReview() { // Given String user = client.currentUser().getMetadata().getName(); + String ns = client.getConfiguration().getNamespace(); SubjectAccessReview sar = new SubjectAccessReviewBuilder() .withNewSpec() .withNewResourceAttributes() - .withNamespace(namespace.getMetadata().getName()) + .withNamespace(ns) .withVerb("get") .withResource("pods") .endResourceAttributes() diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/OpenShiftAuthorizationIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/OpenShiftAuthorizationIT.java index 4adab99a291..3c32676d6b8 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/OpenShiftAuthorizationIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/OpenShiftAuthorizationIT.java @@ -15,8 +15,8 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.RequireK8sSupport; -import io.fabric8.kubernetes.api.model.Namespace; import io.fabric8.openshift.api.model.LocalResourceAccessReview; import io.fabric8.openshift.api.model.LocalResourceAccessReviewBuilder; import io.fabric8.openshift.api.model.LocalSubjectAccessReview; @@ -40,13 +40,12 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(RoleBindingRestriction.class) class OpenShiftAuthorizationIT { OpenShiftClient client; - Namespace namespace; - @Test void createSubjectAccessReviewOpenShift() { // Given @@ -67,6 +66,7 @@ void createSubjectAccessReviewOpenShift() { void createSubjectRulesReviewOpenShift() { // Given String user = client.currentUser().getMetadata().getName(); + String namespace = client.getConfiguration().getNamespace(); SubjectRulesReview srr = new SubjectRulesReviewBuilder() .withNewSpec() .withUser(user) @@ -74,7 +74,7 @@ void createSubjectRulesReviewOpenShift() { .build(); // When - SubjectRulesReview createdSrr = client.subjectRulesReviews().inNamespace(namespace.getMetadata().getName()).create(srr); + SubjectRulesReview createdSrr = client.subjectRulesReviews().inNamespace(namespace).create(srr); // Then assertNotNull(createdSrr); @@ -85,10 +85,11 @@ void createSubjectRulesReviewOpenShift() { @Test void createSelfSubjectRulesReview() { // Given + String namespace = client.getConfiguration().getNamespace(); SelfSubjectRulesReview ssrr = new SelfSubjectRulesReviewBuilder().build(); // When - SelfSubjectRulesReview createdSsrr = client.selfSubjectRulesReviews().inNamespace(namespace.getMetadata().getName()) + SelfSubjectRulesReview createdSsrr = client.selfSubjectRulesReviews().inNamespace(namespace) .create(ssrr); // Then @@ -100,13 +101,14 @@ void createSelfSubjectRulesReview() { @Test void createLocalResourceAccessReview() { // Given + String namespace = client.getConfiguration().getNamespace(); LocalResourceAccessReview lrar = new LocalResourceAccessReviewBuilder() .withVerb("create") .withResource("configmaps") .build(); // When - ResourceAccessReviewResponse rarr = client.localResourceAccessReviews().inNamespace(namespace.getMetadata().getName()) + ResourceAccessReviewResponse rarr = client.localResourceAccessReviews().inNamespace(namespace) .create(lrar); // Then @@ -118,14 +120,15 @@ void createLocalResourceAccessReview() { @Test void createLocalSubjectAccessReview() { // Given + String namespace = client.getConfiguration().getNamespace(); LocalSubjectAccessReview localSubjectAccessReview = new LocalSubjectAccessReviewBuilder() - .withNamespace(namespace.getMetadata().getName()) + .withNamespace(namespace) .withVerb("get") .withResource("pods") .build(); // When - SubjectAccessReviewResponse response = client.localSubjectAccessReviews().inNamespace(namespace.getMetadata().getName()) + SubjectAccessReviewResponse response = client.localSubjectAccessReviews().inNamespace(namespace) .create(localSubjectAccessReview); // Then diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/ProjectIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/ProjectIT.java index 2e0cc162a2c..2d491de0677 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/ProjectIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/ProjectIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.openshift.api.model.Project; @@ -28,6 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(Project.class) class ProjectIT { diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/ProjectRequestIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/ProjectRequestIT.java index cb07d1e0627..c7778eb6b09 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/ProjectRequestIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/ProjectRequestIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.openshift.api.model.Project; import io.fabric8.openshift.api.model.ProjectRequest; @@ -28,6 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(ProjectRequest.class) class ProjectRequestIT { diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/RouteIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/RouteIT.java index 0fb373b9bf4..2cd5ee5a124 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/RouteIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/RouteIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.LoadKubernetesManifests; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.openshift.api.model.Route; @@ -32,6 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(Route.class) @LoadKubernetesManifests("/route-it.yml") class RouteIT { diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/SecurityContextConstraintsIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/SecurityContextConstraintsIT.java index c40499c9716..56724a0ee43 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/SecurityContextConstraintsIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/SecurityContextConstraintsIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.LoadKubernetesManifests; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.openshift.api.model.SecurityContextConstraints; @@ -30,6 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(SecurityContextConstraints.class) @LoadKubernetesManifests("/securitycontextconstraints-it.yml") class SecurityContextConstraintsIT { diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/SelfSubjectAccessReviewIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/SelfSubjectAccessReviewIT.java index 399c6e2b848..bd41f8c8646 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/SelfSubjectAccessReviewIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/SelfSubjectAccessReviewIT.java @@ -15,8 +15,8 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.RequireK8sSupport; -import io.fabric8.kubernetes.api.model.Namespace; import io.fabric8.kubernetes.api.model.authorization.v1.SelfSubjectAccessReview; import io.fabric8.kubernetes.api.model.authorization.v1.SelfSubjectAccessReviewBuilder; import io.fabric8.openshift.api.model.Project; @@ -25,23 +25,23 @@ import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(Project.class) class SelfSubjectAccessReviewIT { OpenShiftClient client; - Namespace namespace; - @Test void create() { // Given + String namespace = client.getConfiguration().getNamespace(); SelfSubjectAccessReview ssar = new SelfSubjectAccessReviewBuilder() .withNewSpec() .withNewResourceAttributes() .withGroup("apps") .withResource("deployments") .withVerb("create") - .withNamespace(namespace.getMetadata().getName()) + .withNamespace(namespace) .endResourceAttributes() .endSpec() .build(); diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/ServiceToURLIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/ServiceToURLIT.java index 42980a9b9db..02e066fef89 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/ServiceToURLIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/ServiceToURLIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.kubernetes.api.model.IntOrString; import io.fabric8.kubernetes.api.model.Service; @@ -30,6 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(Route.class) class ServiceToURLIT { diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/SubjectAccessReviewIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/SubjectAccessReviewIT.java index de67ae80168..c8447484f8a 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/SubjectAccessReviewIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/SubjectAccessReviewIT.java @@ -15,8 +15,8 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.RequireK8sSupport; -import io.fabric8.kubernetes.api.model.Namespace; import io.fabric8.openshift.api.model.Project; import io.fabric8.openshift.api.model.SubjectAccessReview; import io.fabric8.openshift.api.model.SubjectAccessReviewBuilder; @@ -27,20 +27,20 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(Project.class) class SubjectAccessReviewIT { OpenShiftClient client; - Namespace namespace; - @Test void testCreate() { // Given + String namespace = client.getConfiguration().getNamespace(); SubjectAccessReview sar = new SubjectAccessReviewBuilder() .withResource("Pod") .withVerb("get") - .withNamespace(namespace.getMetadata().getName()) + .withNamespace(namespace) .build(); // When diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/TemplateIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/TemplateIT.java index 939809ee8f6..67b0249c19b 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/TemplateIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/TemplateIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.LoadKubernetesManifests; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.kubernetes.api.model.Pod; @@ -34,6 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(Template.class) @LoadKubernetesManifests("/template-it.yml") class TemplateIT { diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/UserImpersonationIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/UserImpersonationIT.java index eef028675dd..a8a6a7595d1 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/UserImpersonationIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/UserImpersonationIT.java @@ -15,8 +15,8 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.RequireK8sSupport; -import io.fabric8.kubernetes.api.model.Namespace; import io.fabric8.kubernetes.api.model.ServiceAccount; import io.fabric8.kubernetes.api.model.ServiceAccountBuilder; import io.fabric8.kubernetes.api.model.rbac.ClusterRole; @@ -46,6 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(Project.class) class UserImpersonationIT { @@ -54,8 +55,6 @@ class UserImpersonationIT { OpenShiftClient client; - Namespace namespace; - private ServiceAccount serviceAccount1; private ClusterRole impersonatorRole; private ClusterRoleBinding impersonatorRoleBinding; @@ -90,7 +89,7 @@ public void init() { .withApiGroup("rbac.authorization.k8s.io") .withKind("User") .withName(client.currentUser().getMetadata().getName()) - .withNamespace(namespace.getMetadata().getName()) + .withNamespace(client.getConfiguration().getNamespace()) .build()) .withRoleRef(new RoleRefBuilder() .withApiGroup("rbac.authorization.k8s.io") diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/VersionIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/VersionIT.java index 6dc98589a04..798cea68a68 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/VersionIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/VersionIT.java @@ -15,6 +15,7 @@ */ package io.fabric8.openshift; +import io.fabric8.junit.jupiter.api.KubernetesTest; import io.fabric8.junit.jupiter.api.RequireK8sSupport; import io.fabric8.kubernetes.client.VersionInfo; import io.fabric8.openshift.api.model.Project; @@ -23,6 +24,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +@KubernetesTest(createEphemeralNamespace = false) @RequireK8sSupport(Project.class) class VersionIT { diff --git a/kubernetes-itests/src/test/resources/imagestreamtag-it.yml b/kubernetes-itests/src/test/resources/imagestreamtag-it.yml index 7ad7d3feac1..59a4aebb3cb 100644 --- a/kubernetes-itests/src/test/resources/imagestreamtag-it.yml +++ b/kubernetes-itests/src/test/resources/imagestreamtag-it.yml @@ -14,39 +14,67 @@ # limitations under the License. # +--- +apiVersion: "image.openshift.io/v1" +kind: "ImageStream" +metadata: + name: "is-tag-get" +spec: + dockerImageRepository: "quay.io/quay/busybox" --- apiVersion: "image.openshift.io/v1" kind: "ImageStreamTag" metadata: - name: "get:1.0.12" + name: "is-tag-get:1.0.12" tag: from: kind: "DockerImage" - name: "busybox:latest" + name: "quay.io/quay/busybox:latest" +--- +apiVersion: "image.openshift.io/v1" +kind: "ImageStream" +metadata: + name: "is-tag-list" +spec: + dockerImageRepository: "quay.io/quay/busybox" --- apiVersion: "image.openshift.io/v1" kind: "ImageStreamTag" metadata: - name: "list:1.0.12" + name: "is-tag-list:1.0.12" tag: from: kind: "DockerImage" - name: "busybox:latest" + name: "quay.io/quay/busybox:latest" +--- +apiVersion: "image.openshift.io/v1" +kind: "ImageStream" +metadata: + name: "is-tag-update" +spec: + dockerImageRepository: "quay.io/quay/busybox" --- apiVersion: "image.openshift.io/v1" kind: "ImageStreamTag" metadata: - name: "update:1.0.12" + name: "is-tag-update:1.0.12" tag: from: kind: "DockerImage" - name: "busybox:latest" + name: "quay.io/quay/busybox:latest" +--- +apiVersion: "image.openshift.io/v1" +kind: "ImageStream" +metadata: + name: "is-tag-delete" +spec: + dockerImageRepository: "quay.io/quay/busybox" --- apiVersion: "image.openshift.io/v1" kind: "ImageStreamTag" metadata: - name: "delete:1.0.12" + name: "is-tag-delete:1.0.12" tag: from: kind: "DockerImage" - name: "busybox:latest" + name: "quay.io/quay/busybox:latest"