From cdbee91b722e25728fca0af32cf6a55d5be50c2e Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 18 Nov 2020 15:01:50 -0500 Subject: Add integration test for GR-API docker container Add integration test for GR-API docker container Change-Id: Iebd60f56668c9b50a2aab62b5309c609bc2369ce Issue-ID: SDNC-1417 Signed-off-by: Dan Timoney --- ms/generic-resource-api/pom.xml | 118 ++++++++++++++++++++- .../onap/sdnc/apps/ms/gra/GenericResourceMsIT.java | 31 ++++++ 2 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/GenericResourceMsIT.java diff --git a/ms/generic-resource-api/pom.xml b/ms/generic-resource-api/pom.xml index 88a6305..cc6471d 100644 --- a/ms/generic-resource-api/pom.xml +++ b/ms/generic-resource-api/pom.xml @@ -34,6 +34,7 @@ ${project.artifactId}-${project.version}.jar deploy true + true @@ -294,6 +295,33 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + always + + ${basedir}/src/test/resources + ${basedir}/src/test/resources/svclogic.properties + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + + true + + @@ -411,6 +439,24 @@ + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + + false + + ${gra.port} + + + io.fabric8 docker-maven-plugin @@ -441,7 +487,77 @@ build - + + start-it-instance + pre-integration-test + + start + + + + + mariadb:10.5 + gradb + + + itsASecret + sdnc + abc123 + sdnctl + + + custom + gra + dbhost + + + gradb.port:3306 + + + true + + + + + ${image.name}:${project.docker.latesttagtimestamp.version} + gra-container + + + sdnc + abc123 + sdnctl + /opt/onap/sdnc/config + + + gradb + + + custom + gra + gra + + + gra.port:8080 + + + Started GenericResourceMsApp + + + + true + + + + + + + + stop-it-instance + post-integration-test + + stop + + push-images ${docker.push.phase} diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/GenericResourceMsIT.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/GenericResourceMsIT.java new file mode 100644 index 0000000..7f00c6b --- /dev/null +++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/GenericResourceMsIT.java @@ -0,0 +1,31 @@ +package org.onap.sdnc.apps.ms.gra; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; + +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.junit.Test; + +public class GenericResourceMsIT { + @Test + public void healthcheckTest() throws ClientProtocolException, IOException { + String graPort = System.getenv("GRA_PORT"); + if ((graPort == null) || (graPort.length() == 0)) { + graPort = "8080"; + } + + String testUrl = "http://localhost:" + graPort + "/restconf/operations/SLI-API:healthcheck/"; + + CloseableHttpClient client = HttpClients.createDefault(); + HttpPost postCmd = new HttpPost(testUrl); + postCmd.addHeader("Content-Type", "application/json"); + + CloseableHttpResponse resp = client.execute(postCmd); + assertEquals(200, resp.getStatusLine().getStatusCode()); + } +} -- cgit 1.2.3-korg