From b01df8be03edfbea5e6185d763496bd8cfa833ff Mon Sep 17 00:00:00 2001 From: "waqas.ikram" Date: Tue, 9 Jul 2019 16:14:17 +0000 Subject: [PATCH] Adding Infrastructure for Simulate Request for SDC Change-Id: Icf1100f180201735b4862cb0b9762d4a30750817 Issue-ID: SO-1949 Signed-off-by: waqas.ikram --- plans/so/integration-etsi-testing/.gitignore | 20 +++ .../so/integration-etsi-testing/docker-compose.yml | 34 ++++ plans/so/integration-etsi-testing/settings.xml | 171 +++++++++++++++++++++ plans/so/integration-etsi-testing/setup.sh | 113 ++++++++++++++ .../so-simulators/package/docker/pom.xml | 100 ++++++++++++ .../Dockerfile.so-simulator-base-image | 31 ++++ .../configs/logging/logback-spring.xml | 46 ++++++ .../main/docker/docker-files/scripts/start-app.sh | 56 +++++++ .../so-simulators/package/pom.xml | 18 +++ .../integration-etsi-testing/so-simulators/pom.xml | 64 ++++++++ .../so-simulators/sdc-simulator/pom.xml | 36 +++++ .../java/org/onap/so/sdc/simulator/Constant.java | 26 ++++ .../so/sdc/simulator/SdcSimulatorApplication.java | 35 +++++ .../so/sdc/simulator/SdcSimulatorController.java | 49 ++++++ .../src/main/resources/application.yaml | 5 + .../sdc/simulator/SdcSimulatorControllerTest.java | 66 ++++++++ plans/so/integration-etsi-testing/teardown.sh | 22 +++ plans/so/integration-etsi-testing/testplan.txt | 2 + 18 files changed, 894 insertions(+) create mode 100644 plans/so/integration-etsi-testing/.gitignore create mode 100644 plans/so/integration-etsi-testing/docker-compose.yml create mode 100755 plans/so/integration-etsi-testing/settings.xml create mode 100755 plans/so/integration-etsi-testing/setup.sh create mode 100644 plans/so/integration-etsi-testing/so-simulators/package/docker/pom.xml create mode 100644 plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/Dockerfile.so-simulator-base-image create mode 100644 plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml create mode 100644 plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/scripts/start-app.sh create mode 100644 plans/so/integration-etsi-testing/so-simulators/package/pom.xml create mode 100644 plans/so/integration-etsi-testing/so-simulators/pom.xml create mode 100644 plans/so/integration-etsi-testing/so-simulators/sdc-simulator/pom.xml create mode 100644 plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/Constant.java create mode 100644 plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorApplication.java create mode 100644 plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorController.java create mode 100644 plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml create mode 100644 plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/SdcSimulatorControllerTest.java create mode 100755 plans/so/integration-etsi-testing/teardown.sh create mode 100644 plans/so/integration-etsi-testing/testplan.txt diff --git a/plans/so/integration-etsi-testing/.gitignore b/plans/so/integration-etsi-testing/.gitignore new file mode 100644 index 00000000..675e83ca --- /dev/null +++ b/plans/so/integration-etsi-testing/.gitignore @@ -0,0 +1,20 @@ +target +**/.settings +**/.classpath +**/.project +**/.buildpath +**/.factorypath +**/.springBeans +.idea +.checkstyle +.DS_Store +.*~ +*.iml +*.class +*.swp +*.log +*.tmp +**/bin/ +/.metadata/ +temp/ +**/temp/** diff --git a/plans/so/integration-etsi-testing/docker-compose.yml b/plans/so/integration-etsi-testing/docker-compose.yml new file mode 100644 index 00000000..d725596e --- /dev/null +++ b/plans/so/integration-etsi-testing/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3' +services: +################################################################################ + sdc-simulator: + image: simulators/sdc-simulator:latest + ports: + - "9991:9991" + environment: + - APP=SDC-SIMULATOR + - JVM_ARGS=-Xms64m -Xmx512m + hostname: + sdc-simulator + logging: + driver: "json-file" + options: + max-size: "30m" + max-file: "5" +################################################################################ + VNFM-adapter: + image: nexus3.onap.org:10001/onap/so/vnfm-adapter:1.4.4 + ports: + - "9092:9092" + environment: + - APP=VNFM-adapter + - JVM_ARGS=-Xms64m -Xmx512m + hostname: + vnfm-adapter-test + logging: + driver: "json-file" + options: + max-size: "30m" + max-file: "5" +################################################################################ + diff --git a/plans/so/integration-etsi-testing/settings.xml b/plans/so/integration-etsi-testing/settings.xml new file mode 100755 index 00000000..5db52989 --- /dev/null +++ b/plans/so/integration-etsi-testing/settings.xml @@ -0,0 +1,171 @@ + + + + +${user.home}/.m2/repository + + + onap-settings + + https://nexus.onap.org + https://nexus.onap.org/content/sites/raw + https://nexus.onap.org/service/local/repositories/raw/content + ecomp-raw + + + nexus3.onap.org:10003 + nexus3.onap.org:10002 + nexus3.onap.org:10001 + nexus3.onap.org:10003 + + + + onap-snapshots + + + onap-snapshots + onap-snapshots + https://nexus.onap.org/content/repositories/snapshots/ + + false + + + true + + + + + + onap-snapshots + onap-snapshots + https://nexus.onap.org/content/repositories/snapshots/ + + false + + + true + + + + + + onap-releases + + + onap-releases + onap-releases + https://nexus.onap.org/content/repositories/releases/ + + true + + + false + + + + + + onap-releases + onap-releases + https://nexus.onap.org/content/repositories/releases/ + + true + + + false + + + + + + onap-public + + + central + http://repo1.maven.org/maven2/ + + + onap-public + onap-public + https://nexus.onap.org/content/repositories/public/ + + true + + + false + + + + + + central + http://repo1.maven.org/maven2/ + + + onap-public + onap-public + https://nexus.onap.org/content/repositories/public/ + + true + + + false + + + + + + + local-public + + + local-public + local-public + http://nexus-proxy:8081/nexus/content/repositories/public/ + + true + + + false + + + + + + local-public + local-public + http://nexus-proxy:8081/nexus/content/repositories/public/ + + true + + + false + + + + + + + + onap-settings + onap-snapshots + onap-releases + onap-public + + + + + diff --git a/plans/so/integration-etsi-testing/setup.sh b/plans/so/integration-etsi-testing/setup.sh new file mode 100755 index 00000000..25e7ee76 --- /dev/null +++ b/plans/so/integration-etsi-testing/setup.sh @@ -0,0 +1,113 @@ +#!/bin/bash +# +# ============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========================================================= + +# @author Waqas Ikram (waqas.ikram@est.tech) + +MAVEN_VERSION_DIR="apache-maven-3.3.9" +MAVEN_TAR_FILE="$MAVEN_VERSION_DIR-bin.tar.gz" +MAVEN_TAR_LOCATION="http://apache.claz.org/maven/maven-3/3.3.9/binaries/$MAVEN_TAR_FILE" + +SCRIPT_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +SCRIPT_NAME=$(basename $0) +TEMP_DIR_PATH=$SCRIPT_HOME/temp + +MAVEN_DIR=$TEMP_DIR_PATH/maven +INSTALLED_MAVEN_DIR=$MAVEN_DIR/$MAVEN_VERSION_DIR +MVN=$INSTALLED_MAVEN_DIR/bin/mvn +MVN_VERSION="$MVN -v" +MVN_SETTINGS_XML="$SCRIPT_HOME/settings.xml" +MVN_CLEAN_INSTALL="$MVN clean install" +SIMULATOR_MAVEN_PROJECT_POM="$SCRIPT_HOME/so-simulators/pom.xml" + +echo "Running $SCRIPT_HOME/$SCRIPT_NAME ..." + +if [[ ! "$TEMP_DIR_PATH" || ! -d "$TEMP_DIR_PATH" ]]; then + echo "Creating temporary directory $TEMP_DIR_PATH" + mkdir $TEMP_DIR_PATH + + if [ $? -ne 0 ]; then + echo "Could not create $TEMP_DIR_PATH" + exit 1 + fi + +fi +echo "Will use ${TEMP_DIR_PATH} directory" + +if [[ ! "$MAVEN_DIR" || ! -d "$MAVEN_DIR" ]]; then + echo "Creating temporary maven directory $MAVEN_DIR" + mkdir $MAVEN_DIR + + if [ $? -ne 0 ]; then + echo "Could not create $MAVEN_DIR" + exit 1 + fi +fi +echo "Will use ${MAVEN_DIR} directory for maven install" + +if [[ ! "$INSTALLED_MAVEN_DIR" || ! -d "$INSTALLED_MAVEN_DIR" ]]; then + echo "Installing maven ..." + cd $MAVEN_DIR + + CURL=`which curl` + if [[ ! "$CURL" ]]; then + echo "curl command is not installed" + echo "Unable to execute test plan" + exit 1 + fi + curl -O $MAVEN_TAR_LOCATION + + TAR=`which tar` + if [[ ! "$TAR" ]]; then + echo "tar command is not installed" + echo "Unable to execute test plan" + exit 1 + fi + + tar -xzvf apache-maven-3.3.9-bin.tar.gz + + echo "Finished installing maven ..." +fi + +echo "Maven installed under directory $INSTALLED_MAVEN_DIR" + +$MVN_VERSION + +if [ $? -ne 0 ]; then + echo "Unable to run mvn -v command" + exit 1 +fi + +cd $SCRIPT_HOME + +echo "Will build simulator project using $MVN_CLEAN_INSTALL -f $SIMULATOR_MAVEN_PROJECT_POM --settings $MVN_SETTINGS_XML" +$MVN_CLEAN_INSTALL -f $SIMULATOR_MAVEN_PROJECT_POM --settings $MVN_SETTINGS_XML + +export NEXUS_DOCKER_REPO_MSO=nexus3.onap.org:10001 +export TAG=1.4.0-STAGING-latest + +docker-compose up -d + +echo "Sleeping for 2m" +sleep 2m + +REPO_IP='127.0.0.1' +ROBOT_VARIABLES="-v REPO_IP:${REPO_IP}" + +echo "Finished executing $SCRIPT_HOME/$SCRIPT_NAME" diff --git a/plans/so/integration-etsi-testing/so-simulators/package/docker/pom.xml b/plans/so/integration-etsi-testing/so-simulators/package/docker/pom.xml new file mode 100644 index 00000000..873fa2ab --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/package/docker/pom.xml @@ -0,0 +1,100 @@ + + + package + org.onap.so.simulators + 1.0-SNAPSHOT + + 4.0.0 + + docker + pom + ${project.artifactId} + + + ${project.artifactId}-${project.version} + + + io.fabric8 + docker-maven-plugin + 0.28.0 + + + true + 1.23 + ${docker.pull.registry} + ${docker.push.registry} + + + + simulators/sdc-simulator + + try + docker-files + Dockerfile.so-simulator-base-image + + ${project.version} + + + + + + + org.onap.so.simulators:sdc-simulator + + app.jar + + + + + + + + + + + + clean-images + pre-clean + + remove + + + true + + + + + generate-images + generate-sources + + build + + + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8 + + true + + + + + + + + + org.onap.so.simulators + sdc-simulator + ${project.version} + + + + + diff --git a/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/Dockerfile.so-simulator-base-image b/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/Dockerfile.so-simulator-base-image new file mode 100644 index 00000000..f6f0fc9b --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/Dockerfile.so-simulator-base-image @@ -0,0 +1,31 @@ +FROM docker.io/openjdk:8-jdk-alpine + +ARG http_proxy +ARG https_proxy +ENV HTTP_PROXY=$http_proxy +ENV HTTPS_PROXY=$https_proxy +ENV http_proxy=$HTTP_PROXY +ENV https_proxy=$HTTPS_PROXY + +# Update the package list and upgrade installed packages +RUN apk update && apk upgrade + +# Install commonly needed tools +RUN apk --no-cache add curl netcat-openbsd sudo nss + +# Create 'so' user +RUN addgroup -g 1000 so && adduser -S -u 1000 -G so -s /bin/sh so + +RUN mkdir /app && mkdir /app/config && mkdir /app/logs + +COPY maven/app.jar /app +COPY configs/logging/logback-spring.xml /app +COPY scripts/start-app.sh /app + +RUN chown -R so:so /app && chmod 700 /app/*.sh + +# Springboot configuration (required) +VOLUME /app/config + +WORKDIR /app +CMD ["/app/start-app.sh"] diff --git a/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml b/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml new file mode 100644 index 00000000..13c91879 --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml @@ -0,0 +1,46 @@ + + + + + + + + + %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable + + + + + + ${logs_dir:-.}/spring-boot-logger.log + + %d %p %C{1.} [%t] %m%n + + + + + ${logs_dir:-.}/archived/spring-boot-logger-%d{yyyy-MM-dd}.%i.log + + + 10MB + + + + + + + + + + + + + + + + diff --git a/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/scripts/start-app.sh b/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/scripts/start-app.sh new file mode 100644 index 00000000..0ab3d27f --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/package/docker/src/main/docker/docker-files/scripts/start-app.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +# ============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========================================================= + +# @author Waqas Ikram (waqas.ikram@est.tech) + +touch /app/app.jar + +if [ -z "$APP" ]; then + echo "CONFIG ERROR: APP environment variable not set" + exit 1 +fi + +echo "Starting $APP simulator ... " + +if [ -z "${CONFIG_PATH}" ]; then + export CONFIG_PATH=/app/config/override.yaml +fi + +if [ -z "${LOG_PATH}" ]; then + export LOG_PATH="logs/${APP}" +fi + +if [ "${SSL_DEBUG}" = "log" ]; then + export SSL_DEBUG="-Djavax.net.debug=all" +else + export SSL_DEBUG= +fi + + +jvmargs="${JVM_ARGS} -Dlogs_dir=${LOG_PATH} -Dlogging.config=/app/logback-spring.xml -Dspring.config.additional-location=$CONFIG_PATH ${SSL_DEBUG} ${DISABLE_SNI}" + +echo "JVM Arguments: ${jvmargs}" + +java ${jvmargs} -jar app.jar +rc=$? + +echo "Application exiting with status code $rc" + +exit $rc diff --git a/plans/so/integration-etsi-testing/so-simulators/package/pom.xml b/plans/so/integration-etsi-testing/so-simulators/package/pom.xml new file mode 100644 index 00000000..e486ce7e --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/package/pom.xml @@ -0,0 +1,18 @@ + + + so-simulators + org.onap.so.simulators + 1.0-SNAPSHOT + + 4.0.0 + + package + pom + ${project.artifactId} + + docker + + + + diff --git a/plans/so/integration-etsi-testing/so-simulators/pom.xml b/plans/so/integration-etsi-testing/so-simulators/pom.xml new file mode 100644 index 00000000..feca047f --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/pom.xml @@ -0,0 +1,64 @@ + + 4.0.0 + + org.onap.so.simulators + so-simulators + + pom + ${project.artifactId} + 1.0-SNAPSHOT + + + 2.1 + UTF-8 + 1.8 + 1.8 + + + + sdc-simulator + package + + + + + + org.springframework.boot + spring-boot-starter-parent + 2.0.5.RELEASE + pom + import + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-aop + + + javax.ws.rs + javax.ws.rs-api + ${jax.ws.rs} + + + diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/pom.xml b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/pom.xml new file mode 100644 index 00000000..6a1baccf --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/pom.xml @@ -0,0 +1,36 @@ + + + so-simulators + org.onap.so.simulators + 1.0-SNAPSHOT + + 4.0.0 + + sdc-simulator + ${project.artifactId} + + + + + org.springframework.boot + spring-boot-maven-plugin + + org.onap.so.sdc.simulator.SdcSimulatorApplication + + + + + repackage + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/Constant.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/Constant.java new file mode 100644 index 00000000..c4e9c468 --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/Constant.java @@ -0,0 +1,26 @@ +/* + * ============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.sdc.simulator; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + */ +public class Constant { + + public static final String BASE_URL = "/sdc/simulator/v1"; + + private Constant() {} +} diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorApplication.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorApplication.java new file mode 100644 index 00000000..6bcd04d8 --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorApplication.java @@ -0,0 +1,35 @@ +/*- + * ============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.sdc.simulator; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + */ +@SpringBootApplication +public class SdcSimulatorApplication extends SpringBootServletInitializer { + public static void main(final String[] args) { + SpringApplication.run(SdcSimulatorApplication.class, args); + } +} diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorController.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorController.java new file mode 100644 index 00000000..12e179f8 --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorController.java @@ -0,0 +1,49 @@ +/*- + * ============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.sdc.simulator; + +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; +import javax.ws.rs.core.MediaType; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + */ +@RestController +@RequestMapping(path = Constant.BASE_URL, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) +public class SdcSimulatorController { + + private static final Logger LOGGER = LoggerFactory.getLogger(SdcSimulatorController.class); + + @GetMapping(value = "/healthcheck") + @ResponseStatus(code = HttpStatus.OK) + public String healthCheck() { + LOGGER.info("Running health check ..."); + return "healthy"; + } + + +} diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml new file mode 100644 index 00000000..f1e63b10 --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml @@ -0,0 +1,5 @@ +server: + port: 9991 + tomcat: + max-threads: 50 +ssl-enable: false diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/SdcSimulatorControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/SdcSimulatorControllerTest.java new file mode 100644 index 00000000..e0d44e93 --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/SdcSimulatorControllerTest.java @@ -0,0 +1,66 @@ +/*- + * ============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.sdc.simulator; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; +import org.junit.runner.RunWith; +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.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ActiveProfiles("test") +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class SdcSimulatorControllerTest { + + @LocalServerPort + private int port; + + @Autowired + private TestRestTemplate restTemplate; + + @Test + public void testHealthCheck() { + final HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + + final HttpEntity request = new HttpEntity<>(headers); + final String url = "http://localhost:" + port + Constant.BASE_URL + "/healthcheck"; + final ResponseEntity object = restTemplate.exchange(url, HttpMethod.GET, request, String.class); + + assertEquals("healthy", object.getBody()); + + } + +} diff --git a/plans/so/integration-etsi-testing/teardown.sh b/plans/so/integration-etsi-testing/teardown.sh new file mode 100755 index 00000000..8b778a57 --- /dev/null +++ b/plans/so/integration-etsi-testing/teardown.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# ============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========================================================= +# + +docker-compose down diff --git a/plans/so/integration-etsi-testing/testplan.txt b/plans/so/integration-etsi-testing/testplan.txt new file mode 100644 index 00000000..94b5442d --- /dev/null +++ b/plans/so/integration-etsi-testing/testplan.txt @@ -0,0 +1,2 @@ +# Test suites are relative paths under [integration/csit.git]/tests/. +# Place the suites in run order. -- 2.16.6