From 8780838944813d78c81eb6cf8603ce8cc0613b61 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Thu, 3 Oct 2024 19:39:38 +0530 Subject: [PATCH] test : Move CompleteOcDockerLayerDisabledITCase to a different package Currently CompleteOcDockerITCase and CompleteOcDockerLayersDisabledITCase use shared project. This causes problems when these projects are run concurrently as one test overwrites build directory (fat jar) that might be currently getting used by other test (the latter one uses legacy fat jar). Move CompleteOcDockerLayerDisabledITCase to a different package and make it use a different test project. Signed-off-by: Rohan Kumar --- .../complete/CompleteOcDockerITCase.java | 12 ++- .../LayeredJarDisabled.java | 59 +++++++++++++ .../LayeredJarDisabledOcDockerITCase.java} | 27 ++---- pom.xml | 3 +- .../maven/spring/complete/pom.xml | 47 ----------- .../maven/spring/layered-jar-disabled/pom.xml | 84 +++++++++++++++++++ .../LayeredJarDisabledApplication.java | 26 ++++++ .../LayeredJarDisabledResource.java | 28 +++++++ 8 files changed, 211 insertions(+), 75 deletions(-) create mode 100644 it/src/test/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabled.java rename it/src/test/java/org/eclipse/jkube/integrationtests/springboot/{complete/CompleteOcDockerLayersDisabledITCase.java => layeredjardisabled/LayeredJarDisabledOcDockerITCase.java} (85%) create mode 100644 projects-to-be-tested/maven/spring/layered-jar-disabled/pom.xml create mode 100644 projects-to-be-tested/maven/spring/layered-jar-disabled/src/main/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabledApplication.java create mode 100644 projects-to-be-tested/maven/spring/layered-jar-disabled/src/main/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabledResource.java diff --git a/it/src/test/java/org/eclipse/jkube/integrationtests/springboot/complete/CompleteOcDockerITCase.java b/it/src/test/java/org/eclipse/jkube/integrationtests/springboot/complete/CompleteOcDockerITCase.java index 5d59d400..1831ebf2 100644 --- a/it/src/test/java/org/eclipse/jkube/integrationtests/springboot/complete/CompleteOcDockerITCase.java +++ b/it/src/test/java/org/eclipse/jkube/integrationtests/springboot/complete/CompleteOcDockerITCase.java @@ -53,6 +53,11 @@ public List getProfiles() { return Collections.singletonList("OpenShift-Docker"); } + @Override + public String getApplication() { + return "spring-boot-complete"; + } + @Test @Order(1) @ResourceLock(value = CLUSTER_RESOURCE_INTENSIVE, mode = READ_WRITE) @@ -129,11 +134,4 @@ void ocUndeploy() throws Exception { .assertThatShouldDeleteAllAppliedResources(); cleanUpCluster(); } - - @Override - public void cleanUpCluster() { - // NO OP - // Don't clean up cluster to avoid removing builds and image streams for other tests - // TODO: Split the Complete test project by profile into multiple projects to avoid this issue - } } diff --git a/it/src/test/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabled.java b/it/src/test/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabled.java new file mode 100644 index 00000000..076f2af9 --- /dev/null +++ b/it/src/test/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabled.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.integrationtests.springboot.layeredjardisabled; + +import io.fabric8.junit.jupiter.api.KubernetesTest; +import io.fabric8.kubernetes.api.model.Pod; +import io.fabric8.kubernetes.client.KubernetesClient; +import org.eclipse.jkube.integrationtests.JKubeCase; +import org.eclipse.jkube.integrationtests.assertions.ServiceAssertion; +import org.eclipse.jkube.integrationtests.maven.MavenCase; + +import static org.eclipse.jkube.integrationtests.assertions.PodAssertion.assertPod; +import static org.eclipse.jkube.integrationtests.assertions.PodAssertion.awaitPod; +import static org.eclipse.jkube.integrationtests.assertions.ServiceAssertion.awaitService; +import static org.hamcrest.Matchers.hasSize; + +@KubernetesTest(createEphemeralNamespace = false) +abstract class LayeredJarDisabled implements JKubeCase, MavenCase { + + private static final String PROJECT_LAYERED_JAR_DISABLED = "projects-to-be-tested/maven/spring/layered-jar-disabled"; + + private KubernetesClient kubernetesClient; + + @Override + public KubernetesClient getKubernetesClient() { + return kubernetesClient; + } + + @Override + public String getProject() { + return PROJECT_LAYERED_JAR_DISABLED; + } + + @Override + public String getApplication() { + return "spring-boot-layered-jar-disabled"; + } + + final ServiceAssertion assertThatShouldApplyResources() throws Exception { + final Pod pod = awaitPod(this).getKubernetesResource(); + assertPod(pod).apply(this).logContains("LayeredJarDisabledApplication : Started LayeredJarDisabledApplication in", 60); + return awaitService(this, pod.getMetadata().getNamespace()) + .assertIsNodePort() + .assertPorts(hasSize(1)) + .assertPort("http", 8080, true); + } + +} diff --git a/it/src/test/java/org/eclipse/jkube/integrationtests/springboot/complete/CompleteOcDockerLayersDisabledITCase.java b/it/src/test/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabledOcDockerITCase.java similarity index 85% rename from it/src/test/java/org/eclipse/jkube/integrationtests/springboot/complete/CompleteOcDockerLayersDisabledITCase.java rename to it/src/test/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabledOcDockerITCase.java index bd6aefee..4d39dff2 100644 --- a/it/src/test/java/org/eclipse/jkube/integrationtests/springboot/complete/CompleteOcDockerLayersDisabledITCase.java +++ b/it/src/test/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabledOcDockerITCase.java @@ -11,7 +11,7 @@ * Contributors: * Red Hat, Inc. - initial API and implementation */ -package org.eclipse.jkube.integrationtests.springboot.complete; +package org.eclipse.jkube.integrationtests.springboot.layeredjardisabled; import io.fabric8.openshift.api.model.ImageStream; import org.apache.maven.shared.invoker.InvocationResult; @@ -26,8 +26,6 @@ import org.junit.jupiter.api.parallel.ResourceLock; import java.io.File; -import java.util.Collections; -import java.util.List; import static org.eclipse.jkube.integrationtests.Locks.CLUSTER_RESOURCE_INTENSIVE; import static org.eclipse.jkube.integrationtests.Tags.OPEN_SHIFT; @@ -47,12 +45,7 @@ @Tag(OPEN_SHIFT) @Tag(OPEN_SHIFT_OSCI) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -class CompleteOcDockerLayersDisabledITCase extends Complete implements OpenShiftCase { - @Override - public List getProfiles() { - return Collections.singletonList("OpenShift-Docker-Spring-Layers-Disabled"); - } - +class LayeredJarDisabledOcDockerITCase extends LayeredJarDisabled implements OpenShiftCase { @Test @Order(1) @ResourceLock(value = CLUSTER_RESOURCE_INTENSIVE, mode = READ_WRITE) @@ -68,7 +61,7 @@ void ocBuild() throws Exception { assertOpenShiftDockerBuildCompletedWithLogs( "FROM quay.io/jkube/jkube-java:", "ENV JAVA_APP_DIR=/deployments", - "EXPOSE 8082 8778 9779", + "EXPOSE 8080 8778 9779", "COPY /jkube-generated-layer-original/deployments /deployments/", "WORKDIR /deployment"); } @@ -85,8 +78,9 @@ void ocResource() throws Exception { String.format("../%s/target/classes/META-INF", getProject())); assertThat(metaInfDirectory.exists(), equalTo(true)); assertListResource(new File(metaInfDirectory, "jkube/openshift.yml")); - assertThat(new File(metaInfDirectory, "jkube/openshift/spring-boot-complete-deploymentconfig.yml"), yaml(not(anEmptyMap()))); - assertThat(new File(metaInfDirectory, "jkube/openshift/spring-boot-complete-service.yml"), yaml(not(anEmptyMap()))); + assertThat(new File(metaInfDirectory, "jkube/openshift/spring-boot-layered-jar-disabled-deploymentconfig.yml"), yaml(not(anEmptyMap()))); + assertThat(new File(metaInfDirectory, "jkube/openshift/spring-boot-layered-jar-disabled-service.yml"), yaml(not(anEmptyMap()))); + assertThat(new File(metaInfDirectory, "jkube/openshift/spring-boot-layered-jar-disabled-route.yml"), yaml(not(anEmptyMap()))); } @Test @@ -112,7 +106,7 @@ void ocLog() throws Exception { // Then assertInvocation(invocationResult); assertThat(invocationResult.getStdOut(), - stringContainsInOrder("Tomcat started on port(s)", "Started CompleteApplication in", "seconds")); + stringContainsInOrder("Tomcat started on port(s)", "Started LayeredJarDisabledApplication in", "seconds")); } @Test @@ -127,11 +121,4 @@ void ocUndeploy() throws Exception { .assertThatShouldDeleteAllAppliedResources(); cleanUpCluster(); } - - @Override - public void cleanUpCluster() { - // NO OP - // Don't clean up cluster to avoid removing builds and image streams for other tests - // TODO: Split the Complete test project by profile into multiple projects to avoid this issue - } } diff --git a/pom.xml b/pom.xml index 302eb1d3..2f4151d1 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,7 @@ 4.0.1 2.3.3 - 1.17-SNAPSHOT + 1.18-SNAPSHOT 5.11.0 4.4.6 4.2 @@ -383,6 +383,7 @@ projects-to-be-tested/maven/spring/watch projects-to-be-tested/maven/spring/zero-config projects-to-be-tested/maven/spring/zero-config-fatjar + projects-to-be-tested/maven/spring/layered-jar-disabled diff --git a/projects-to-be-tested/maven/spring/complete/pom.xml b/projects-to-be-tested/maven/spring/complete/pom.xml index efe0175e..ab9a987e 100644 --- a/projects-to-be-tested/maven/spring/complete/pom.xml +++ b/projects-to-be-tested/maven/spring/complete/pom.xml @@ -215,53 +215,6 @@ - - OpenShift-Docker-Spring-Layers-Disabled - - docker - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot.version} - - - - repackage - - - - - - false - - - - - org.eclipse.jkube - openshift-maven-plugin - - - - - NodePort - - - - - - - complete - - - - - - - - diff --git a/projects-to-be-tested/maven/spring/layered-jar-disabled/pom.xml b/projects-to-be-tested/maven/spring/layered-jar-disabled/pom.xml new file mode 100644 index 00000000..b6b79b2c --- /dev/null +++ b/projects-to-be-tested/maven/spring/layered-jar-disabled/pom.xml @@ -0,0 +1,84 @@ + + + + 4.0.0 + + + org.eclipse.jkube.integration-tests + jkube-integration-tests-project + ${revision} + ../../../../pom.xml + + + spring-boot-layered-jar-disabled + ${global.name} :: Spring Boot :: Layered Jar Disabled + + Spring Boot with Explicit Configuration to disable Layered Jar + + + + docker + NodePort + + + + + org.springframework.boot + spring-boot-starter + ${spring-boot.version} + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot.version} + compile + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + repackage + + + + + + false + + + + + org.eclipse.jkube + kubernetes-maven-plugin + + + org.eclipse.jkube + openshift-maven-plugin + + + + + diff --git a/projects-to-be-tested/maven/spring/layered-jar-disabled/src/main/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabledApplication.java b/projects-to-be-tested/maven/spring/layered-jar-disabled/src/main/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabledApplication.java new file mode 100644 index 00000000..b121f0a8 --- /dev/null +++ b/projects-to-be-tested/maven/spring/layered-jar-disabled/src/main/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabledApplication.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.integrationtests.springboot.layeredjardisabled; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class LayeredJarDisabledApplication { + + public static void main(String[] args) { + SpringApplication.run(LayeredJarDisabledApplication.class, args); + } + +} diff --git a/projects-to-be-tested/maven/spring/layered-jar-disabled/src/main/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabledResource.java b/projects-to-be-tested/maven/spring/layered-jar-disabled/src/main/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabledResource.java new file mode 100644 index 00000000..b72478d1 --- /dev/null +++ b/projects-to-be-tested/maven/spring/layered-jar-disabled/src/main/java/org/eclipse/jkube/integrationtests/springboot/layeredjardisabled/LayeredJarDisabledResource.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.integrationtests.springboot.layeredjardisabled; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/") +public class LayeredJarDisabledResource { + + @GetMapping + public String layeredJarDisabled() { + return "Layered Jar is Disabled in this application"; + } +}