From 4aaecabe227562584d9c3958ca6bcf2535a2ea5c Mon Sep 17 00:00:00 2001 From: Binbing Hou Date: Mon, 8 Apr 2024 15:16:00 -0700 Subject: [PATCH] genie client integration tests: throw the exception of setting up the docker container (#1211) Co-authored-by: bhou --- .../GenieClientIntegrationTestBase.java | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/genie-client/src/integTest/java/com/netflix/genie/client/GenieClientIntegrationTestBase.java b/genie-client/src/integTest/java/com/netflix/genie/client/GenieClientIntegrationTestBase.java index 08ab70ddd7f..1da0836e6c2 100644 --- a/genie-client/src/integTest/java/com/netflix/genie/client/GenieClientIntegrationTestBase.java +++ b/genie-client/src/integTest/java/com/netflix/genie/client/GenieClientIntegrationTestBase.java @@ -26,13 +26,11 @@ import com.netflix.genie.common.dto.Command; import com.netflix.genie.common.dto.CommandStatus; import org.apache.commons.lang3.StringUtils; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assumptions; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import retrofit2.Retrofit; @@ -41,7 +39,6 @@ import java.util.Set; import java.util.UUID; - /** * Base class for all Genie client integration tests. * @@ -66,34 +63,16 @@ abstract class GenieClientIntegrationTestBase { // TODO: Improve genie-app image packaging to leverage unpacked (application plugin) based agent so that startup // is faster as in agent mode the tests are much slower than embedded. Also once we move to boot 2.3 we can // leverage their layered jars to produce less changing images. - private static GenericContainer genericContainer; + @Container + private static final GenericContainer GENIE = new GenericContainer("netflixoss/genie-app:latest.release") + .waitingFor(Wait.forHttp("/admin/health").forStatusCode(200).withStartupTimeout(Duration.ofMinutes(1L))) + .withExposedPorts(8080); protected ApplicationClient applicationClient; protected CommandClient commandClient; protected ClusterClient clusterClient; protected JobClient jobClient; - @BeforeAll - static void setupBeforeAll() { - try { - genericContainer = new GenericContainer("netflixoss/genie-app:latest.release") - .waitingFor(Wait.forHttp("/admin/health").forStatusCode(200).withStartupTimeout(Duration.ofMinutes(1L))) - .withExposedPorts(8080); - genericContainer.start(); - } catch (Exception e) { - // skip genie client integration tests for unblocking - Assumptions.assumeTrue(() -> false, "Docker is not available. Skipping tests."); - } - } - - @AfterAll - static void teardownAfterAll() { - // Stop the container - if (genericContainer != null) { - genericContainer.stop(); - } - } - @BeforeEach void setup() throws Exception { // Just run these once but don't make it a static BeforeAll in case it would be executed before container starts @@ -103,9 +82,7 @@ void setup() throws Exception { || this.clusterClient == null || this.jobClient == null ) { - final String baseUrl = "http://" + genericContainer.getContainerIpAddress() - + ":" + genericContainer.getFirstMappedPort(); - + final String baseUrl = "http://" + GENIE.getContainerIpAddress() + ":" + GENIE.getFirstMappedPort(); final Retrofit retrofit = GenieClientUtils.createRetrofitInstance(baseUrl, null, null); if (this.applicationClient == null) { this.applicationClient = new ApplicationClient(retrofit);