diff options
-rwxr-xr-x | engine/build-dockers.sh | 92 | ||||
-rw-r--r-- | engine/pom.xml | 4 | ||||
-rw-r--r-- | engine/src/docker/Dockerfile (renamed from engine/docker/Dockerfile) | 2 | ||||
-rw-r--r-- | engine/version.properties | 28 | ||||
-rwxr-xr-x | pom.xml | 12 | ||||
-rw-r--r-- | robot/testsuites/healthcheck/Valet-Test.robot | 81 | ||||
-rwxr-xr-x | valetapi/build-dockers.sh | 94 | ||||
-rw-r--r-- | valetapi/pom.xml | 63 | ||||
-rw-r--r-- | valetapi/src/main/java/org/onap/fgps/api/logging/EELFLoggerDelegate.java | 2 | ||||
-rw-r--r-- | valetapi/version.properties | 28 | ||||
-rw-r--r-- | version.properties | 9 |
11 files changed, 352 insertions, 63 deletions
diff --git a/engine/build-dockers.sh b/engine/build-dockers.sh new file mode 100755 index 0000000..68ede4e --- /dev/null +++ b/engine/build-dockers.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +# The script starts in the root folder of the repo, which has the following outline +# We fetch the version information from version.properties, build docker files and +# do a docker push. Since the job will be run under Jenkins, it will have the Nexus +# credentials + +set -e + +BUILD_ARGS="--no-cache" +ORG="onap" +PROJECT="fgps-engine" +DOCKER_REPOSITORY="nexus3.onap.org:10003" +IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}" + +# Version properties +source version.properties +VERSION=$release_version +SNAPSHOT=$snapshot_version +STAGING=${release_version}-STAGING +TIMESTAMP=$(date +"%Y%m%dT%H%M%S")Z +REPO="" + +if [ $HTTP_PROXY ]; then + BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}" +fi +if [ $HTTPS_PROXY ]; then + BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}" +fi + +function log_ts() { # Log message with timestamp + echo [DEBUG LOG at $(date -u +%Y%m%d:%H%M%S)] "$@" +} + +function get_artifact_version() { + log_ts Get Maven Artifact version from pom.xml + MVN_ARTIFACT_VERSION=`echo -e "setns x=http://maven.apache.org/POM/4.0.0 \n xpath /x:project/x:version/text() "| xmllint --shell pom.xml | grep content | sed 's/.*content=//'` + log_ts Maven artifact version for HAS is $MVN_ARTIFACT_VERSION + if [[ "$MVN_ARTIFACT_VERSION" =~ SNAPSHOT ]]; then + log_ts "REPO is snapshots"; + REPO=snapshots + else + log_ts "REPO is releases"; + REPO=releases + fi + BUILD_ARGS+=" --build-arg REPO=${REPO}" + BUILD_ARGS+=" --build-arg MVN_ARTIFACT_VERSION=${MVN_ARTIFACT_VERSION}" +} + +function build_image() { + log_ts Building Image in folder: $PWD with build arguments ${BUILD_ARGS} + docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest -f src/docker/Dockerfile . + log_ts ... Built +} + +function push_image() { + if [[ "$REPO" == snapshots ]]; then + push_snapshot_image + else + push_staging_image + fi +} + +function push_snapshot_image(){ + log_ts Tagging images: ${IMAGE_NAME}:\{${SNAPSHOT}-${TIMESTAMP},${SNAPSHOT}-latest\} + docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${SNAPSHOT}-${TIMESTAMP} + docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${SNAPSHOT}-latest + log_ts ... Tagged images + + log_ts Pushing images: ${IMAGE_NAME}:\{${SNAPSHOT}-${TIMESTAMP},${SNAPSHOT}-latest\} + docker push ${IMAGE_NAME}:${SNAPSHOT}-${TIMESTAMP} + docker push ${IMAGE_NAME}:${SNAPSHOT}-latest + log_ts ... Pushed images +} + +function push_staging_image(){ + log_ts Tagging images: ${IMAGE_NAME}:\{${STAGING}-${TIMESTAMP},${STAGING}-latest\} + docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${STAGING}-${TIMESTAMP} + docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${STAGING}-latest + log_ts ... Tagged images + + log_ts Pushing images: ${IMAGE_NAME}:\{${STAGING}-${TIMESTAMP},${STAGING}-latest\} + docker push ${IMAGE_NAME}:${STAGING}-${TIMESTAMP} + docker push ${IMAGE_NAME}:${STAGING}-latest + log_ts ... Pushed images +} + +( + get_artifact_version + build_image + push_image +) diff --git a/engine/pom.xml b/engine/pom.xml index df0d03a..e5207f5 100644 --- a/engine/pom.xml +++ b/engine/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.oparent</groupId> <artifactId>oparent-python</artifactId> - <version>2.0.0</version> + <version>2.1.0</version> </parent> <properties> @@ -49,7 +49,7 @@ <sonar.test.exclusions>**/**.py,setup.py,**/lib/**</sonar.test.exclusions> </properties> - <groupId>org.onap.fgps</groupId> + <groupId>org.onap.optf.fgps</groupId> <artifactId>fgps-engine</artifactId> <name>fgps-engine</name> diff --git a/engine/docker/Dockerfile b/engine/src/docker/Dockerfile index f8bf14e..8eccb13 100644 --- a/engine/docker/Dockerfile +++ b/engine/src/docker/Dockerfile @@ -21,3 +21,5 @@ USER valetu:valetg RUN date > /home/valetu/imagedate.txt CMD ["python", "valet/valet_main.py", "/opt/config/solver.json"] + + diff --git a/engine/version.properties b/engine/version.properties new file mode 100644 index 0000000..b847a8d --- /dev/null +++ b/engine/version.properties @@ -0,0 +1,28 @@ +# +# ------------------------------------------------------------------------- +# Copyright (c) 2015-2017 AT&T Intellectual Property +# +# 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. +# +# ------------------------------------------------------------------------- +# + +major=1 +minor=3 +patch=1 + +base_version=${major}.${minor}.${patch} + +# Release must be completed with git revision # in Jenkins +release_version=${base_version} +snapshot_version=${base_version}-SNAPSHOT @@ -21,7 +21,7 @@ <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> - <groupId>org.onap.fgps</groupId> + <groupId>org.onap.optf.fgps</groupId> <artifactId>fgps</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> @@ -29,7 +29,7 @@ <parent> <groupId>org.onap.oparent</groupId> <artifactId>oparent</artifactId> - <version>2.0.0</version> + <version>2.1.0</version> </parent> <properties> @@ -113,6 +113,14 @@ </compilerArgs> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>2.7</version> + <configuration> + <retryFailedDeploymentCount>2</retryFailedDeploymentCount> + </configuration> + </plugin> </plugins> </build> diff --git a/robot/testsuites/healthcheck/Valet-Test.robot b/robot/testsuites/healthcheck/Valet-Test.robot new file mode 100644 index 0000000..c626cef --- /dev/null +++ b/robot/testsuites/healthcheck/Valet-Test.robot @@ -0,0 +1,81 @@ +*** Settings *** +Library OperatingSystem +Library RequestsLibrary +Library json + +*** Variables *** +${Valet_Host}= http://10.12.6.165 +${Endpoint_API}= /api/valet/alive +${Endpoint_Ping}= /api/valet/ping +${Endpoint_Health}= /api/valet/healthcheck +${Valet_Port} = 8080 +${Valet_Url}= /api/valet +${Create_EP}= /placement/v1/ +${Authorization}= ${BASIC} ${AUTHVALUE} +${BASIC}= basic +${AUTHVALUE}= UWLoPObt6Bb837uJ4jbDYRoQ7zu7svyxeJh4NGY6IT/QjIOOsNA+AaHIGP/G0Bp7dWJLiEytrjPC+NjIGfeRrA== +${Reg_Id}= aic6 +${Vf_Mod_Id}= vf_module_uuid-006 +${Vf_Mod_Name}= test_stack_006 +${Stack_Name}= test_stack_006 +${Vnf_Id}= vnf_id_test-006 +${Create_Group_EP}= /groups/v1/ +${Req_ID}= GPlcp +${Tenant_ID}= 00000000000000000000000000000000 +${Vnf_Name}= vnf_name_test-006 +${Name}= new_rule_1 +${Prior_req_id}= testrackdiv01 +${Type}= affinity +${Level}= rack + +*** Test Cases *** +HealthCheck API + [Documentation] GET Call to confirm that Valet API is running + + Create Session Valet ${Valet_Host}:${Valet_Port} + &{headers}= Create Dictionary Content-Type=application/json + # ${StepName} Set Variable healthcheck + Log to Console ****************** + Log to Console Sending Get Call to check Valet API status + Log to Console ${Valet_Host}:${Valet_Port} is URL + #Log to Console ${headers} + ${resp}= Get Request Valet ${Endpoint_API} headers=${headers} + Sleep 30s + Log to Console Response from Server ${resp} + Log to Console ${resp.status_code} + Should Be Equal As Integers ${resp.status_code} 200 + Log to Console HealthCheck API Test case is Successful + + +HealthCheck Communication + [Documentation] GET Call to confirm that the API is running and communicating with Music + Create Session Valet ${Valet_Host}:${Valet_Port} + &{headers}= Create Dictionary Content-Type=application/json + # ${StepName} Set Variable healthcheck + Log to Console ****************** + Log to Console Sending Get Call to confirm that the API is running and communicating with Music + Log to Console ${Valet_Host}:${Valet_Port} is URL + # Log to Console Header is ${headers} + ${resp}= Get Request Valet ${Endpoint_Ping} headers=${headers} + Sleep 30s + Log to Console Response from Server ${resp} + Log to Console ${resp.status_code} + Should Be Equal As Integers ${resp.status_code} 200 + Log to Console HealthCheck Communication Test case is Successful + +HealthCheck API and Engine + [Documentation] GET Cal to confirm that API and Engine both are running, and able to communicate with each other through Music + Create Session Valet ${Valet_Host}:${Valet_Port} + &{headers}= Create Dictionary Content-Type=application/json + # ${StepName} Set Variable healthcheck + Log to Console ****************** + Log to Console Sending Get Call to confirm that the API is running and communicating with Music + Log to Console ${Valet_Host}:${Valet_Port} is URL + #Log to Console Header is ${headers} + ${resp}= Get Request Valet ${Endpoint_Health} headers=${headers} + Sleep 30s + Log to Console Response from Server ${resp} + Log to Console ${resp.status_code} + Should Be Equal As Integers ${resp.status_code} 200 + Log to Console HealthCheck API and Engine Test case is Successful + diff --git a/valetapi/build-dockers.sh b/valetapi/build-dockers.sh new file mode 100755 index 0000000..8faab28 --- /dev/null +++ b/valetapi/build-dockers.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +# The script starts in the root folder of the repo, which has the following outline +# We fetch the version information from version.properties, build docker files and +# do a docker push. Since the job will be run under Jenkins, it will have the Nexus +# credentials + +set -e + +BUILD_ARGS="--no-cache" +ORG="onap" +PROJECT="fgps-api" +DOCKER_REPOSITORY="nexus3.onap.org:10003" +IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}" + +# Version properties +source version.properties +VERSION=$release_version +SNAPSHOT=$snapshot_version +STAGING=${release_version}-STAGING +TIMESTAMP=$(date +"%Y%m%dT%H%M%S")Z +REPO="" + +if [ $HTTP_PROXY ]; then + BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}" +fi +if [ $HTTPS_PROXY ]; then + BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}" +fi + +function log_ts() { # Log message with timestamp + echo [DEBUG LOG at $(date -u +%Y%m%d:%H%M%S)] "$@" +} + +function get_artifact_version() { + log_ts Get Maven Artifact version from pom.xml + MVN_ARTIFACT_VERSION=`echo -e "setns x=http://maven.apache.org/POM/4.0.0 \n xpath /x:project/x:version/text() "| xmllint --shell conductor/pom.xml | grep content | sed 's/.*content=//'` + log_ts Maven artifact version for fgps-api is $MVN_ARTIFACT_VERSION + if [[ "$MVN_ARTIFACT_VERSION" =~ SNAPSHOT ]]; then + log_ts "REPO is snapshots"; + REPO=snapshots + else + log_ts "REPO is releases"; + REPO=releases + fi + BUILD_ARGS+=" --build-arg REPO=${REPO}" + BUILD_ARGS+=" --build-arg MVN_ARTIFACT_VERSION=${MVN_ARTIFACT_VERSION}" +} + +function build_image() { + log_ts Building Image in folder: $PWD with build arguments ${BUILD_ARGS} + mvn clean install + cp target/ValetApi.jar src/main/docker + docker build ${BUILD_ARGS} -t ${IMAGE_NAME}:latest src/main/docker + log_ts ... Built +} + +function push_image() { + if [[ "$REPO" == snapshots ]]; then + push_snapshot_image + else + push_staging_image + fi +} + +function push_snapshot_image(){ + log_ts Tagging images: ${IMAGE_NAME}:\{${SNAPSHOT}-${TIMESTAMP},${SNAPSHOT}-latest\} + docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${SNAPSHOT}-${TIMESTAMP} + docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${SNAPSHOT}-latest + log_ts ... Tagged images + + log_ts Pushing images: ${IMAGE_NAME}:\{${SNAPSHOT}-${TIMESTAMP},${SNAPSHOT}-latest\} + docker push ${IMAGE_NAME}:${SNAPSHOT}-${TIMESTAMP} + docker push ${IMAGE_NAME}:${SNAPSHOT}-latest + log_ts ... Pushed images +} + +function push_staging_image(){ + log_ts Tagging images: ${IMAGE_NAME}:\{${STAGING}-${TIMESTAMP},${STAGING}-latest\} + docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${STAGING}-${TIMESTAMP} + docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${STAGING}-latest + log_ts ... Tagged images + + log_ts Pushing images: ${IMAGE_NAME}:\{${STAGING}-${TIMESTAMP},${STAGING}-latest\} + docker push ${IMAGE_NAME}:${STAGING}-${TIMESTAMP} + docker push ${IMAGE_NAME}:${STAGING}-latest + log_ts ... Pushed images +} + +( + get_artifact_version + build_image + push_image +) diff --git a/valetapi/pom.xml b/valetapi/pom.xml index 14760c0..9ce50b4 100644 --- a/valetapi/pom.xml +++ b/valetapi/pom.xml @@ -3,14 +3,14 @@ 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>
- <groupId>org.onap.fgps</groupId>
+ <groupId>org.onap.optf.fgps</groupId>
<artifactId>fgps-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<swagger.directory>${basedir}/target/classes/META-INF/resources/swagger</swagger.directory>
<java.version>1.8</java.version>
- <docker.registry>nexus.onap.org:5100</docker.registry>
+<!-- <docker.registry>nexus.onap.org:5100</docker.registry> -->
<build.number>local</build.number>
<kube.namespace>org-onap-fgps</kube.namespace>
<service.account>svc-account</service.account>
@@ -147,22 +147,6 @@ <version>2.4.13</version>
</dependency>
<dependency>
- <groupId>au.com.dius</groupId>
- <artifactId>pact-jvm-consumer-junit_2.11</artifactId>
- <version>3.3.9</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>au.com.dius</groupId>
- <artifactId>pact-jvm-provider-junit_2.11</artifactId>
- <version>3.3.9</version>
- </dependency>
- <dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.38</version>
@@ -356,6 +340,14 @@ </execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.7</version>
+ <configuration>
+ <retryFailedDeploymentCount>2</retryFailedDeploymentCount>
+ </configuration>
+ </plugin>
<!-- Used for unit tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -401,41 +393,6 @@ </executions>
</plugin>
<plugin>
- <groupId>au.com.dius</groupId>
- <artifactId>pact-jvm-provider-maven_2.11</artifactId>
- <version>3.3.9</version>
- <configuration>
- <!--pactBrokerUrl,user name,password and project version required only
- for consumer -->
- <pactBrokerUrl>${BROKER_URL}</pactBrokerUrl>
- <pactBrokerUsername>${userName}</pactBrokerUsername>
- <pactBrokerPassword>${password}</pactBrokerPassword>
- <projectVersion>0.0.1</projectVersion>
- <!-- service provider required only for producer -->
- <serviceProviders>
- <serviceProvider>
- <name>ValetApi</name>
- <protocol>http</protocol>
- <host>${APP_URL}</host>
- <port>${APP_PORT}</port>
- <path>/</path>
- <pactBroker>
- <url>${BROKER_URL}</url>
- <authentication>
- <username>${userName}</username>
- <password>${password}</password>
- </authentication>
- </pactBroker>
- <!-- If you want to test specific PACT and specific port uncomment
- the consumers section and comment the pact broker in the service provider -->
- <!-- <consumers> <consumer> <name>pactconsumer</name> <pactUrl>${brokerUrl}/pacts/provider/pactdemo/consumer/pactdemo/latest</pactUrl>
- <pactUrl>${brokerUrl}/pacts/provider/pactdemo/consumer/pactconsumer2/version/0.0.1</pactUrl>
- </consumer> </consumers> -->
- </serviceProvider>
- </serviceProviders>
- </configuration>
- </plugin>
- <plugin>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
diff --git a/valetapi/src/main/java/org/onap/fgps/api/logging/EELFLoggerDelegate.java b/valetapi/src/main/java/org/onap/fgps/api/logging/EELFLoggerDelegate.java index 4208334..63617fa 100644 --- a/valetapi/src/main/java/org/onap/fgps/api/logging/EELFLoggerDelegate.java +++ b/valetapi/src/main/java/org/onap/fgps/api/logging/EELFLoggerDelegate.java @@ -58,7 +58,7 @@ import org.onap.fgps.api.logging.aspect.EELFLoggerAdvice; import org.onap.fgps.api.logging.format.AlarmSeverityEnum; //import org.onap.portalsdk.core.domain.User; import org.onap.fgps.api.utils.SystemProperties; -import org.onap.fgps.api.utils.UserUtils;; +import org.onap.fgps.api.utils.UserUtils; import org.slf4j.MDC; diff --git a/valetapi/version.properties b/valetapi/version.properties new file mode 100644 index 0000000..b847a8d --- /dev/null +++ b/valetapi/version.properties @@ -0,0 +1,28 @@ +# +# ------------------------------------------------------------------------- +# Copyright (c) 2015-2017 AT&T Intellectual Property +# +# 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. +# +# ------------------------------------------------------------------------- +# + +major=1 +minor=3 +patch=1 + +base_version=${major}.${minor}.${patch} + +# Release must be completed with git revision # in Jenkins +release_version=${base_version} +snapshot_version=${base_version}-SNAPSHOT diff --git a/version.properties b/version.properties index be52259..b847a8d 100644 --- a/version.properties +++ b/version.properties @@ -1,7 +1,6 @@ # # ------------------------------------------------------------------------- -# Copyright (c) 2019 AT&T Intellectual Property -# Modifications Copyright (C) 2019 IBM +# Copyright (c) 2015-2017 AT&T Intellectual Property # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,9 +17,9 @@ # ------------------------------------------------------------------------- # -major=1.0.0 -minor=1.0.0 -patch=1.0.0 +major=1 +minor=3 +patch=1 base_version=${major}.${minor}.${patch} |