summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2020-11-18 15:01:50 -0500
committerDan Timoney <dtimoney@att.com>2020-11-18 15:01:50 -0500
commitcdbee91b722e25728fca0af32cf6a55d5be50c2e (patch)
tree258317703e3b1c7a4ed630610b8a3d9dda8d6c73
parent192f1cb5b022e00baba3d60bbae389c26fcaf1da (diff)
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 <dtimoney@att.com>
-rw-r--r--ms/generic-resource-api/pom.xml118
-rw-r--r--ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/GenericResourceMsIT.java31
2 files changed, 148 insertions, 1 deletions
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 @@
<sdnc.gra.jar>${project.artifactId}-${project.version}.jar</sdnc.gra.jar>
<docker.push.phase>deploy</docker.push.phase>
<docker.verbose>true</docker.verbose>
+ <docker.autoCreateCustomNetworks>true</docker.autoCreateCustomNetworks>
</properties>
<dependencies>
@@ -294,6 +295,33 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.19.1</version>
+ <configuration>
+ <forkMode>always</forkMode>
+ <environmentVariables>
+ <SDNC_CONFIG_DIR>${basedir}/src/test/resources</SDNC_CONFIG_DIR>
+ <SVCLOGIC_PROPERTIES>${basedir}/src/test/resources/svclogic.properties</SVCLOGIC_PROPERTIES>
+ </environmentVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <skipITs>true</skipITs>
+ </configuration>
+ </plugin>
</plugins>
</build>
@@ -412,6 +440,24 @@
</executions>
</plugin>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <skipITs>false</skipITs>
+ <environmentVariables>
+ <GRA_PORT>${gra.port}</GRA_PORT>
+ </environmentVariables>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.28.0</version>
@@ -441,7 +487,77 @@
<goal>build</goal>
</goals>
</execution>
-
+ <execution>
+ <id>start-it-instance</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ <configuration>
+ <images>
+ <image>
+ <name>mariadb:10.5</name>
+ <alias>gradb</alias>
+ <run>
+ <env>
+ <MYSQL_ROOT_PASSWORD>itsASecret</MYSQL_ROOT_PASSWORD>
+ <MYSQL_USER>sdnc</MYSQL_USER>
+ <MYSQL_PASSWORD>abc123</MYSQL_PASSWORD>
+ <MYSQL_DATABASE>sdnctl</MYSQL_DATABASE>
+ </env>
+ <network>
+ <mode>custom</mode>
+ <name>gra</name>
+ <alias>dbhost</alias>
+ </network>
+ <ports>
+ <port>gradb.port:3306</port>
+ </ports>
+ <log>
+ <enabled>true</enabled>
+ </log>
+ </run>
+ </image>
+ <image>
+ <name>${image.name}:${project.docker.latesttagtimestamp.version}</name>
+ <alias>gra-container</alias>
+ <run>
+ <env>
+ <MYSQL_USER>sdnc</MYSQL_USER>
+ <MYSQL_PASSWORD>abc123</MYSQL_PASSWORD>
+ <MYSQL_DATABASE>sdnctl</MYSQL_DATABASE>
+ <SDNC_CONFIG_DIR>/opt/onap/sdnc/config</SDNC_CONFIG_DIR>
+ </env>
+ <dependsOn>
+ <container>gradb</container>
+ </dependsOn>
+ <network>
+ <mode>custom</mode>
+ <name>gra</name>
+ <alias>gra</alias>
+ </network>
+ <ports>
+ <port>gra.port:8080</port>
+ </ports>
+ <wait>
+ <log>Started GenericResourceMsApp</log>
+ <time>120000</time>
+ </wait>
+ <log>
+ <enabled>true</enabled>
+ </log>
+ </run>
+ </image>
+ </images>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-it-instance</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
<execution>
<id>push-images</id>
<phase>${docker.push.phase}</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());
+ }
+}