diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index dff1599b0..55ee2a964 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -11,8 +11,6 @@ on: - 'doc/**' - '.circleci/**' env: - # failsafe.groups configuration depends on the env setup. - FAILSAFE_GROUPS: '' DOCKER_HOST: 'unix:///var/run/docker.sock' jobs: @@ -23,9 +21,12 @@ jobs: fail-fast: false matrix: java: ['11'] - + target: ['docker', 'kubernetes'] + env: + # failsafe.groups configuration depends on the env setup. + FAILSAFE_GROUPS: '' steps: - - name: Setup Minikube + - name: Setup Minikube # add an if for the kubernetes target only? uses: manusa/actions-setup-minikube@v2.10.0 with: driver: docker @@ -34,8 +35,6 @@ jobs: kubernetes version: 'v1.30.0' github token: ${{ secrets.GITHUB_TOKEN }} start args: "--memory='4gb' --cpus='2'" - env: - FAILSAFE_GROUPS: "-Dfailsafe.groups=\"org.arquillian.cube.docker.impl.requirement.RequiresDocker,org.arquillian.cube.kubernetes.impl.requirement.RequiresKubernetes\"" - name: Enable minikube registry run: | minikube addons enable registry @@ -55,10 +54,15 @@ jobs: distribution: 'adopt' - name: Maven pre-fetch dependencies ${{ matrix.java }} run: | - ./mvnw verify -q -U -DskipTests # pre-fetch dependencies - - name: Build with Maven Java ${{ matrix.java }} + ./mvnw clean package -q -U -DskipTests # pre-fetch dependencies + - name: Build and run integration tests for Docker target (${{ matrix.java }}) + if: ${{ matrix.target == 'docker' }} + run: | + ./mvnw package -Dfailsafe.groups=org.arquillian.cube.docker.impl.requirement.RequiresDocker -Dcontainerless.skip.tests=true + - name: Build and run integration tests for Kubernetes target (${{ matrix.java }}) + if: ${{ matrix.target == 'kubernetes' }} run: | - ./mvnw -fae clean package ${{ env.FAILSAFE_GROUPS }} + ./mvnw verify -Dfailsafe.groups=org.arquillian.cube.kubernetes.impl.requirement.RequiresKubernetes -Dcontainerless.skip.tests=true - uses: actions/upload-artifact@v3 if: failure() with: diff --git a/docker/docker/src/test/java/org/arquillian/cube/docker/impl/await/DockerHealthAwaitStrategyTest.java b/docker/docker/src/test/java/org/arquillian/cube/docker/impl/await/DockerHealthAwaitStrategyTest.java index 626c8029a..67a7375ab 100644 --- a/docker/docker/src/test/java/org/arquillian/cube/docker/impl/await/DockerHealthAwaitStrategyTest.java +++ b/docker/docker/src/test/java/org/arquillian/cube/docker/impl/await/DockerHealthAwaitStrategyTest.java @@ -47,7 +47,7 @@ public class DockerHealthAwaitStrategyTest { @BeforeClass public static void createDockerClient() { if (!System.getenv().containsKey(DOCKER_HOST) || System.getenv(DOCKER_HOST).equals("")){ - environmentVariables.set(DOCKER_HOST, "unix:///var/run/podman.sock"); + environmentVariables.set(DOCKER_HOST, "unix:///var/run/docker.sock"); } dockerClient = DockerClientBuilder.getInstance().build(); healthSuccessImageId = dockerBuild("DockerHealthAwait/HealthSuccess/Dockerfile"); diff --git a/kubernetes/ftest-kubernetes-assistant/src/test/java/org/arquillian/cube/kubernetes/assistant/HelloWorldKubernetesAssistantTest.java b/kubernetes/ftest-kubernetes-assistant/src/test/java/org/arquillian/cube/kubernetes/assistant/HelloWorldKubernetesAssistantTest.java index 5db28d1df..fb817fd30 100644 --- a/kubernetes/ftest-kubernetes-assistant/src/test/java/org/arquillian/cube/kubernetes/assistant/HelloWorldKubernetesAssistantTest.java +++ b/kubernetes/ftest-kubernetes-assistant/src/test/java/org/arquillian/cube/kubernetes/assistant/HelloWorldKubernetesAssistantTest.java @@ -1,7 +1,5 @@ package org.arquillian.cube.kubernetes.assistant; -import io.fabric8.kubernetes.client.http.HttpClient; -import io.fabric8.kubernetes.client.jdkhttp.JdkHttpClientFactory; import org.arquillian.cube.kubernetes.impl.KubernetesAssistant; import org.arquillian.cube.kubernetes.impl.requirement.RequiresKubernetes; import org.arquillian.cube.requirement.ArquillianConditionalRunner; @@ -17,8 +15,6 @@ import static io.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.Matchers.hasKey; // tag::k8_assistant_example[] @RunWith(ArquillianConditionalRunner.class) diff --git a/kubernetes/ftest-kubernetes-assistant/src/test/resources/kubernetes.json b/kubernetes/ftest-kubernetes-assistant/src/test/resources/kubernetes.json index 56dc1fe10..3b9abcf3d 100644 --- a/kubernetes/ftest-kubernetes-assistant/src/test/resources/kubernetes.json +++ b/kubernetes/ftest-kubernetes-assistant/src/test/resources/kubernetes.json @@ -18,7 +18,7 @@ } } }, { - "apiVersion" : "extensions/v1beta1", + "apiVersion" : "apps/v1", "kind" : "Deployment", "metadata" : { "name" : "hello-world" diff --git a/kubernetes/ftest-kubernetes-logs/pom.xml b/kubernetes/ftest-kubernetes-logs/pom.xml index f307f7f12..9cddd5e8c 100644 --- a/kubernetes/ftest-kubernetes-logs/pom.xml +++ b/kubernetes/ftest-kubernetes-logs/pom.xml @@ -25,6 +25,11 @@ junit test + + io.fabric8 + kubernetes-client + test + diff --git a/kubernetes/ftest-kubernetes-reporter/pom.xml b/kubernetes/ftest-kubernetes-reporter/pom.xml index b818af628..ca107c3ea 100644 --- a/kubernetes/ftest-kubernetes-reporter/pom.xml +++ b/kubernetes/ftest-kubernetes-reporter/pom.xml @@ -39,6 +39,11 @@ junit test + + io.fabric8 + kubernetes-client + test + diff --git a/kubernetes/ftest-kubernetes-resources/pom.xml b/kubernetes/ftest-kubernetes-resources/pom.xml index 11d4e3ea3..4c556ff67 100644 --- a/kubernetes/ftest-kubernetes-resources/pom.xml +++ b/kubernetes/ftest-kubernetes-resources/pom.xml @@ -28,6 +28,11 @@ assertj-core test + + io.fabric8 + kubernetes-client + test + diff --git a/kubernetes/ftest-kubernetes-resources/src/test/resources/hello-world-2.yaml b/kubernetes/ftest-kubernetes-resources/src/test/resources/hello-world-2.yaml index 2683d1883..fe32e6218 100644 --- a/kubernetes/ftest-kubernetes-resources/src/test/resources/hello-world-2.yaml +++ b/kubernetes/ftest-kubernetes-resources/src/test/resources/hello-world-2.yaml @@ -11,7 +11,7 @@ spec: selector: app: hello-world --- -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: hello-world diff --git a/kubernetes/ftest-kubernetes-resources/src/test/resources/hello-world.yaml b/kubernetes/ftest-kubernetes-resources/src/test/resources/hello-world.yaml index f73ec4a33..5c357460b 100644 --- a/kubernetes/ftest-kubernetes-resources/src/test/resources/hello-world.yaml +++ b/kubernetes/ftest-kubernetes-resources/src/test/resources/hello-world.yaml @@ -11,7 +11,7 @@ spec: selector: app: hello-world --- -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: hello-world diff --git a/kubernetes/ftest-kubernetes/pom.xml b/kubernetes/ftest-kubernetes/pom.xml index 924a419e4..09c63cbc6 100644 --- a/kubernetes/ftest-kubernetes/pom.xml +++ b/kubernetes/ftest-kubernetes/pom.xml @@ -30,6 +30,11 @@ rest-assured test + + io.fabric8 + kubernetes-client + test + diff --git a/kubernetes/ftest-kubernetes/src/test/java/HelloWorldIT.java b/kubernetes/ftest-kubernetes/src/test/java/HelloWorldIT.java index 8a63be01c..4f018a54e 100644 --- a/kubernetes/ftest-kubernetes/src/test/java/HelloWorldIT.java +++ b/kubernetes/ftest-kubernetes/src/test/java/HelloWorldIT.java @@ -3,8 +3,6 @@ import java.net.URL; import io.restassured.RestAssured; -import io.restassured.builder.RequestSpecBuilder; -import io.restassured.specification.RequestSpecification; import org.arquillian.cube.kubernetes.annotations.Named; import org.arquillian.cube.kubernetes.annotations.PortForward; import org.arquillian.cube.kubernetes.impl.requirement.RequiresKubernetes; @@ -15,12 +13,8 @@ import org.junit.runner.RunWith; import static junit.framework.TestCase.assertFalse; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.hasKey; -import static org.junit.Assert.assertEquals; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; @Category(RequiresKubernetes.class) @RequiresKubernetes @@ -55,7 +49,7 @@ public void shouldShowHelloWorld() throws IOException { .then() .assertThat() .statusCode(200) - .body(contains("Hello OpenShift!\n")); + .body(is("Hello OpenShift!\n")); } } } diff --git a/kubernetes/ftest-kubernetes/src/test/resources/kubernetes.yaml b/kubernetes/ftest-kubernetes/src/test/resources/kubernetes.yaml index 38d20fdfe..f218cbb4b 100644 --- a/kubernetes/ftest-kubernetes/src/test/resources/kubernetes.yaml +++ b/kubernetes/ftest-kubernetes/src/test/resources/kubernetes.yaml @@ -11,7 +11,7 @@ spec: selector: app: hello-world --- -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: hello-world diff --git a/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java b/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java index 0d21d85f6..52b586da6 100644 --- a/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java +++ b/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java @@ -283,9 +283,10 @@ public Optional getServiceUrl() { } private Optional createUrlForService(Service service) { - final String scheme = (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) ? + final boolean useMetadataAnnotations = service.getMetadata().getAnnotations() != null && !service.getMetadata().getAnnotations().isEmpty(); + final String scheme = (service.getMetadata() != null && useMetadataAnnotations) ? service.getMetadata().getAnnotations().get("api.service.kubernetes.io/scheme") : "http"; - final String path = (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) ? + final String path = (service.getMetadata() != null && useMetadataAnnotations) ? service.getMetadata().getAnnotations().get("api.service.kubernetes.io/path") : "/"; final int port = resolvePort(service); diff --git a/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/SessionManager.java b/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/SessionManager.java index 2f2b6d53f..3f5d4d968 100644 --- a/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/SessionManager.java +++ b/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/SessionManager.java @@ -9,8 +9,8 @@ import io.fabric8.kubernetes.api.model.Service; import io.fabric8.kubernetes.api.model.ServiceList; import io.fabric8.kubernetes.api.model.ServicePort; -import io.fabric8.kubernetes.api.model.extensions.ReplicaSet; -import io.fabric8.kubernetes.api.model.extensions.ReplicaSetList; +import io.fabric8.kubernetes.api.model.apps.ReplicaSet; +import io.fabric8.kubernetes.api.model.apps.ReplicaSetList; import io.fabric8.kubernetes.client.KubernetesClient; import java.io.IOException; import java.io.InputStream; @@ -270,7 +270,7 @@ public void clean(String status) { @Override public void display() { - ReplicaSetList replicaSetList = client.extensions().replicaSets().inNamespace(session.getNamespace()).list(); + ReplicaSetList replicaSetList = client.apps().replicaSets().inNamespace(session.getNamespace()).list(); if (replicaSetList.getItems() != null) { for (ReplicaSet replicaSet : replicaSetList.getItems()) { session.getLogger().info("ReplicaSet: [" + replicaSet.getMetadata().getName() + "]"); diff --git a/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/portforward/PortForwarder.java b/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/portforward/PortForwarder.java index c5fc6dcaa..e3c8ace32 100644 --- a/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/portforward/PortForwarder.java +++ b/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/portforward/PortForwarder.java @@ -14,6 +14,7 @@ import io.undertow.protocols.spdy.SpdyChannelWithoutFlowControl; import io.undertow.server.XnioByteBufferPool; import io.undertow.util.Headers; +import io.undertow.util.HttpString; import io.undertow.util.Methods; import io.undertow.util.StringReadChannelListener; import java.io.Closeable; @@ -105,7 +106,8 @@ public X509Certificate[] getAcceptedIssuers() { request.getRequestHeaders() .put(Headers.HOST, this.portForwardURI.getHost()) .put(Headers.CONNECTION, "Upgrade") - .put(Headers.UPGRADE, "SPDY/3.1"); + .put(Headers.UPGRADE, "SPDY/3.1") + .put(new HttpString("X-Stream-Protocol-Version"), "portforward.k8s.io"); if (config.getOauthToken() != null) { request.getRequestHeaders().put(Headers.AUTHORIZATION, "Bearer " + config.getOauthToken()); } diff --git a/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/requirement/KubernetesRequirement.java b/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/requirement/KubernetesRequirement.java index eb7ef8d06..6d745b0f8 100644 --- a/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/requirement/KubernetesRequirement.java +++ b/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/requirement/KubernetesRequirement.java @@ -40,7 +40,7 @@ public void check(RequiresKubernetes context) throws UnsatisfiedRequirementExcep HttpClient httpClient = httpClientFactory.newBuilder(httpClientConfig).build(); HttpRequest versionRequest = new StandardHttpRequest.Builder() .url(new URL(URLUtils.join(client.getMasterUrl().toString(), "version").toString())) - .method("GET", "*/*", null) + .method("GET", "application/json", null) .build(); HttpResponse response = httpClient.sendAsync(versionRequest, String.class).get(); diff --git a/kubernetes/kubernetes/src/test/java/org/arquillian/cube/kubernetes/impl/MockTest.java b/kubernetes/kubernetes/src/test/java/org/arquillian/cube/kubernetes/impl/MockTest.java index 89ebb0262..0f4d073ad 100644 --- a/kubernetes/kubernetes/src/test/java/org/arquillian/cube/kubernetes/impl/MockTest.java +++ b/kubernetes/kubernetes/src/test/java/org/arquillian/cube/kubernetes/impl/MockTest.java @@ -381,7 +381,7 @@ public static void setUpClass() { MOCK.expect() .get() - .withPath("/apis/extensions/v1beta1/namespaces/arquillian/replicasets") + .withPath("/apis/apps/v1/namespaces/arquillian/replicasets") .andReturn(200, new ReplicaSetBuilder().build()) .always(); diff --git a/openshift/ftest-oc-proxy/src/test/resources/openshift.json b/openshift/ftest-oc-proxy/src/test/resources/openshift.json index 43766f51b..e8edb46db 100644 --- a/openshift/ftest-oc-proxy/src/test/resources/openshift.json +++ b/openshift/ftest-oc-proxy/src/test/resources/openshift.json @@ -18,7 +18,7 @@ } } }, { - "apiVersion" : "extensions/v1beta1", + "apiVersion" : "apps/v1", "kind" : "Deployment", "metadata" : { "name" : "hello-world" diff --git a/openshift/ftest-openshift-assistant/src/test/resources/openshift.json b/openshift/ftest-openshift-assistant/src/test/resources/openshift.json index 43766f51b..e8edb46db 100644 --- a/openshift/ftest-openshift-assistant/src/test/resources/openshift.json +++ b/openshift/ftest-openshift-assistant/src/test/resources/openshift.json @@ -18,7 +18,7 @@ } } }, { - "apiVersion" : "extensions/v1beta1", + "apiVersion" : "apps/v1", "kind" : "Deployment", "metadata" : { "name" : "hello-world" diff --git a/openshift/ftest-openshift-graphene/src/test/resources/openshift.json b/openshift/ftest-openshift-graphene/src/test/resources/openshift.json index 7a836a0f6..01f14600a 100644 --- a/openshift/ftest-openshift-graphene/src/test/resources/openshift.json +++ b/openshift/ftest-openshift-graphene/src/test/resources/openshift.json @@ -18,7 +18,7 @@ } } }, { - "apiVersion" : "extensions/v1beta1", + "apiVersion" : "apps/v1", "kind" : "Deployment", "metadata" : { "name" : "hello-world" diff --git a/openshift/ftest-openshift-resources-standalone/src/test/resources/hello-openshift.json b/openshift/ftest-openshift-resources-standalone/src/test/resources/hello-openshift.json index 56dc1fe10..3b9abcf3d 100644 --- a/openshift/ftest-openshift-resources-standalone/src/test/resources/hello-openshift.json +++ b/openshift/ftest-openshift-resources-standalone/src/test/resources/hello-openshift.json @@ -18,7 +18,7 @@ } } }, { - "apiVersion" : "extensions/v1beta1", + "apiVersion" : "apps/v1", "kind" : "Deployment", "metadata" : { "name" : "hello-world" diff --git a/openshift/ftest-openshift-restassured/src/test/resources/openshift.json b/openshift/ftest-openshift-restassured/src/test/resources/openshift.json index 376b42171..909cb7524 100644 --- a/openshift/ftest-openshift-restassured/src/test/resources/openshift.json +++ b/openshift/ftest-openshift-restassured/src/test/resources/openshift.json @@ -18,7 +18,7 @@ } } }, { - "apiVersion" : "extensions/v1beta1", + "apiVersion" : "apps/v1", "kind" : "Deployment", "metadata" : { "name" : "hello-openshift"