Creating infrastructure for aai simulator 62/91862/1
authorwaqas.ikram <waqas.ikram@est.tech>
Tue, 23 Jul 2019 12:39:15 +0000 (12:39 +0000)
committerwaqas.ikram <waqas.ikram@est.tech>
Tue, 23 Jul 2019 12:39:15 +0000 (12:39 +0000)
Change-Id: I73b15d50db8216e7fe3e2cade3b80fe645f363a9
Issue-ID: SO-1953
Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
15 files changed:
plans/so/integration-etsi-testing/docker-compose.yml
plans/so/integration-etsi-testing/so-simulators/aai-simulator/pom.xml [new file with mode: 0644]
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/AaiSimulatorApplication.java [new file with mode: 0644]
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/AaiSimulatorController.java [new file with mode: 0644]
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constant.java [new file with mode: 0644]
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml [new file with mode: 0644]
plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/AaiSimulatorControllerTest.java [new file with mode: 0644]
plans/so/integration-etsi-testing/so-simulators/package/docker/pom.xml
plans/so/integration-etsi-testing/so-simulators/pom.xml
plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorController.java
plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/providers/ResourceProviderImpl.java
plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/utils/Constant.java [moved from plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/Constant.java with 97% similarity]
plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml
plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/SdcSimulatorControllerTest.java
plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/providers/ResourceProviderImplTest.java

index bbc03df..2286c9a 100644 (file)
@@ -87,7 +87,7 @@ services:
       - --
       - "/app/start-app.sh"
 ################################################################################
-  VNFM-adapter:
+  vnfm-adapter:
     image: ${NEXUS_DOCKER_REPO_MSO}/onap/so/vnfm-adapter:${TAG}
     ports:
       - "9092:9092"
@@ -95,7 +95,7 @@ services:
       - ${TEST_LAB_DIR}/volumes/so/ca-certificates/onapheat:/app/ca-certificates
       - ${TEST_LAB_DIR}/volumes/so/config/vnfm-adapter/onapheat:/app/config
     environment:
-    - APP=VNFM-adapter
+    - APP=vnfm-adapter
     - JVM_ARGS=-Xms64m -Xmx512m
     hostname:
       vnfm-adapter-test
@@ -126,7 +126,25 @@ services:
       sdc-simulator
     depends_on:
       - mariadb
-      - VNFM-adapter
+      - vnfm-adapter
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "30m"
+        max-file: "5"
+################################################################################
+  aai-simulator:
+    image: simulators/aai-simulator:latest
+    ports:
+      - "9993:9993"
+    environment:
+    - APP=AAI-SIMULATOR
+    - JVM_ARGS=-Xms64m -Xmx512m
+    hostname:
+      aai-simulator
+    depends_on:
+      - mariadb
+      - vnfm-adapter
     logging:
       driver: "json-file"
       options:
@@ -146,7 +164,7 @@ services:
       - CATALOG_DB=catalogdb
     depends_on:
       - mariadb
-      - VNFM-adapter
+      - vnfm-adapter
     command:
       - "/config/apply-workarounds.sh"
 ################################################################################
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/pom.xml b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/pom.xml
new file mode 100644 (file)
index 0000000..1d1f8db
--- /dev/null
@@ -0,0 +1,34 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onap.so.simulators</groupId>
+        <artifactId>so-simulators</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>aai-simulator</artifactId>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <mainClass>org.onap.so.aai.simulator.AaiSimulatorApplication</mainClass>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/AaiSimulatorApplication.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/AaiSimulatorApplication.java
new file mode 100644 (file)
index 0000000..72c37ad
--- /dev/null
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aai.simulator;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@SpringBootApplication(scanBasePackages = {"org.onap"})
+public class AaiSimulatorApplication extends SpringBootServletInitializer {
+    
+    public static void main(final String[] args) {
+        SpringApplication.run(AaiSimulatorApplication.class, args);
+    }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/AaiSimulatorController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/AaiSimulatorController.java
new file mode 100644 (file)
index 0000000..4acae56
--- /dev/null
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aai.simulator;
+
+import javax.ws.rs.core.MediaType;
+import org.onap.so.aai.simulator.utils.Constant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@RestController
+@RequestMapping(path = Constant.BASE_URL)
+public class AaiSimulatorController {
+    private static final Logger LOGGER = LoggerFactory.getLogger(AaiSimulatorController.class);
+
+    @GetMapping(value = "/healthcheck", produces = MediaType.TEXT_PLAIN)
+    @ResponseStatus(code = HttpStatus.OK)
+    public String healthCheck() {
+        LOGGER.info("Running health check ...");
+        return Constant.HEALTHY;
+    }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constant.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/utils/Constant.java
new file mode 100644 (file)
index 0000000..9dd503b
--- /dev/null
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aai.simulator.utils;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+public class Constant {
+
+    public static final String BASE_URL = "/simulator/aai";
+
+    public static final String HEALTHY = "healthy";
+
+    private Constant() {}
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml
new file mode 100644 (file)
index 0000000..69f46ea
--- /dev/null
@@ -0,0 +1,5 @@
+server:
+  port: 9993
+  tomcat:
+    max-threads: 4
+ssl-enable: false
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/AaiSimulatorControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aai/simulator/AaiSimulatorControllerTest.java
new file mode 100644 (file)
index 0000000..0bd6aaa
--- /dev/null
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.aai.simulator;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.aai.simulator.utils.Constant;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ActiveProfiles("test")
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@Configuration
+public class AaiSimulatorControllerTest {
+
+    @LocalServerPort
+    private int port;
+
+    @Autowired
+    private TestRestTemplate restTemplate;
+
+    @Test
+    public void test_healthCheck_matchContent() {
+        final String url = getBaseUrl() + "/healthcheck";
+        final ResponseEntity<String> object = restTemplate.getForEntity(url, String.class);
+
+        assertEquals(Constant.HEALTHY, object.getBody());
+
+    }
+
+    private String getBaseUrl() {
+        return "http://localhost:" + port + Constant.BASE_URL;
+    }
+
+
+
+}
index 1753f4b..5736c8e 100644 (file)
                                 </assembly>
                             </build>
                         </image>
+                        <image>
+                            <name>simulators/aai-simulator</name>
+                            <build>
+                                <cleanup>try</cleanup>
+                                <dockerFileDir>docker-files</dockerFileDir>
+                                <dockerFile>Dockerfile.so-simulator-base-image</dockerFile>
+                                <tags>
+                                    <tag>${project.version}</tag>
+                                </tags>
+                                <assembly>
+                                    <inline>
+                                        <dependencySets>
+                                            <dependencySet>
+                                                <includes>
+                                                    <include>org.onap.so.simulators:aai-simulator</include>
+                                                </includes>
+                                                <outputFileNameMapping>app.jar</outputFileNameMapping>
+                                            </dependencySet>
+                                        </dependencySets>
+                                    </inline>
+                                </assembly>
+                            </build>
+                        </image>
                     </images>
                 </configuration>
 
                             <goal>build</goal>
                         </goals>
                     </execution>
-
-
                 </executions>
 
             </plugin>
             <artifactId>sdc-simulator</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.onap.so.simulators</groupId>
+            <artifactId>aai-simulator</artifactId>
+            <version>${project.version}</version>
+        </dependency>
     </dependencies>
 
 
index 5e582c8..c18e170 100644 (file)
@@ -18,6 +18,7 @@
 
     <modules>
         <module>sdc-simulator</module>
+        <module>aai-simulator</module>
         <module>package</module>
     </modules>
 
index 953df6f..b844caa 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.so.sdc.simulator;
 import java.util.Optional;
 import javax.ws.rs.core.MediaType;
 import org.onap.so.sdc.simulator.providers.ResourceProvider;
+import org.onap.so.sdc.simulator.utils.Constant;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -40,6 +41,7 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping(path = Constant.BASE_URL)
 public class SdcSimulatorController {
+    private static final Logger LOGGER = LoggerFactory.getLogger(SdcSimulatorController.class);
 
     private ResourceProvider resourceProvider;
 
@@ -47,8 +49,6 @@ public class SdcSimulatorController {
         this.resourceProvider = resourceProvider;
     }
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(SdcSimulatorController.class);
-
     @GetMapping(value = "/healthcheck", produces = MediaType.APPLICATION_JSON)
     @ResponseStatus(code = HttpStatus.OK)
     public String healthCheck() {
index 302dcb6..cdc96f6 100644 (file)
@@ -26,7 +26,7 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Optional;
-import org.onap.so.sdc.simulator.Constant;
+import org.onap.so.sdc.simulator.utils.Constant;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
index 5c7a77a..7834425 100644 (file)
@@ -23,14 +23,12 @@ package org.onap.so.sdc.simulator;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-
 import java.util.Optional;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
 import org.onap.so.sdc.simulator.providers.ResourceProvider;
+import org.onap.so.sdc.simulator.utils.Constant;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -51,8 +49,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 @Configuration
 public class SdcSimulatorControllerTest {
 
-    private static final String MOCKER_SDC_CONTROLLER_BEAN = "mockResourceProvider";
-
     @LocalServerPort
     private int port;