summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2018-06-07 14:15:10 +0000
committerGerrit Code Review <gerrit@onap.org>2018-06-07 14:15:10 +0000
commit935ad375aab3c58a1ea245d2d20c49fc20941388 (patch)
treee3bc155089031f88c98a288c41fe8a13959e1fd8 /test
parent2805840c029892f85c6e723606fb18c9f6dd1529 (diff)
parentd77cb63fe253a8f9335764aeecf971348c894728 (diff)
Merge "Changing docker image tag" into beijing
Diffstat (limited to 'test')
-rwxr-xr-xtest/csit/plans/appc/healthcheck/setup.sh2
-rw-r--r--test/csit/plans/dcaegen2/prh_testsuites/setup.sh55
-rw-r--r--test/csit/plans/dcaegen2/prh_testsuites/teardown.sh20
-rw-r--r--test/csit/plans/dcaegen2/prh_testsuites/testplan.txt3
-rw-r--r--test/csit/tests/clamp/UIs/03__Verify_UI_Models.robot2
-rw-r--r--test/csit/tests/clamp/UIs/04__Submit_deploy_chain_Holmes.robot4
-rw-r--r--test/csit/tests/clamp/UIs/05__Submit_deploy_chain_TCA.robot4
-rw-r--r--test/csit/tests/dcaegen2/prh_testcases/__init__.robot0
-rw-r--r--test/csit/tests/dcaegen2/prh_testcases/prh_tests.robot65
-rw-r--r--test/csit/tests/dcaegen2/prh_testcases/resources/docker-compose.yml44
-rw-r--r--test/csit/tests/dcaegen2/prh_testcases/resources/simulator/AAI.py56
-rw-r--r--test/csit/tests/dcaegen2/prh_testcases/resources/simulator/AAI_simulator11
-rw-r--r--test/csit/tests/dcaegen2/prh_testcases/resources/simulator/DMaaP.py75
-rw-r--r--test/csit/tests/dcaegen2/prh_testcases/resources/simulator/DMaaP_simulator11
-rw-r--r--test/mocks/pnfsimulator/LICENSE.txt36
-rw-r--r--test/mocks/pnfsimulator/pom.xml278
-rwxr-xr-xtest/mocks/pnfsimulator/simulator.sh4
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java4
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/cli/SimulatorParams.java2
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/cli/SimulatorParamsProvider.java2
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java5
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java13
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/Simulator.java4
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java8
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientProvider.java2
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ParamsValidator.java103
-rw-r--r--test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ValidationException.java20
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/SimulatorParamsProviderTest.java20
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/SimulatorTest.java20
-rw-r--r--test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java27
-rw-r--r--test/vcpe/preload_templates/template.vcpe_brgemu_vfmodule.json281
-rw-r--r--test/vcpe/preload_templates/template.vcpe_vgw_vfmodule.json237
-rw-r--r--test/vcpe/preload_templates/template_sniro_data.json3
-rwxr-xr-xtest/vcpe/soutils.py31
-rwxr-xr-xtest/vcpe/vcpe.py27
-rwxr-xr-xtest/vcpe/vcpe_custom_service.py2
-rwxr-xr-xtest/vcpe/vcpecommon.py162
37 files changed, 976 insertions, 667 deletions
diff --git a/test/csit/plans/appc/healthcheck/setup.sh b/test/csit/plans/appc/healthcheck/setup.sh
index 51d100033..a0683fbe6 100755
--- a/test/csit/plans/appc/healthcheck/setup.sh
+++ b/test/csit/plans/appc/healthcheck/setup.sh
@@ -20,7 +20,7 @@
SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source ${WORKSPACE}/test/csit/scripts/appc/script1.sh
-export APPC_DOCKER_IMAGE_VERSION=1.3.0-SNAPSHOT-latest
+export APPC_DOCKER_IMAGE_VERSION=1.4.0-SNAPSHOT-latest
export CCSDK_DOCKER_IMAGE_VERSION=0.2-STAGING-latest
export BRANCH=beijing
export SOLUTION_NAME=onap
diff --git a/test/csit/plans/dcaegen2/prh_testsuites/setup.sh b/test/csit/plans/dcaegen2/prh_testsuites/setup.sh
new file mode 100644
index 000000000..279696597
--- /dev/null
+++ b/test/csit/plans/dcaegen2/prh_testsuites/setup.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+source ${SCRIPTS}/common_functions.sh
+
+export PRH_SERVICE="prh"
+export DMAAP_SIMULATOR="dmaap_simulator"
+export AAI_SIMULATOR="aai_simulator"
+
+cd ${WORKSPACE}/test/csit/tests/dcaegen2/prh_testcases/resources/
+
+docker login -u docker -p docker nexus3.onap.org:10003
+docker-compose up -d --build
+
+# Wait for initialization of Docker containers
+for i in {1..50}; do
+ if [ $(docker inspect --format '{{ .State.Running }}' ${PRH_SERVICE}) ] && \
+ [ $(docker inspect --format '{{ .State.Running }}' ${DMAAP_SIMULATOR}) ] && \
+ [ $(docker inspect --format '{{ .State.Running }}' ${AAI_SIMULATOR}) ]
+ then
+ echo "dmaap_simulator, aai_simulator and prh services are running"
+ break
+ else
+ echo sleep ${i}
+ sleep ${i}
+ fi
+done
+
+PRH_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${PRH_SERVICE})
+DMAAP_SIMULATOR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${DMAAP_SIMULATOR})
+AAI_SIMULATOR_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${AAI_SIMULATOR})
+
+bypass_ip_adress ${PRH_IP}
+bypass_ip_adress ${DMAAP_SIMULATOR_IP}
+bypass_ip_adress ${AAI_SIMULATOR_IP}
+
+echo PRH_IP=${PRH_IP}
+echo DMAAP_SIMULATOR_IP=${DMAAP_SIMULATOR_IP}
+echo AAI_SIMULATOR_IP=${AAI_SIMULATOR_IP}
+
+# Wait for initialization of docker services
+for i in {1..50}; do
+ curl -sS -m 1 localhost:2222 && \
+ curl -sS -m 1 localhost:3333 && \
+ curl -sS -m 1 localhost:8100/heartbeat && break
+ echo sleep ${i}
+ sleep ${i}
+done
+
+docker cp prh:/config/prh_endpoints.json ${WORKDIR}
+sed -i -e 's/"dmaapHostName":.*/"dmaapHostName": "'${DMAAP_SIMULATOR_IP}'",/g' ${WORKDIR}/prh_endpoints.json
+sed -i -e 's/"aaiHost":.*/"aaiHost": "'${AAI_SIMULATOR_IP}'",/g' ${WORKDIR}/prh_endpoints.json
+docker cp ${WORKDIR}/prh_endpoints.json prh:/config/
+
+#Pass any variables required by Robot test suites in ROBOT_VARIABLES
+ROBOT_VARIABLES="-v DMAAP_SIMULATOR:localhost:2222 -v AAI_SIMULATOR:localhost:3333 -v PRH:localhost:8100"
diff --git a/test/csit/plans/dcaegen2/prh_testsuites/teardown.sh b/test/csit/plans/dcaegen2/prh_testsuites/teardown.sh
new file mode 100644
index 000000000..bd1e5ba06
--- /dev/null
+++ b/test/csit/plans/dcaegen2/prh_testsuites/teardown.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Copyright 2017 Nokia, Inc. and others.
+#
+# 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.
+#
+
+kill-instance.sh prh
+kill-instance.sh dmaap_simulator
+kill-instance.sh aai_simulator
diff --git a/test/csit/plans/dcaegen2/prh_testsuites/testplan.txt b/test/csit/plans/dcaegen2/prh_testsuites/testplan.txt
new file mode 100644
index 000000000..8c1f3274a
--- /dev/null
+++ b/test/csit/plans/dcaegen2/prh_testsuites/testplan.txt
@@ -0,0 +1,3 @@
+# Test suites are relative paths under [integration.git]/test/csit/tests/.
+# Place the suites in run order.
+dcaegen2/prh_testcases
diff --git a/test/csit/tests/clamp/UIs/03__Verify_UI_Models.robot b/test/csit/tests/clamp/UIs/03__Verify_UI_Models.robot
index a9cb78749..8bbf7c85e 100644
--- a/test/csit/tests/clamp/UIs/03__Verify_UI_Models.robot
+++ b/test/csit/tests/clamp/UIs/03__Verify_UI_Models.robot
@@ -21,7 +21,7 @@ Verify HolmesModel1
Should Contain Match ${resp} *migrate*
Should Contain Match ${resp} *240*
Should Contain Match ${resp} *390*
- Should Contain Match ${resp} *correlational Logic1*
+ Should Contain Match ${resp} *Logic1*
Should Contain Match ${resp} *config Policy Name1*
Verify TCAModel1
diff --git a/test/csit/tests/clamp/UIs/04__Submit_deploy_chain_Holmes.robot b/test/csit/tests/clamp/UIs/04__Submit_deploy_chain_Holmes.robot
index f400156d1..32b4ce7ec 100644
--- a/test/csit/tests/clamp/UIs/04__Submit_deploy_chain_Holmes.robot
+++ b/test/csit/tests/clamp/UIs/04__Submit_deploy_chain_Holmes.robot
@@ -78,8 +78,8 @@ Deploy Holmes CL
Click Element xpath=//*[@id="navbar"]/ul/li[2]/a
Wait Until Element Is Visible locator=Deploy timeout=60
Click Element locator=Deploy
- Wait Until Element Is Visible xpath=//*[@id="deployProperties"] timeout=60
- Input Text xpath=//*[@id="deployProperties"] text={}
+# Wait Until Element Is Visible xpath=//*[@id="deployProperties"] timeout=60
+# Input Text xpath=//*[@id="deployProperties"] text={}
Click Button locator=Deploy
Click Button locator=Yes
Wait Until Element Is Visible xpath=//*[@id="alert_message_"] timeout=60
diff --git a/test/csit/tests/clamp/UIs/05__Submit_deploy_chain_TCA.robot b/test/csit/tests/clamp/UIs/05__Submit_deploy_chain_TCA.robot
index 34c1a71ef..db72f3bbd 100644
--- a/test/csit/tests/clamp/UIs/05__Submit_deploy_chain_TCA.robot
+++ b/test/csit/tests/clamp/UIs/05__Submit_deploy_chain_TCA.robot
@@ -78,8 +78,8 @@ Deploy TCA CL
Click Element xpath=//*[@id="navbar"]/ul/li[2]/a
Wait Until Element Is Visible locator=Deploy timeout=60
Click Element locator=Deploy
- Wait Until Element Is Visible xpath=//*[@id="deployProperties"] timeout=60
- Input Text xpath=//*[@id="deployProperties"] text={}
+# Wait Until Element Is Visible xpath=//*[@id="deployProperties"] timeout=60
+# Input Text xpath=//*[@id="deployProperties"] text={}
Click Button locator=Deploy
Click Button locator=Yes
Wait Until Element Is Visible xpath=//*[@id="alert_message_"] timeout=60
diff --git a/test/csit/tests/dcaegen2/prh_testcases/__init__.robot b/test/csit/tests/dcaegen2/prh_testcases/__init__.robot
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh_testcases/__init__.robot
diff --git a/test/csit/tests/dcaegen2/prh_testcases/prh_tests.robot b/test/csit/tests/dcaegen2/prh_testcases/prh_tests.robot
new file mode 100644
index 000000000..764a879a3
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh_testcases/prh_tests.robot
@@ -0,0 +1,65 @@
+*** Settings ***
+Library RequestsLibrary
+
+*** Variables ***
+${DMAAP_SIM_URL} http://${DMAAP_SIMULATOR}
+${AAI_SIM_URL} http://${AAI_SIMULATOR}
+${PRH_URL} http://${PRH}
+
+*** Test Cases ***
+Getting and Consuming Positive Scenario
+ [Documentation] Get message from new topic and consume it - positive scenarios
+ [Tags] PRH
+ [Setup] Start prh
+ [Template] Run Getting and Consuming
+ [Timeout]
+ {"pnfName":"NOKQTFCOC540002E","ipv4":"10.16.123.234","ipv6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334"} NOKQTFCOC540002E {"event": {"commonEventHeader": {"sourceId":"QTFCOC540002E", "startEpochMicrosec":1519837825682, "eventId":"QTFCOC540002E-reg", "nfcNamingCode":"5DU", "internalHeaderFields":{"collectorTimeStamp":"Fri, 04 27 2018 09:01:10 GMT"}, "eventType":"pnfRegistration", "priority":"Normal", "version":3, "reportingEntityName":"5GRAN_DU", "sequence":0, "domain":"other", "lastEpochMicrosec":1519837825682, "eventName":"pnfRegistration_5GDU", "sourceName":"5GRAN_DU", "nfNamingCode":"5GRAN"}, "otherFields": {"pnfLastServiceDate":1517206400, "pnfOamIpv6Address":"2001:0db8:85a3:0000:0000:8a2e:0370:7334", "pnfVendorName":"Nokia", "pnfModelNumber":"AJ02", "pnfFamily":"BBU", "pnfType":"AirScale", "otherFieldsVersion":1, "pnfOamIpv4Address":"10.16.123.234", "pnfSoftwareVersion":"v4.5.0.1", "pnfSerialNumber":"QTFCOC540002E", "pnfManufactureDate":1516406400}}}
+ {"pnfName":"NOKQTFCOC540002F","ipv4":"","ipv6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334"} NOKQTFCOC540002F {"event": {"commonEventHeader": {"sourceId":"QTFCOC540002F", "startEpochMicrosec":1519837825682, "eventId":"QTFCOC540002F-reg", "nfcNamingCode":"5DU", "internalHeaderFields":{"collectorTimeStamp":"Fri, 04 27 2018 09:01:10 GMT"}, "eventType":"pnfRegistration", "priority":"Normal", "version":3, "reportingEntityName":"5GRAN_DU", "sequence":0, "domain":"other", "lastEpochMicrosec":1519837825682, "eventName":"pnfRegistration_5GDU", "sourceName":"5GRAN_DU", "nfNamingCode":"5GRAN"}, "otherFields": {"pnfLastServiceDate":1517206400, "pnfOamIpv6Address":"2001:0db8:85a3:0000:0000:8a2e:0370:7334", "pnfVendorName":"Nokia", "pnfModelNumber":"AJ02", "pnfFamily":"BBU", "pnfType":"AirScale", "otherFieldsVersion":1, "pnfOamIpv4Address":"", "pnfSoftwareVersion":"v4.5.0.1", "pnfSerialNumber":"QTFCOC540002F", "pnfManufactureDate":1516406400}}}
+ {"pnfName":"NOKQTFCOC540002G","ipv4":"10.16.123.234","ipv6":""} NOKQTFCOC540002G {"event": {"commonEventHeader": {"sourceId":"QTFCOC540002G", "startEpochMicrosec":1519837825682, "eventId":"QTFCOC540002G-reg", "nfcNamingCode":"5DU", "internalHeaderFields":{"collectorTimeStamp":"Fri, 04 27 2018 09:01:10 GMT"}, "eventType":"pnfRegistration", "priority":"Normal", "version":3, "reportingEntityName":"5GRAN_DU", "sequence":0, "domain":"other", "lastEpochMicrosec":1519837825682, "eventName":"pnfRegistration_5GDU", "sourceName":"5GRAN_DU", "nfNamingCode":"5GRAN"}, "otherFields": {"pnfLastServiceDate":1517206400, "pnfOamIpv6Address":"", "pnfVendorName":"Nokia", "pnfModelNumber":"AJ02", "pnfFamily":"BBU", "pnfType":"AirScale", "otherFieldsVersion":1, "pnfOamIpv4Address":"10.16.123.234", "pnfSoftwareVersion":"v4.5.0.1", "pnfSerialNumber":"QTFCOC540002G", "pnfManufactureDate":1516406400}}}
+ {"pnfName":"ERIQTFCOC5400000","ipv4":"10.16.123.23","ipv6":""} ERIQTFCOC5400000 {"event": {"commonEventHeader": {"sourceId":"QTFCOC5400000", "startEpochMicrosec":1519837825682, "eventId":"QTFCOC5400000-reg", "nfcNamingCode":"5DU", "internalHeaderFields":{"collectorTimeStamp":"Fri, 04 27 2018 09:01:10 GMT"}, "eventType":"pnfRegistration", "priority":"Normal", "version":3, "reportingEntityName":"5GRAN_DU", "sequence":0, "domain":"other", "lastEpochMicrosec":1519837825682, "eventName":"pnfRegistration_5GDU", "sourceName":"5GRAN_DU", "nfNamingCode":"5GRAN"}, "otherFields": {"pnfLastServiceDate":1517206400, "pnfOamIpv6Address":"", "pnfVendorName":"Ericsson", "pnfModelNumber":"AJ02", "pnfFamily":"BBU", "pnfType":"AirScale", "otherFieldsVersion":1, "pnfOamIpv4Address":"10.16.123.23", "pnfSoftwareVersion":"v4.5.0.1", "pnfSerialNumber":"QTFCOC5400000", "pnfManufactureDate":1516406400}}}
+ [Teardown] Stop prh
+
+*** Keywords ***
+Run Getting and Consuming
+ [Arguments] ${posted_event_to_dmaap} ${pnfs_name} ${event_in_dmaap}
+ [Timeout] 1 minutes
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
+ Set pnfs name in AAI ${pnfs_name}
+ Set get event in DMAAP ${event_in_dmaap} ${headers}
+ : FOR ${Index} IN RANGE 1 30
+ \ Create Session prh_ready ${DMAAP_SIM_URL}
+ \ ${resp}= Get Request prh_ready /events/pnfReady headers=${headers}
+ \ Exit For Loop If '${resp.text}' == '${posted_event_to_dmaap}'
+ \ Sleep 1s
+ Should Be Equal ${resp.text} ${posted_event_to_dmaap}
+
+Start prh
+ [Timeout] 1 minute
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
+ Create Session prh_start ${PRH_URL}
+ ${resp}= Get Request prh_start /start headers=${headers}
+ Should Be Equal ${resp.text} "PRH Service has been started!"
+
+Stop prh
+ [Timeout] 1 minute
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
+ Create Session prh_stop ${PRH_URL}
+ ${resp}= Get Request prh_stop /stopPrh headers=${headers}
+ Should Be Equal ${resp.text} "PRH Service has already been stopped!"
+
+Set pnfs name in AAI
+ [Arguments] ${pnfs_name}
+ [Timeout] 1 minute
+ ${headers}= Create Dictionary Accept=application/json Content-Type=text/html
+ Create Session set_pnfs_in_aai ${AAI_SIM_URL}
+ ${resp}= Put Request set_pnfs_in_aai /set_pnfs headers=${headers} data=${pnfs_name}
+ Should Be Equal As Strings ${resp.status_code} 200
+ Log To Console ${resp.text}
+
+Set get event in DMAAP
+ [Arguments] ${event_in_dmaap} ${headers}
+ [Timeout] 1 minute
+ Create Session set_get_event ${DMAAP_SIM_URL}
+ ${resp}= Put Request set_get_event /set_get_event headers=${headers} data=${event_in_dmaap}
+ Should Be Equal As Strings ${resp.status_code} 200
+ Log To Console ${resp.text}
diff --git a/test/csit/tests/dcaegen2/prh_testcases/resources/docker-compose.yml b/test/csit/tests/dcaegen2/prh_testcases/resources/docker-compose.yml
new file mode 100644
index 000000000..e27d84516
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh_testcases/resources/docker-compose.yml
@@ -0,0 +1,44 @@
+version: '3'
+services:
+ prh:
+ image: nexus3.onap.org:10003/onap/org.onap.dcaegen2.services.prh.prh-app-server
+ command: >
+ --dmaap.dmaapConsumerConfiguration.dmaapPortNumber=2222
+ --dmaap.dmaapProducerConfiguration.dmaapPortNumber=2222
+ --aai.aaiClientConfiguration.aaiHostPortNumber=3333
+ --aai.aaiClientConfiguration.aaiProtocol=http
+ entrypoint:
+ - java
+ - -Dspring.profiles.active=dev
+ - -Dlogging.level.org.onap.dcaegen2.services.prh=TRACE
+ - -jar
+ - /opt/prh-app-server.jar
+ ports:
+ - "8100:8100"
+ - "8433:8433"
+ container_name: prh
+
+ dmaap_simulator:
+ build:
+ context: simulator
+ dockerfile: DMaaP_simulator
+ args:
+ - https_proxy=${HTTPS_PROXY}
+ ports:
+ - "2222:2222"
+ container_name: dmaap_simulator
+ depends_on:
+ - prh
+
+ aai_simulator:
+ build:
+ context: simulator
+ dockerfile: AAI_simulator
+ args:
+ - https_proxy=${HTTPS_PROXY}
+ ports:
+ - "3333:3333"
+ container_name: aai_simulator
+ depends_on:
+ - prh
+ \ No newline at end of file
diff --git a/test/csit/tests/dcaegen2/prh_testcases/resources/simulator/AAI.py b/test/csit/tests/dcaegen2/prh_testcases/resources/simulator/AAI.py
new file mode 100644
index 000000000..f9d0ee07b
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh_testcases/resources/simulator/AAI.py
@@ -0,0 +1,56 @@
+import BaseHTTPServer
+import re
+import sys
+
+from robot.api import logger
+
+pnfs = 'Empty'
+
+class AAIHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+ def do_PUT(self):
+ if re.search('/set_pnfs', self.path):
+ global pnfs
+ content_length = int(self.headers['Content-Length'])
+ pnfs = self.rfile.read(content_length)
+ self.send_response(200)
+ self.send_header('Content-Type', 'application/json')
+ self.end_headers()
+
+ return
+
+ def do_PATCH(self):
+ pnfs_name = '/aai/v12/network/pnfs/pnf/' + pnfs
+ if re.search(pnfs_name, self.path):
+ self.send_response(200)
+ self.end_headers()
+
+ return
+
+ def do_GET(self):
+ self.send_response(200)
+ self.send_header('Content-Type', 'application/json')
+ self.end_headers()
+ self.wfile.write('GET')
+ self.wfile.close()
+
+ return
+
+def _main_ (HandlerClass = AAIHandler,
+ ServerClass = BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"):
+
+ if sys.argv[1:]:
+ port = int(sys.argv[1])
+ else:
+ port = 3333
+
+ server_address = ('', port)
+
+ HandlerClass.protocol_version = protocol
+ httpd = ServerClass(server_address, HandlerClass)
+
+ sa = httpd.socket.getsockname()
+ print "Serving HTTP on", sa[0], "port", sa[1], "..."
+ httpd.serve_forever()
+
+if __name__ == '__main__':
+ _main_()
diff --git a/test/csit/tests/dcaegen2/prh_testcases/resources/simulator/AAI_simulator b/test/csit/tests/dcaegen2/prh_testcases/resources/simulator/AAI_simulator
new file mode 100644
index 000000000..2d96d8925
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh_testcases/resources/simulator/AAI_simulator
@@ -0,0 +1,11 @@
+FROM python:2
+
+ENV https_proxy "$https_proxy"
+
+ADD AAI.py /
+
+RUN pip install robotframework
+
+EXPOSE 3333
+
+CMD [ "python", "./AAI.py" ]
diff --git a/test/csit/tests/dcaegen2/prh_testcases/resources/simulator/DMaaP.py b/test/csit/tests/dcaegen2/prh_testcases/resources/simulator/DMaaP.py
new file mode 100644
index 000000000..af716fd06
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh_testcases/resources/simulator/DMaaP.py
@@ -0,0 +1,75 @@
+import BaseHTTPServer
+import re
+import sys
+
+from robot.api import logger
+
+posted_event_from_prh = 'Empty'
+received_event_to_get_method = 'Empty'
+
+class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+ def do_PUT(self):
+ if re.search('/set_get_event', self.path):
+ global received_event_to_get_method
+ content_length = int(self.headers['Content-Length'])
+ received_event_to_get_method = self.rfile.read(content_length)
+ self.send_response(200)
+ self.send_header('Content-Type', 'application/json')
+ self.end_headers()
+
+ return
+
+ def do_POST(self):
+ if re.search('/events/pnfReady', self.path):
+ global posted_event_from_prh
+ content_length = int(self.headers['Content-Length'])
+ posted_event_from_prh = self.rfile.read(content_length)
+ self.send_response(200)
+ self.send_header('Content-Type', 'application/json')
+ self.end_headers()
+
+ return
+
+ def do_GET(self):
+ if re.search('/events/unauthenticated.SEC_OTHER_OUTPUT', self.path):
+ self.send_response(200)
+ self.send_header('Content-Type', 'application/json')
+ self.end_headers()
+ self.wfile.write(received_event_to_get_method)
+ self.wfile.close()
+ elif re.search('/events/pnfReady', self.path):
+ self.send_response(200)
+ self.send_header('Content-Type', 'application/json')
+ self.end_headers()
+ self.wfile.write(posted_event_from_prh)
+ global posted_event_from_prh
+ posted_event_from_prh = 'Empty'
+ self.wfile.close()
+ else:
+ self.send_response(200)
+ self.send_header('Content-Type', 'application/json')
+ self.end_headers()
+ self.wfile.write('GET else')
+ self.wfile.close()
+
+ return
+
+def _main_ (HandlerClass = DMaaPHandler,
+ ServerClass = BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"):
+
+ if sys.argv[1:]:
+ port = int(sys.argv[1])
+ else:
+ port = 2222
+
+ server_address = ('', port)
+
+ HandlerClass.protocol_version = protocol
+ httpd = ServerClass(server_address, HandlerClass)
+
+ sa = httpd.socket.getsockname()
+ print "Serving HTTP on", sa[0], "port", sa[1], "..."
+ httpd.serve_forever()
+
+if __name__ == '__main__':
+ _main_()
diff --git a/test/csit/tests/dcaegen2/prh_testcases/resources/simulator/DMaaP_simulator b/test/csit/tests/dcaegen2/prh_testcases/resources/simulator/DMaaP_simulator
new file mode 100644
index 000000000..4de65393d
--- /dev/null
+++ b/test/csit/tests/dcaegen2/prh_testcases/resources/simulator/DMaaP_simulator
@@ -0,0 +1,11 @@
+FROM python:2
+
+ENV https_proxy "$https_proxy"
+
+ADD DMaaP.py /
+
+RUN pip install robotframework
+
+EXPOSE 2222
+
+CMD [ "python", "./DMaaP.py" ]
diff --git a/test/mocks/pnfsimulator/LICENSE.txt b/test/mocks/pnfsimulator/LICENSE.txt
deleted file mode 100644
index 22e7ef85c..000000000
--- a/test/mocks/pnfsimulator/LICENSE.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-* ============LICENSE_START==========================================
-* ===================================================================
-* Copyright (c) 2018 NOKIA Intellectual Property. All rights reserved.
-* ===================================================================
-*
-* Unless otherwise specified, all software contained herein is licensed
-* under the Apache License, Version 2.0 (the "License");
-* you may not use this software 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.
-*
-*
-*
-* Unless otherwise specified, all documentation contained herein is licensed
-* under the Creative Commons License, Attribution 4.0 Intl. (the "License");
-* you may not use this documentation except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* https://creativecommons.org/licenses/by/4.0/
-*
-* Unless required by applicable law or agreed to in writing, documentation
-* 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.
-*
-* ============LICENSE_END============================================
-*/ \ No newline at end of file
diff --git a/test/mocks/pnfsimulator/pom.xml b/test/mocks/pnfsimulator/pom.xml
index 1f1f46a04..2fee83622 100644
--- a/test/mocks/pnfsimulator/pom.xml
+++ b/test/mocks/pnfsimulator/pom.xml
@@ -1,155 +1,153 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
+ 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.oparent</groupId>
- <artifactId>oparent</artifactId>
- <version>0.1.1</version>
- </parent>
+ <groupId>org.onap.pnfsimulator</groupId>
+ <artifactId>pnf-simulator</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
- <groupId>org.onap.pnfsimulator</groupId>
- <artifactId>pnf-simulator</artifactId>
- <version>1.0</version>
-
- <name>pnf-simulator</name>
+ <name>pnf-simulator</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<simulator.main.class>org.onap.pnfsimulator.Main</simulator.main.class>
+ <docker.image.tag>${project.version}-latest</docker.image.tag>
<dependency.directory.name>libs</dependency.directory.name>
- <dependency.directory.location>${project.build.directory}/${dependency.directory.name}
- </dependency.directory.location>
- </properties>
+ <dependency.directory.location>${project.build.directory}/${dependency.directory.name}</dependency.directory.location>
+ <onap.nexus.dockerregistry.daily>nexus3.onap.org:10003</onap.nexus.dockerregistry.daily>
+ </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <version>2.11.0</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.6</version>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20180130</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.5.5</version>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>21.0</version>
- </dependency>
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <version>5.1.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <version>3.9.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.7</version>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>2.11.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20180130</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.5</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>21.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>5.1.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.9.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.7</version>
+ </dependency>
+ </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>${maven.compiler.source}</source>
- <target>${maven.compiler.target}</target>
- <showWarnings>true</showWarnings>
- <showDeprecation>true</showDeprecation>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.19</version>
- <dependencies>
- <dependency>
- <groupId>org.junit.platform</groupId>
- <artifactId>junit-platform-surefire-provider</artifactId>
- <version>1.1.1</version>
- </dependency>
- </dependencies>
- <configuration>
- <detail>true</detail>
- <printSummary>true</printSummary>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <configuration>
- <outputDirectory>${dependency.directory.location}</outputDirectory>
- <includeScope>runtime</includeScope>
- <silent>true</silent>
- </configuration>
- <executions>
- <execution>
- <id>copy-external-dependencies</id>
- <phase>package</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>com.spotify</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <configuration>
- <skipDockerBuild>false</skipDockerBuild>
- <imageName>
- ${onap.nexus.dockerregistry.daily}/onap/${project.artifactId}
- </imageName>
- <baseImage>openjdk:8-jdk-alpine</baseImage>
- <cmd>java -cp ${dependency.directory.name}/*:${project.build.finalName}.jar ${simulator.main.class}
- </cmd>
- <resources>
- <resource>
- <targetPath>${dependency.directory.name}</targetPath>
- <directory>${dependency.directory.location}</directory>
- </resource>
- <resource>
- <targetPath>/</targetPath>
- <directory>${project.build.directory}</directory>
- <include>${project.build.finalName}.jar</include>
- </resource>
- </resources>
- <imageTags>
- <imageTag>${project.version}</imageTag>
- <imageTag>latest</imageTag>
- </imageTags>
- <serverId>${onap.nexus.dockerregistry.daily}</serverId>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${maven.compiler.source}</source>
+ <target>${maven.compiler.target}</target>
+ <showWarnings>true</showWarnings>
+ <showDeprecation>true</showDeprecation>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.19</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-surefire-provider</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <detail>true</detail>
+ <printSummary>true</printSummary>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <configuration>
+ <outputDirectory>${dependency.directory.location}</outputDirectory>
+ <includeScope>runtime</includeScope>
+ <silent>true</silent>
+ </configuration>
+ <executions>
+ <execution>
+ <id>copy-external-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <imageName>${onap.nexus.dockerregistry.daily}/onap/${project.artifactId}</imageName>
+ <imageTags>${docker.image.tag}</imageTags>
+ <serverId>${onap.nexus.dockerregistry.daily}</serverId>
+ <baseImage>openjdk:8-jdk-alpine</baseImage>
+ <cmd>java -cp ${dependency.directory.name}/*:${project.build.finalName}.jar ${simulator.main.class}</cmd>
+ <resources>
+ <resource>
+ <targetPath>${dependency.directory.name}</targetPath>
+ <directory>${dependency.directory.location}</directory>
+ </resource>
+ <resource>
+ <targetPath>/</targetPath>
+ <directory>${project.build.directory}</directory>
+ <include>${project.build.finalName}.jar</include>
+ </resource>
+ </resources>
+ </configuration>
+ <executions>
+ <execution>
+ <id>build-image</id>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/test/mocks/pnfsimulator/simulator.sh b/test/mocks/pnfsimulator/simulator.sh
index 27384dd04..d1185565f 100755
--- a/test/mocks/pnfsimulator/simulator.sh
+++ b/test/mocks/pnfsimulator/simulator.sh
@@ -4,8 +4,8 @@ set -euo pipefail
CONTAINER_NAME=pnf-simulator
CONFIG_FILE_PATH=/config/body.json
-SIMULATOR_DOCKER_HUB=hub-name
-SIMULATOR_TAG=latest
+SIMULATOR_DOCKER_HUB=nexus3.onap.org:10003/onap
+SIMULATOR_TAG=1.0.0-SNAPSHOT-latest
function main(){
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java
index 8efdfe08d..37f1b21c9 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java
@@ -35,7 +35,7 @@ public class Main {
private static Logger logger = LogManager.getLogger(Main.class);
private static SimulatorFactory simulatorFactory =
- new SimulatorFactory(MessageProvider.getInstance(), ParamsValidator.getInstance());
+ new SimulatorFactory(MessageProvider.getInstance());
public static void main(String[] args) {
@@ -51,7 +51,7 @@ public class Main {
} catch (ParseException e) {
logger.error("Invalid cli params", e);
} catch (ValidationException e){
- logger.error("Missing some mandatory params:", e);
+ logger.error(e);
}
}
}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/cli/SimulatorParams.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/cli/SimulatorParams.java
index 4c662ab5f..2ca0b5e7b 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/cli/SimulatorParams.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/cli/SimulatorParams.java
@@ -1,4 +1,4 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* org.onap.integration
* ================================================================================
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/cli/SimulatorParamsProvider.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/cli/SimulatorParamsProvider.java
index 5c4d219a0..ab705e907 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/cli/SimulatorParamsProvider.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/cli/SimulatorParamsProvider.java
@@ -1,4 +1,4 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* org.onap.integration
* ================================================================================
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java
index 194e8960a..5805a88c7 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java
@@ -1,4 +1,4 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* org.onap.integration
* ================================================================================
@@ -17,11 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
+
package org.onap.pnfsimulator.message;
public final class MessageConstants {
+ public static final String EVENT = "event";
public static final String DOMAIN = "domain";
public static final String EVENT_ID = "eventId";
public static final String EVENT_TYPE = "eventType";
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java
index 95f9dfc55..94f5fc167 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java
@@ -1,4 +1,4 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* org.onap.integration
* ================================================================================
@@ -35,13 +35,12 @@ import static org.onap.pnfsimulator.message.MessageConstants.PRIORITY;
import static org.onap.pnfsimulator.message.MessageConstants.SEQUENCE;
import static org.onap.pnfsimulator.message.MessageConstants.START_EPOCH_MICROSEC;
import static org.onap.pnfsimulator.message.MessageConstants.VERSION;
+import static org.onap.pnfsimulator.message.MessageConstants.EVENT;
import java.util.Map;
import java.util.UUID;
import com.google.common.base.Preconditions;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
import org.json.JSONObject;
public class MessageProvider {
@@ -72,8 +71,11 @@ public class MessageProvider {
}
});
- root.put(COMMON_EVENT_HEADER, commonEventHeader);
- root.put(OTHER_FIELDS, otherFields);
+ JSONObject event = new JSONObject();
+ event.put(COMMON_EVENT_HEADER, commonEventHeader);
+ event.put(OTHER_FIELDS, otherFields);
+
+ root.put(EVENT, event);
return root;
}
@@ -91,6 +93,7 @@ public class MessageProvider {
commonEventHeader.put(START_EPOCH_MICROSEC, timestamp);
commonEventHeader.put(INTERNAL_HEADER_FIELDS, new JSONObject());
commonEventHeader.put(VERSION, 3);
+ commonEventHeader.put("functionalRole", "test_rola");
return commonEventHeader;
}
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/Simulator.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/Simulator.java
index d9559ecb2..ff2ca862a 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/Simulator.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/Simulator.java
@@ -1,4 +1,4 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* org.onap.integration
* ================================================================================
@@ -48,7 +48,7 @@ public class Simulator {
Instant endTime = Instant.now().plus(duration);
while (runningTimeNotExceeded(endTime)) {
try {
- logger.info("MESSAGE TO BE SENT:\n{}", messageBody.toString(4));
+ logger.info(()-> "MESSAGE TO BE SENT:\n" + messageBody.toString(4));
clientProvider.sendMsg(messageBody.toString());
Thread.sleep(interval.toMillis());
} catch (InterruptedException e) {
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java
index 9f3d48ab3..e3a003831 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java
@@ -1,4 +1,4 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* org.onap.integration
* ================================================================================
@@ -37,19 +37,17 @@ import org.onap.pnfsimulator.simulator.validation.ValidationException;
public class SimulatorFactory {
private MessageProvider messageProvider;
- private ParamsValidator paramsValidator;
- public SimulatorFactory(MessageProvider messageProvider, ParamsValidator paramsValidator) {
+ public SimulatorFactory(MessageProvider messageProvider) {
this.messageProvider = messageProvider;
- this.paramsValidator = paramsValidator;
}
public Simulator create(String vesServerUrl, String configFilePath) throws IOException, ValidationException {
String configJson = FileUtils.readFileToString(new File(configFilePath), StandardCharsets.UTF_8);
JSONObject configObject = new JSONObject(configJson);
+ ParamsValidator.forObject(configObject).validate();
- paramsValidator.validate(configObject);
Duration duration = Duration.ofSeconds(parseJsonField(configObject, TEST_DURATION));
Duration interval = Duration.ofSeconds(parseJsonField(configObject, MESSAGE_INTERVAL));
JSONObject messageBody = messageProvider.createMessage(configObject);
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientProvider.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientProvider.java
index 7ff506923..54d2c9fbb 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientProvider.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientProvider.java
@@ -1,4 +1,4 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* org.onap.integration
* ================================================================================
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ParamsValidator.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ParamsValidator.java
index 57408660a..6cdb781f1 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ParamsValidator.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ParamsValidator.java
@@ -1,23 +1,3 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.onap.integration
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
package org.onap.pnfsimulator.simulator.validation;
import static org.onap.pnfsimulator.message.MessageConstants.MESSAGE_INTERVAL;
@@ -28,71 +8,70 @@ import static org.onap.pnfsimulator.message.MessageConstants.PNF_VENDOR_NAME;
import static org.onap.pnfsimulator.message.MessageConstants.TEST_DURATION;
import com.google.common.collect.ImmutableMap;
-import java.util.ArrayList;
import java.util.List;
-import java.util.function.BiPredicate;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
public class ParamsValidator {
- private final static String MISSING_PARAMS_ERROR = "Some mandatory params are missing";
- private static ParamsValidator instance;
-
+ private final static String MISSING_PARAMS_MESSAGE = "Following mandatory params are missing:\n";
+ private final Map<String, Predicate<String>> validators = ImmutableMap
+ .<String, Predicate<String>>builder()
+ .put(TEST_DURATION, this::isNumeric)
+ .put(MESSAGE_INTERVAL, this::isNumeric)
+ .put(PNF_SERIAL_NUMBER, this::isDefined)
+ .put(PNF_VENDOR_NAME, this::isDefined)
+ .put(PNF_OAM_IPV4_ADDRESS, this::isDefined)
+ .put(PNF_OAM_IPV6_ADDRESS, this::isDefined)
+ .build();
+
+ private JSONObject subject;
+
+ private ParamsValidator(JSONObject paramsObject) {
+ subject = paramsObject;
+ }
- public static ParamsValidator getInstance() {
- if (instance == null) {
- instance = new ParamsValidator();
- }
- return instance;
+ public static ParamsValidator forObject(JSONObject configObject) {
+ return new ParamsValidator(configObject);
}
- public void validate(JSONObject params) throws ValidationException {
- ImmutableMap<String, BiPredicate<JSONObject, String>> paramValidators = ImmutableMap
- .<String, BiPredicate<JSONObject, String>>builder()
- .put(TEST_DURATION, this::isNotNumeric)
- .put(MESSAGE_INTERVAL, this::isNotNumeric)
- .put(PNF_SERIAL_NUMBER, this::nullOrEmpty)
- .put(PNF_VENDOR_NAME, this::nullOrEmpty)
- .put(PNF_OAM_IPV4_ADDRESS, this::nullOrEmpty)
- .put(PNF_OAM_IPV6_ADDRESS, this::nullOrEmpty)
- .build();
-
- List<String> missingParams = new ArrayList<>();
-
- paramValidators.forEach((param, validator) -> {
- if (validator.test(params, param)) {
- missingParams.add(param);
- }
- });
-
- clearIPError(missingParams);
+ public void validate() throws ValidationException {
+
+ List<String> missingParams = validators
+ .entrySet()
+ .stream()
+ .filter(entry -> !entry.getValue().test(entry.getKey()))
+ .map(Entry::getKey)
+ .collect(Collectors.toList());
+
+ resolveMissingIP(missingParams);
+
if (!missingParams.isEmpty()) {
throw new ValidationException(constructMessage(missingParams));
}
}
private String constructMessage(List<String> missingParams) {
- StringBuilder msg = new StringBuilder(MISSING_PARAMS_ERROR);
-
- missingParams.forEach(param -> {
- msg.append('\n');
- msg.append(param);
- });
- return msg.toString();
+ return MISSING_PARAMS_MESSAGE + missingParams
+ .stream()
+ .collect(Collectors.joining("\n"));
}
- private boolean isNotNumeric(JSONObject params, String param) {
- return nullOrEmpty(params, param) || !StringUtils.isNumeric(params.getString(param));
+ private boolean isNumeric(String param) {
+ return isDefined(param) && StringUtils.isNumeric(subject.getString(param));
}
- private boolean nullOrEmpty(JSONObject params, String param) {
- return !params.has(param) || params.getString(param).isEmpty();
+ private boolean isDefined(String param) {
+ return subject.has(param) && !subject.getString(param).isEmpty();
}
- private void clearIPError(List<String> missingParams) {
+ private void resolveMissingIP(List<String> missingParams) {
// if only one IP is missing clear the error
if (!(missingParams.contains(PNF_OAM_IPV4_ADDRESS) && missingParams.contains(PNF_OAM_IPV6_ADDRESS))) {
missingParams.remove(PNF_OAM_IPV4_ADDRESS);
diff --git a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ValidationException.java b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ValidationException.java
index 086997f85..9855a784e 100644
--- a/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ValidationException.java
+++ b/test/mocks/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/validation/ValidationException.java
@@ -1,23 +1,3 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.onap.integration
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
package org.onap.pnfsimulator.simulator.validation;
public class ValidationException extends Exception {
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/SimulatorParamsProviderTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/SimulatorParamsProviderTest.java
index bd6584233..96397eae1 100644
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/SimulatorParamsProviderTest.java
+++ b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/SimulatorParamsProviderTest.java
@@ -1,23 +1,3 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.onap.integration
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
package org.onap.pnfsimulator;
import org.apache.commons.cli.ParseException;
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/SimulatorTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/SimulatorTest.java
index e3db4c837..ccbb72846 100644
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/SimulatorTest.java
+++ b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/SimulatorTest.java
@@ -1,23 +1,3 @@
-/*-
- * ============LICENSE_START=======================================================
- * org.onap.integration
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
package org.onap.pnfsimulator;
import org.assertj.core.api.Assertions;
diff --git a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java
index d462d2592..bfd222dc2 100644
--- a/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java
+++ b/test/mocks/pnfsimulator/src/test/java/org/onap/pnfsimulator/message/MessageProviderTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.integration
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,20 +23,7 @@ package org.onap.pnfsimulator.message;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.onap.pnfsimulator.message.MessageConstants.COMMON_EVENT_HEADER;
-import static org.onap.pnfsimulator.message.MessageConstants.DOMAIN;
-import static org.onap.pnfsimulator.message.MessageConstants.EVENT_ID;
-import static org.onap.pnfsimulator.message.MessageConstants.EVENT_TYPE;
-import static org.onap.pnfsimulator.message.MessageConstants.INTERNAL_HEADER_FIELDS;
-import static org.onap.pnfsimulator.message.MessageConstants.LAST_EPOCH_MICROSEC;
-import static org.onap.pnfsimulator.message.MessageConstants.OTHER_FIELDS;
-import static org.onap.pnfsimulator.message.MessageConstants.OTHER_FIELDS_VERSION;
-import static org.onap.pnfsimulator.message.MessageConstants.PNF_LAST_SERVICE_DATE;
-import static org.onap.pnfsimulator.message.MessageConstants.PNF_MANUFACTURE_DATE;
-import static org.onap.pnfsimulator.message.MessageConstants.PRIORITY;
-import static org.onap.pnfsimulator.message.MessageConstants.SEQUENCE;
-import static org.onap.pnfsimulator.message.MessageConstants.START_EPOCH_MICROSEC;
-import static org.onap.pnfsimulator.message.MessageConstants.VERSION;
+import static org.onap.pnfsimulator.message.MessageConstants.*;
import java.util.UUID;
import org.json.JSONObject;
@@ -65,9 +52,10 @@ public class MessageProviderTest {
@Test
public void createMessage_should_create_constant_message_when_no_params_specified() {
JSONObject message = messageProvider.createMessage(new JSONObject());
+ JSONObject event = message.getJSONObject(EVENT);
- JSONObject commonEventHeader = message.getJSONObject(COMMON_EVENT_HEADER);
- JSONObject otherFields = message.getJSONObject(OTHER_FIELDS);
+ JSONObject commonEventHeader = event.getJSONObject(COMMON_EVENT_HEADER);
+ JSONObject otherFields = event.getJSONObject(OTHER_FIELDS);
JSONObject expectedCommonEventHeader = generateConstantCommonEventHeader();
JSONObject expectedOtherFields = generateConstantOtherFields();
@@ -89,8 +77,9 @@ public class MessageProviderTest {
JSONObject params = new JSONObject(testParamsJson);
JSONObject message = messageProvider.createMessage(params);
- JSONObject commonEventHeader = message.getJSONObject(COMMON_EVENT_HEADER);
- JSONObject otherFields = message.getJSONObject(OTHER_FIELDS);
+ JSONObject event = message.getJSONObject(EVENT);
+ JSONObject commonEventHeader = event.getJSONObject(COMMON_EVENT_HEADER);
+ JSONObject otherFields = event.getJSONObject(OTHER_FIELDS);
assertEquals("pnfVal3", otherFields.getString("pnfKey3"));
assertEquals("val1", commonEventHeader.getString("key1"));
diff --git a/test/vcpe/preload_templates/template.vcpe_brgemu_vfmodule.json b/test/vcpe/preload_templates/template.vcpe_brgemu_vfmodule.json
index 12303f49a..9a9ecc37d 100644
--- a/test/vcpe/preload_templates/template.vcpe_brgemu_vfmodule.json
+++ b/test/vcpe/preload_templates/template.vcpe_brgemu_vfmodule.json
@@ -1,145 +1,138 @@
{
- "VNF-API:input": {
- "VNF-API:request-information": {
- "VNF-API:request-id": "robot12",
- "VNF-API:notification-url": "https://so.onap.org",
- "VNF-API:order-number": "robot12",
- "VNF-API:request-sub-action": "SUPP",
- "VNF-API:request-action": "PreloadVNFRequest",
- "VNF-API:source": "VID",
- "VNF-API:order-version": "1.0"
- },
- "VNF-API:sdnc-request-header": {
- "VNF-API:svc-action": "reserve",
- "VNF-API:svc-notification-url": "https://son.onap.org",
- "VNF-API:svc-request-id": "robot12"
- },
- "VNF-API:vnf-topology-information": {
- "vnf-topology-identifier": {
- "service-type": "${service_type}",
- "vnf-type": "${vnf_type}",
- "generic-vnf-name": "${generic_vnf_name}",
- "generic-vnf-type": "${generic_vnf_type}",
- "vnf-name": "${vnf_name}"
- },
- "VNF-API:vnf-parameters": [
-
-
- {
- "vnf-parameter-name": "vcpe_image_name",
- "vnf-parameter-value": "vbrg-base-ubuntu-16-04-new"
- },
- {
- "vnf-parameter-name": "vcpe_flavor_name",
- "vnf-parameter-value": "m1.medium"
- },
-
- {
- "vnf-parameter-name": "public_net_id",
- "vnf-parameter-value": "${public_net_id}"
- },
- {
- "vnf-parameter-name": "vbrgemu_bng_private_net_id",
- "vnf-parameter-value": "${brg_bng_net}"
- },
- {
- "vnf-parameter-name": "vbrgemu_bng_private_subnet_id",
- "vnf-parameter-value": "${brg_bng_subnet}"
- },
- {
- "vnf-parameter-name": "onap_private_net_id",
- "vnf-parameter-value": "${oam_onap_net}"
- },
- {
- "vnf-parameter-name": "onap_private_subnet_id",
- "vnf-parameter-value": "${oam_onap_subnet}"
- },
- {
- "vnf-parameter-name": "onap_private_net_cidr",
- "vnf-parameter-value": "10.0.0.0/16"
- },
-
- {
- "vnf-parameter-name": "compile_state",
- "vnf-parameter-value": "done"
- },
- {
- "vnf-parameter-name": "vbrgemu_bng_private_net_cidr",
- "vnf-parameter-value": "10.3.0.0/24"
- },
- {
- "vnf-parameter-name": "vbrgemu_private_ip_0",
- "vnf-parameter-value": "10.3.0.14"
- },
- {
- "vnf-parameter-name": "sdnc_ip",
- "vnf-parameter-value": "10.0.7.1"
- },
- {
- "vnf-parameter-name": "vbrgemu_name_0",
- "vnf-parameter-value": "zdcpe1cpe01brgemu01_${suffix}"
- },
- {
- "vnf-parameter-name": "vnf_id",
- "vnf-parameter-value": "vCPE_Infrastructure_BGREMU_demo_app"
- },
- {
- "vnf-parameter-name": "vf_module_id",
- "vnf-parameter-value": "vCPE_Customer_BRGEMU"
- },
- {
- "vnf-parameter-name": "repo_url_blob",
- "vnf-parameter-value": "https://nexus.onap.org/content/sites/raw"
- },
- {
- "vnf-parameter-name": "repo_url_artifacts",
- "vnf-parameter-value": "https://nexus.onap.org/content/groups/staging"
- },
- {
- "vnf-parameter-name": "demo_artifacts_version",
- "vnf-parameter-value": "1.1.1"
- },
- {
- "vnf-parameter-name": "install_script_version",
- "vnf-parameter-value": "1.1.1"
- },
- {
- "vnf-parameter-name": "key_name",
- "vnf-parameter-value": "vbrgemu_key"
- },
- {
- "vnf-parameter-name": "pub_key",
- "vnf-parameter-value": "${pub_key}"
- },
- {
- "vnf-parameter-name": "cloud_env",
- "vnf-parameter-value": "openstack"
- },
- {
- "vnf-parameter-name": "vpp_source_repo_url",
- "vnf-parameter-value": "https://gerrit.fd.io/r/vpp"
- },
- {
- "vnf-parameter-name": "vpp_source_repo_branch",
- "vnf-parameter-value": "stable/1704"
- },
- {
- "vnf-parameter-name": "hc2vpp_source_repo_url",
- "vnf-parameter-value": "https://gerrit.fd.io/r/hc2vpp"
- },
- {
- "vnf-parameter-name": "hc2vpp_source_repo_branch",
- "vnf-parameter-value": "stable/1704"
- },
- {
- "vnf-parameter-name": "vpp_patch_url",
- "vnf-parameter-value": "https://git.onap.org/demo/plain/vnfs/vCPE/vpp-option-82-for-vbrg/src/patches/VPP-Add-Option82-Nat-Filter-For-vBRG.patch"
- }
-
- ],
- "VNF-API:vnf-assignments": {
- }
- }
- }
-}
-
+ "VNF-API:input": {
+ "VNF-API:request-information": {
+ "VNF-API:notification-url": "https://so.onap.org",
+ "VNF-API:order-number": "robot12",
+ "VNF-API:order-version": "1.0",
+ "VNF-API:request-action": "PreloadVNFRequest",
+ "VNF-API:request-id": "robot12",
+ "VNF-API:request-sub-action": "SUPP",
+ "VNF-API:source": "VID"
+ },
+ "VNF-API:sdnc-request-header": {
+ "VNF-API:svc-action": "reserve",
+ "VNF-API:svc-notification-url": "https://son.onap.org",
+ "VNF-API:svc-request-id": "robot12"
+ },
+ "VNF-API:vnf-topology-information": {
+ "VNF-API:vnf-assignments": {},
+ "VNF-API:vnf-parameters": [
+ {
+ "vnf-parameter-name": "vcpe_image_name",
+ "vnf-parameter-value": "vbrg-base-ubuntu-16-04-new"
+ },
+ {
+ "vnf-parameter-name": "vcpe_flavor_name",
+ "vnf-parameter-value": "m1.medium"
+ },
+ {
+ "vnf-parameter-name": "public_net_id",
+ "vnf-parameter-value": "${public_net_id}"
+ },
+ {
+ "vnf-parameter-name": "vbrgemu_bng_private_net_id",
+ "vnf-parameter-value": "${brg_bng_net}"
+ },
+ {
+ "vnf-parameter-name": "vbrgemu_bng_private_subnet_id",
+ "vnf-parameter-value": "${brg_bng_subnet}"
+ },
+ {
+ "vnf-parameter-name": "onap_private_net_id",
+ "vnf-parameter-value": "${oam_onap_net}"
+ },
+ {
+ "vnf-parameter-name": "onap_private_subnet_id",
+ "vnf-parameter-value": "${oam_onap_subnet}"
+ },
+ {
+ "vnf-parameter-name": "onap_private_net_cidr",
+ "vnf-parameter-value": "10.0.0.0/16"
+ },
+ {
+ "vnf-parameter-name": "compile_state",
+ "vnf-parameter-value": "done"
+ },
+ {
+ "vnf-parameter-name": "vbrgemu_bng_private_net_cidr",
+ "vnf-parameter-value": "10.3.0.0/24"
+ },
+ {
+ "vnf-parameter-name": "vbrgemu_private_ip_0",
+ "vnf-parameter-value": "10.3.0.21"
+ },
+ {
+ "vnf-parameter-name": "sdnc_ip",
+ "vnf-parameter-value": "10.0.7.1"
+ },
+ {
+ "vnf-parameter-name": "vbrgemu_name_0",
+ "vnf-parameter-value": "zdcpe1cpe01brgemu01_${suffix}"
+ },
+ {
+ "vnf-parameter-name": "vnf_id",
+ "vnf-parameter-value": "vCPE_Infrastructure_BGREMU_demo_app_${suffix}"
+ },
+ {
+ "vnf-parameter-name": "vf_module_id",
+ "vnf-parameter-value": "vCPE_Customer_BRGEMU_${suffix}"
+ },
+ {
+ "vnf-parameter-name": "repo_url_blob",
+ "vnf-parameter-value": "https://nexus.onap.org/content/sites/raw"
+ },
+ {
+ "vnf-parameter-name": "repo_url_artifacts",
+ "vnf-parameter-value": "https://nexus.onap.org/content/groups/staging"
+ },
+ {
+ "vnf-parameter-name": "demo_artifacts_version",
+ "vnf-parameter-value": "1.1.1"
+ },
+ {
+ "vnf-parameter-name": "install_script_version",
+ "vnf-parameter-value": "1.1.1"
+ },
+ {
+ "vnf-parameter-name": "key_name",
+ "vnf-parameter-value": "vbrgemu_key"
+ },
+ {
+ "vnf-parameter-name": "pub_key",
+ "vnf-parameter-value": "${pub_key}"
+ },
+ {
+ "vnf-parameter-name": "cloud_env",
+ "vnf-parameter-value": "openstack"
+ },
+ {
+ "vnf-parameter-name": "vpp_source_repo_url",
+ "vnf-parameter-value": "https://gerrit.fd.io/r/vpp"
+ },
+ {
+ "vnf-parameter-name": "vpp_source_repo_branch",
+ "vnf-parameter-value": "stable/1704"
+ },
+ {
+ "vnf-parameter-name": "hc2vpp_source_repo_url",
+ "vnf-parameter-value": "https://gerrit.fd.io/r/hc2vpp"
+ },
+ {
+ "vnf-parameter-name": "hc2vpp_source_repo_branch",
+ "vnf-parameter-value": "stable/1704"
+ },
+ {
+ "vnf-parameter-name": "vpp_patch_url",
+ "vnf-parameter-value": "https://git.onap.org/demo/plain/vnfs/vCPE/vpp-option-82-for-vbrg/src/patches/VPP-Add-Option82-Nat-Filter-For-vBRG.patch"
+ }
+ ],
+ "vnf-topology-identifier": {
+ "generic-vnf-name": "${generic_vnf_name}",
+ "generic-vnf-type": "${generic_vnf_type}",
+ "service-type": "${service_type}",
+ "vnf-name": "${vnf_name}",
+ "vnf-type": "${vnf_type}"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/test/vcpe/preload_templates/template.vcpe_vgw_vfmodule.json b/test/vcpe/preload_templates/template.vcpe_vgw_vfmodule.json
index 8b33482ab..d955a1d9c 100644
--- a/test/vcpe/preload_templates/template.vcpe_vgw_vfmodule.json
+++ b/test/vcpe/preload_templates/template.vcpe_vgw_vfmodule.json
@@ -1,121 +1,118 @@
{
- "VNF-API:input": {
- "VNF-API:request-information": {
- "VNF-API:request-id": "robot12",
- "VNF-API:notification-url": "https://so.onap.org",
- "VNF-API:order-number": "robot12",
- "VNF-API:request-sub-action": "SUPP",
- "VNF-API:request-action": "PreloadVNFRequest",
- "VNF-API:source": "VID",
- "VNF-API:order-version": "1.0"
- },
- "VNF-API:sdnc-request-header": {
- "VNF-API:svc-action": "reserve",
- "VNF-API:svc-notification-url": "https://son.onap.org",
- "VNF-API:svc-request-id": "robot12"
- },
- "VNF-API:vnf-topology-information": {
- "vnf-topology-identifier": {
- "service-type": "VGW-SERVICE-TYPE",
- "vnf-type": "VGW-VNF-TYPE",
- "generic-vnf-name": "GENERIC-VGW-VNF-NAME0",
- "generic-vnf-type": "GENERIC-VGW-VNF-TYPE",
- "vnf-name": "VGW2BRG-${brg_mac}"
- },
- "VNF-API:vnf-parameters": [
-
- {
- "vnf-parameter-name": "public_net_id",
- "vnf-parameter-value": "${public_net_id}"
- },
- {
- "vnf-parameter-name": "mux_gw_private_net_id",
- "vnf-parameter-value": "${mux_gw_net}"
- },
- {
- "vnf-parameter-name": "mux_gw_private_subnet_id",
- "vnf-parameter-value": "${mux_gw_subnet}"
- },
- {
- "vnf-parameter-name": "mux_gw_private_net_cidr",
- "vnf-parameter-value": "10.5.0.0/24"
- },
- {
- "vnf-parameter-name": "cpe_public_net_id",
- "vnf-parameter-value": "${cpe_public_net}"
- },
- {
- "vnf-parameter-name": "cpe_public_subnet_id",
- "vnf-parameter-value": "${cpe_public_subnet}"
- },
- {
- "vnf-parameter-name": "cpe_public_net_cidr",
- "vnf-parameter-value": "10.2.0.0/24"
- },
- {
- "vnf-parameter-name": "vgw_private_ip_0",
- "vnf-parameter-value": "10.5.0.22"
- },
- {
- "vnf-parameter-name": "vgw_private_ip_1",
- "vnf-parameter-value": "10.0.101.30"
- },
- {
- "vnf-parameter-name": "vgw_name_0",
- "vnf-parameter-value": "zdcpe1cpe01gw01_${suffix}"
- },
- {
- "vnf-parameter-name": "mux_ip_addr",
- "vnf-parameter-value": "10.5.0.21"
- },
- {
- "vnf-parameter-name": "vg_vgmux_tunnel_vni",
- "vnf-parameter-value": "100"
- },
- {
- "vnf-parameter-name": "onap_private_net_id",
- "vnf-parameter-value": "${oam_onap_net}"
- },
- {
- "vnf-parameter-name": "onap_private_subnet_id",
- "vnf-parameter-value": "${oam_onap_subnet}"
- },
- {
- "vnf-parameter-name": "onap_private_net_cidr",
- "vnf-parameter-value": "10.0.0.0/16"
- },
- {
- "vnf-parameter-name": "repo_url_blob",
- "vnf-parameter-value": "https://nexus.onap.org/content/sites/raw"
- },
- {
- "vnf-parameter-name": "repo_url_artifacts",
- "vnf-parameter-value": "https://nexus.onap.org/content/groups/staging"
- },
- {
- "vnf-parameter-name": "demo_artifacts_version",
- "vnf-parameter-value": "1.1.1"
- },
- {
- "vnf-parameter-name": "install_script_version",
- "vnf-parameter-value": "1.1.1"
- },
- {
- "vnf-parameter-name": "key_name",
- "vnf-parameter-value": "vgw_key"
- },
- {
- "vnf-parameter-name": "pub_key",
- "vnf-parameter-value": "${pub_key}"
- },
- {
- "vnf-parameter-name": "cloud_env",
- "vnf-parameter-value": "openstack"
- }
- ],
- "VNF-API:vnf-assignments": {
- }
- }
- }
-}
-
+ "VNF-API:input": {
+ "VNF-API:request-information": {
+ "VNF-API:notification-url": "https://so.onap.org",
+ "VNF-API:order-number": "robot12",
+ "VNF-API:order-version": "1.0",
+ "VNF-API:request-action": "PreloadVNFRequest",
+ "VNF-API:request-id": "robot12",
+ "VNF-API:request-sub-action": "SUPP",
+ "VNF-API:source": "VID"
+ },
+ "VNF-API:sdnc-request-header": {
+ "VNF-API:svc-action": "reserve",
+ "VNF-API:svc-notification-url": "https://son.onap.org",
+ "VNF-API:svc-request-id": "robot12"
+ },
+ "VNF-API:vnf-topology-information": {
+ "VNF-API:vnf-assignments": {},
+ "VNF-API:vnf-parameters": [
+ {
+ "vnf-parameter-name": "public_net_id",
+ "vnf-parameter-value": "${public_net_id}"
+ },
+ {
+ "vnf-parameter-name": "mux_gw_private_net_id",
+ "vnf-parameter-value": "${mux_gw_net}"
+ },
+ {
+ "vnf-parameter-name": "mux_gw_private_subnet_id",
+ "vnf-parameter-value": "${mux_gw_subnet}"
+ },
+ {
+ "vnf-parameter-name": "mux_gw_private_net_cidr",
+ "vnf-parameter-value": "10.5.0.0/24"
+ },
+ {
+ "vnf-parameter-name": "cpe_public_net_id",
+ "vnf-parameter-value": "${cpe_public_net}"
+ },
+ {
+ "vnf-parameter-name": "cpe_public_subnet_id",
+ "vnf-parameter-value": "${cpe_public_subnet}"
+ },
+ {
+ "vnf-parameter-name": "cpe_public_net_cidr",
+ "vnf-parameter-value": "10.2.0.0/24"
+ },
+ {
+ "vnf-parameter-name": "vgw_private_ip_0",
+ "vnf-parameter-value": "10.5.0.45"
+ },
+ {
+ "vnf-parameter-name": "vgw_private_ip_1",
+ "vnf-parameter-value": "10.0.101.45"
+ },
+ {
+ "vnf-parameter-name": "vgw_name_0",
+ "vnf-parameter-value": "zdcpe1cpe01gw01_${suffix}"
+ },
+ {
+ "vnf-parameter-name": "mux_ip_addr",
+ "vnf-parameter-value": "10.5.0.21"
+ },
+ {
+ "vnf-parameter-name": "vg_vgmux_tunnel_vni",
+ "vnf-parameter-value": "45"
+ },
+ {
+ "vnf-parameter-name": "onap_private_net_id",
+ "vnf-parameter-value": "${oam_onap_net}"
+ },
+ {
+ "vnf-parameter-name": "onap_private_subnet_id",
+ "vnf-parameter-value": "${oam_onap_subnet}"
+ },
+ {
+ "vnf-parameter-name": "onap_private_net_cidr",
+ "vnf-parameter-value": "10.0.0.0/16"
+ },
+ {
+ "vnf-parameter-name": "repo_url_blob",
+ "vnf-parameter-value": "https://nexus.onap.org/content/sites/raw"
+ },
+ {
+ "vnf-parameter-name": "repo_url_artifacts",
+ "vnf-parameter-value": "https://nexus.onap.org/content/groups/staging"
+ },
+ {
+ "vnf-parameter-name": "demo_artifacts_version",
+ "vnf-parameter-value": "1.1.1"
+ },
+ {
+ "vnf-parameter-name": "install_script_version",
+ "vnf-parameter-value": "1.1.1"
+ },
+ {
+ "vnf-parameter-name": "key_name",
+ "vnf-parameter-value": "vgw_key"
+ },
+ {
+ "vnf-parameter-name": "pub_key",
+ "vnf-parameter-value": "${pub_key}"
+ },
+ {
+ "vnf-parameter-name": "cloud_env",
+ "vnf-parameter-value": "openstack"
+ }
+ ],
+ "vnf-topology-identifier": {
+ "generic-vnf-name": "GENERIC-VGW-VNF-NAME0",
+ "generic-vnf-type": "GENERIC-VGW-VNF-TYPE",
+ "service-type": "VGW-SERVICE-TYPE",
+ "vnf-name": "VGW2BRG-${brg_mac}",
+ "vnf-type": "VGW-VNF-TYPE"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/test/vcpe/preload_templates/template_sniro_data.json b/test/vcpe/preload_templates/template_sniro_data.json
index 6fa200395..92c9cc719 100644
--- a/test/vcpe/preload_templates/template_sniro_data.json
+++ b/test/vcpe/preload_templates/template_sniro_data.json
@@ -7,6 +7,7 @@
"resourceModuleName" : "${tunnelxconn_ar_name}",
"serviceInstanceId" : "${vgmux_svc_instance_uuid}",
"serviceResourceId" : "TUNNEL-RESOURCE-ID-REPLACE",
+ "isRehome" : "False",
"assignmentInfo": [ { "variableName": "cloudOwner", "variableValue": "CloudOwner"}, {"variableName": "vnfHostName", "variableValue": "vnfHostName" }]
},
{
@@ -15,6 +16,7 @@
"resourceModuleName" : "${vgw_name}",
"serviceInstanceId" : "vG-service-instance-id",
"serviceResourceId" : "VGW-RESOURCE-ID-REPLACE",
+ "isRehome" : "False",
"assignmentInfo": [ { "variableName": "cloudOwner", "variableValue": "CloudOwner"}, {"variableName": "vnfHostName", "variableValue": "vnfHostName" }]
},
{
@@ -23,6 +25,7 @@
"resourceModuleName" : "${brg_ar_name}",
"serviceInstanceId" : "${vbrg_svc_instance_uuid}",
"serviceResourceId" : "BRG-RESOURCE-ID-REPLACE",
+ "isRehome" : "False",
"assignmentInfo": [ { "variableName": "cloudOwner", "variableValue": "CloudOwner"}, {"variableName": "vnfHostName", "variableValue": "vnfHostName" }]
}
]
diff --git a/test/vcpe/soutils.py b/test/vcpe/soutils.py
index cc82068a6..623f12cc3 100755
--- a/test/vcpe/soutils.py
+++ b/test/vcpe/soutils.py
@@ -18,6 +18,7 @@ class SoUtils:
:param vcpecommon:
:param api_version: must be 'v4' or 'v5'
"""
+ self.tmp_solution_for_so_bug = False
self.logger = logging.getLogger(__name__)
self.vcpecommon = vcpecommon
if api_version not in self.vcpecommon.so_req_api_url:
@@ -49,7 +50,9 @@ class SoUtils:
self.logger.error('Invalid request type: {0}. Can only be service/vnf/network/vfmodule'.format(req_type))
return None, None
+ self.logger.info(url)
r = requests.post(url, headers=self.vcpecommon.so_headers, auth=self.vcpecommon.so_userpass, json=req_json)
+ self.logger.debug(r)
response = r.json()
self.logger.debug('---------------------------------------------------------------')
@@ -58,6 +61,7 @@ class SoUtils:
self.logger.debug('---------------------------------------------------------------')
req_id = response.get('requestReferences', {}).get('requestId', '')
instance_id = response.get('requestReferences', {}).get('instanceId', '')
+
return req_id, instance_id
def check_progress(self, req_id, eta=0, interval=5):
@@ -119,7 +123,8 @@ class SoUtils:
'modelInfo': vnf_or_network_model,
'cloudConfiguration': {"lcpCloudRegionId": self.vcpecommon.os_region_name,
"tenantId": self.vcpecommon.os_tenant_id},
- 'requestParameters': {"userParams": []}
+ 'requestParameters': {"userParams": []},
+ 'platform': {"platformName": "Platform-Demonstration"}
}
self.add_req_info(req_details, instance_name, self.vcpecommon.product_family_id)
self.add_related_instance(req_details, service_instance_id, service_model)
@@ -149,14 +154,23 @@ class SoUtils:
}
}
self.add_req_info(req_details, instance_name)
+ self.add_project_info(req_details)
+ self.add_owning_entity(req_details)
return {'requestDetails': req_details}
+ def add_project_info(self, req_details):
+ req_details['project'] = {'projectName': self.vcpecommon.project_name}
+
+ def add_owning_entity(self, req_details):
+ req_details['owningEntity'] = {'owningEntityId': self.vcpecommon.owning_entity_id,
+ 'owningEntityName': self.vcpecommon.owning_entity_name}
+
def generate_custom_service_request(self, instance_name, model, brg_mac):
req_details = {
'modelInfo': model,
'subscriberInfo': {'subscriberName': 'Kaneohe',
'globalSubscriberId': self.vcpecommon.global_subscriber_id},
- 'cloudConfiguration': {"lcpCloudRegionId": self.vcpecommon.os_region_name,
+ 'cloudConfiguration': {"lcpCloudRegionId": 'CloudOwner_RegionOne', #self.vcpecommon.os_region_name,
"tenantId": self.vcpecommon.os_tenant_id},
'requestParameters': {
"userParams": [
@@ -164,12 +178,23 @@ class SoUtils:
'name': 'BRG_WAN_MAC_Address',
'value': brg_mac
}
+ ,
+ {
+ "name": "Customer_Location",
+ "value": self.vcpecommon.customer_location_used_by_oof
+ },
+ {
+ "name": "Homing_Solution",
+ "value": self.vcpecommon.homing_solution
+ }
],
"subscriptionServiceType": "vCPE",
'aLaCarte': 'false'
}
}
self.add_req_info(req_details, instance_name, self.vcpecommon.custom_product_family_id)
+ self.add_project_info(req_details)
+ self.add_owning_entity(req_details)
return {'requestDetails': req_details}
def create_custom_service(self, csar_file, brg_mac, name_suffix=None):
@@ -186,7 +211,7 @@ class SoUtils:
parser.svc_model['modelName'], name_suffix])
instance_name = instance_name.lower()
req = self.generate_custom_service_request(instance_name, parser.svc_model, brg_mac)
- self.logger.debug(json.dumps(req, indent=2, sort_keys=True))
+ self.logger.info(json.dumps(req, indent=2, sort_keys=True))
self.logger.info('Creating custom service {0}.'.format(instance_name))
req_id, svc_instance_id = self.submit_create_req(req, 'service')
if not self.check_progress(req_id, 140):
diff --git a/test/vcpe/vcpe.py b/test/vcpe/vcpe.py
index 7de86ae8d..c4737296b 100755
--- a/test/vcpe/vcpe.py
+++ b/test/vcpe/vcpe.py
@@ -8,6 +8,7 @@ import preload
import vcpe_custom_service
import csar_parser
import config_sdnc_so
+import json
def config_sniro(vcpecommon, vgmux_svc_instance_uuid, vbrg_svc_instance_uuid):
@@ -49,13 +50,15 @@ def create_one_service(vcpecommon, csar_file, vnf_template_file, preload_dict, s
so = soutils.SoUtils(vcpecommon, 'v4')
return so.create_entire_service(csar_file, vnf_template_file, preload_dict, suffix, heatbridge)
+
def deploy_brg_only():
logging.basicConfig(level=logging.INFO, format='%(message)s')
logger = logging.getLogger(__name__)
vcpecommon = VcpeCommon()
preload_dict = vcpecommon.load_preload_data()
- name_suffix = preload_dict['${brg_bng_net}'].split('_')[-1]
+# name_suffix = preload_dict['${brg_bng_net}'].split('_')[-1]
+ name_suffix = datetime.now().strftime('%Y%m%d%H%M')
# create multiple services based on the pre-determined order
svc_instance_uuid = vcpecommon.load_object(vcpecommon.svc_instance_uuid_file)
@@ -63,6 +66,7 @@ def deploy_brg_only():
heatbridge = 'gmux' == keyword
csar_file = vcpecommon.find_file(keyword, 'csar', 'csar')
vnf_template_file = vcpecommon.find_file(keyword, 'json', 'preload_templates')
+ vcpecommon.increase_ip_address_or_vni_in_template(vnf_template_file, ['vbrgemu_private_ip_0'])
svc_instance_uuid[keyword] = create_one_service(vcpecommon, csar_file, vnf_template_file, preload_dict,
name_suffix, heatbridge)
if not svc_instance_uuid[keyword]:
@@ -71,8 +75,8 @@ def deploy_brg_only():
# Setting up SNIRO
config_sniro(vcpecommon, svc_instance_uuid['gmux'], svc_instance_uuid['brg'])
+
def deploy_infra():
- logging.basicConfig(level=logging.INFO, format='%(message)s')
logger = logging.getLogger(__name__)
vcpecommon = VcpeCommon()
@@ -127,12 +131,12 @@ def deploy_custom_service():
custom_service = vcpe_custom_service.CustomService(vcpecommon)
# clean up
- host_dic = {k: vcpecommon.hosts[k] for k in nodes}
- if not vcpecommon.delete_vxlan_interfaces(host_dic):
- sys.exit()
+ #host_dic = {k: vcpecommon.hosts[k] for k in nodes}
+ #if not vcpecommon.delete_vxlan_interfaces(host_dic):
+ # sys.exit()
- custom_service.clean_up_sdnc()
- custom_service.del_all_vgw_stacks(vcpecommon.vgw_name_keyword)
+ #custom_service.clean_up_sdnc()
+ #custom_service.del_all_vgw_stacks(vcpecommon.vgw_name_keyword)
# create new service
csar_file = vcpecommon.find_file('rescust', 'csar', 'csar')
@@ -171,6 +175,15 @@ def init_so_sdnc():
config_sdnc_so.insert_customer_service_to_sdnc(vcpecommon)
+def tmp_sniro():
+ logger = logging.getLogger(__name__)
+
+ vcpecommon = VcpeCommon()
+
+ svc_instance_uuid = vcpecommon.load_object(vcpecommon.svc_instance_uuid_file)
+ # Setting up SNIRO
+ config_sniro(vcpecommon, svc_instance_uuid['gmux'], svc_instance_uuid['brg'])
+
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO, format='%(message)s')
diff --git a/test/vcpe/vcpe_custom_service.py b/test/vcpe/vcpe_custom_service.py
index d89129eef..af76803aa 100755
--- a/test/vcpe/vcpe_custom_service.py
+++ b/test/vcpe/vcpe_custom_service.py
@@ -72,6 +72,8 @@ class CustomService:
# preload vGW
if preload_dict:
preloader = preload.Preload(self.vcpecommon)
+ parameters_to_change = ['vgw_private_ip_0', 'vgw_private_ip_1', 'vg_vgmux_tunnel_vni']
+ self.vcpecommon.increase_ip_address_or_vni_in_template(vgw_template_file, parameters_to_change)
preloader.preload_vgw(vgw_template_file, brg_mac, preload_dict, name_suffix)
# create service
diff --git a/test/vcpe/vcpecommon.py b/test/vcpe/vcpecommon.py
index 5b3e009a3..0213183e8 100755
--- a/test/vcpe/vcpecommon.py
+++ b/test/vcpe/vcpecommon.py
@@ -21,19 +21,19 @@ class VcpeCommon:
# set the openstack cloud access credentials here
cloud = {
'--os-auth-url': 'http://10.12.25.2:5000',
- '--os-username': 'YOUR ID',
+ '--os-username': 'kxi',
'--os-user-domain-id': 'default',
'--os-project-domain-id': 'default',
- '--os-tenant-id': '087050388b204c73a3e418dd2c1fe30b',
+ '--os-tenant-id': '1e097c6713e74fd7ac8e4295e605ee1e',
'--os-region-name': 'RegionOne',
- '--os-password': 'YOUR PASSWD',
- '--os-project-domain-name': 'Integration-SB-01',
+ '--os-password': 'n3JhGMGuDzD8',
+ '--os-project-domain-name': 'Integration-SB-07',
'--os-identity-api-version': '3'
}
common_preload_config = {
- 'oam_onap_net': 'oam_onap_c4Uw',
- 'oam_onap_subnet': 'oam_onap_c4Uw',
+ 'oam_onap_net': 'oam_onap_lAky',
+ 'oam_onap_subnet': 'oam_onap_lAky',
'public_net': 'external',
'public_net_id': '971040b2-7059-49dc-b220-4fab50cb2ad4'
}
@@ -41,6 +41,7 @@ class VcpeCommon:
#############################################################################################
template_variable_symbol = '${'
+ cpe_vm_prefix = 'zdcpe'
#############################################################################################
# preloading network config
# key=network role
@@ -53,13 +54,17 @@ class VcpeCommon:
'mux_gw': ['10.5.0.10', '10.5.0.1']
}
+ dcae_ves_collector_name = 'dcae-bootstrap'
global_subscriber_id = 'SDN-ETHERNET-INTERNET'
+ project_name = 'Project-Demonstration'
+ owning_entity_id = '520cc603-a3c4-4ec2-9ef4-ca70facd79c0'
+ owning_entity_name = 'OE-Demonstration'
def __init__(self, extra_host_names=None):
self.logger = logging.getLogger(__name__)
self.logger.info('Initializing configuration')
- self.host_names = ['so', 'sdnc', 'robot', 'aai-inst1', 'dcaedoks00']
+ self.host_names = ['so', 'sdnc', 'robot', 'aai-inst1', self.dcae_ves_collector_name]
if extra_host_names:
self.host_names.extend(extra_host_names)
# get IP addresses
@@ -84,6 +89,13 @@ class VcpeCommon:
self.common_preload_config['pub_key'] = self.pub_key
self.sniro_url = 'http://' + self.hosts['robot'] + ':8080/__admin/mappings'
self.sniro_headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
+ self.homing_solution = 'sniro' # value is either 'sniro' or 'oof'
+# self.homing_solution = 'oof'
+ self.customer_location_used_by_oof = {
+ "customerLatitude": "32.897480",
+ "customerLongitude": "-97.040443",
+ "customerName": "some_company"
+ }
#############################################################################################
# SDNC urls
@@ -91,7 +103,7 @@ class VcpeCommon:
self.sdnc_db_name = 'sdnctl'
self.sdnc_db_user = 'sdnctl'
self.sdnc_db_pass = 'gamma'
- self.sdnc_db_port = '32768'
+ self.sdnc_db_port = '32774'
self.sdnc_headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
self.sdnc_preload_network_url = 'http://' + self.hosts['sdnc'] + \
':8282/restconf/operations/VNF-API:preload-network-topology-operation'
@@ -103,13 +115,13 @@ class VcpeCommon:
# SO urls, note: do NOT add a '/' at the end of the url
self.so_req_api_url = {'v4': 'http://' + self.hosts['so'] + ':8080/ecomp/mso/infra/serviceInstances/v4',
'v5': 'http://' + self.hosts['so'] + ':8080/ecomp/mso/infra/serviceInstances/v5'}
- self.so_check_progress_api_url = 'http://' + self.hosts['so'] + ':8080/ecomp/mso/infra/orchestrationRequests/v2'
+ self.so_check_progress_api_url = 'http://' + self.hosts['so'] + ':8080/ecomp/mso/infra/orchestrationRequests/v5'
self.so_userpass = 'InfraPortalClient', 'password1$'
self.so_headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
self.so_db_name = 'mso_catalog'
self.so_db_user = 'root'
self.so_db_pass = 'password'
- self.so_db_port = '32768'
+ self.so_db_port = '32769'
self.vpp_inf_url = 'http://{0}:8183/restconf/config/ietf-interfaces:interfaces'
self.vpp_api_headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
@@ -127,7 +139,8 @@ class VcpeCommon:
def get_brg_mac_from_sdnc(self):
"""
- :return: BRG MAC address. Currently we only support one BRG instance.
+ Check table DHCP_MAP in the SDNC DB. Find the newly instantiated BRG MAC address.
+ Note that there might be multiple BRGs, the most recently instantiated BRG always has the largest IP address.
"""
cnx = mysql.connector.connect(user=self.sdnc_db_user, password=self.sdnc_db_pass, database=self.sdnc_db_name,
host=self.hosts['sdnc'], port=self.sdnc_db_port)
@@ -136,36 +149,30 @@ class VcpeCommon:
cursor.execute(query)
self.logger.debug('DHCP_MAP table in SDNC')
- counter = 0
- mac = None
+ mac_recent = None
+ host = -1
for mac, ip in cursor:
- counter += 1
self.logger.debug(mac + ':' + ip)
+ this_host = int(ip.split('.')[-1])
+ if host < this_host:
+ host = this_host
+ mac_recent = mac
cnx.close()
- if counter != 1:
- self.logger.error('Found %s MAC addresses in DHCP_MAP', counter)
- sys.exit()
- else:
- self.logger.debug('Found MAC addresses in DHCP_MAP: %s', mac)
- return mac
+ assert mac_recent
+ return mac_recent
- def insert_into_sdnc_db(self, cmds):
- cnx = mysql.connector.connect(user=self.sdnc_db_user, password=self.sdnc_db_pass, database=self.sdnc_db_name,
- host=self.hosts['sdnc'], port=self.sdnc_db_port)
- cursor = cnx.cursor()
- for cmd in cmds:
- self.logger.debug(cmd)
- cursor.execute(cmd)
- self.logger.debug('%s', cursor)
- cnx.commit()
- cursor.close()
- cnx.close()
+ def execute_cmds_sdnc_db(self, cmds):
+ self.execute_cmds_db(cmds, self.sdnc_db_user, self.sdnc_db_pass, self.sdnc_db_name,
+ self.hosts['sdnc'], self.sdnc_db_port)
+
+ def execute_cmds_so_db(self, cmds):
+ self.execute_cmds_db(cmds, self.so_db_user, self.so_db_pass, self.so_db_name,
+ self.hosts['so'], self.so_db_port)
- def insert_into_so_db(self, cmds):
- cnx = mysql.connector.connect(user=self.so_db_user, password=self.so_db_pass, database=self.so_db_name,
- host=self.hosts['so'], port=self.so_db_port)
+ def execute_cmds_db(self, cmds, dbuser, dbpass, dbname, host, port):
+ cnx = mysql.connector.connect(user=dbuser, password=dbpass, database=dbname, host=host, port=port)
cursor = cnx.cursor()
for cmd in cmds:
self.logger.debug(cmd)
@@ -257,7 +264,7 @@ class VcpeCommon:
url = 'https://{0}:8443/aai/v11/search/nodes-query?search-node-type={1}&filter={2}:EQUALS:{3}'.format(
self.hosts['aai-inst1'], search_node_type, key, node_uuid)
- headers = {'Content-Type': 'application/json', 'Accept': 'application/json', 'X-FromAppID': 'vCPE-Robot'}
+ headers = {'Content-Type': 'application/json', 'Accept': 'application/json', 'X-FromAppID': 'vCPE-Robot', 'X-TransactionId': 'get_aai_subscr'}
requests.packages.urllib3.disable_warnings()
r = requests.get(url, headers=headers, auth=self.aai_userpass, verify=False)
response = r.json()
@@ -298,24 +305,61 @@ class VcpeCommon:
openstackcmd = 'nova ' + param + ' list'
self.logger.debug(openstackcmd)
- ip_dict = {}
results = os.popen(openstackcmd).read()
- for line in results.split('\n'):
- fields = line.split('|')
- if len(fields) == 8:
- vm_name = fields[2]
- ip_info = fields[-2]
- for keyword in keywords:
- if keyword in vm_name:
- ip = self.extract_ip_from_str(net_addr, net_addr_len, ip_info)
- if ip:
- ip_dict[keyword] = ip
+ all_vm_ip_dict = self.extract_vm_ip_as_dict(results, net_addr, net_addr_len)
+ latest_vm_list = self.remove_old_vms(all_vm_ip_dict.keys(), self.cpe_vm_prefix)
+ latest_vm_ip_dict = {vm: all_vm_ip_dict[vm] for vm in latest_vm_list}
+ ip_dict = self.select_subset_vm_ip(latest_vm_ip_dict, keywords)
+
if len(ip_dict) != len(keywords):
self.logger.error('Cannot find all desired IP addresses for %s.', keywords)
self.logger.error(json.dumps(ip_dict, indent=4, sort_keys=True))
- sys.exit()
+ self.logger.error('Temporarily continue.. remember to check back vcpecommon.py line: 316')
+# sys.exit()
return ip_dict
+ def extract_vm_ip_as_dict(self, novalist_results, net_addr, net_addr_len):
+ vm_ip_dict = {}
+ for line in novalist_results.split('\n'):
+ fields = line.split('|')
+ if len(fields) == 8:
+ vm_name = fields[2]
+ ip_info = fields[-2]
+ ip = self.extract_ip_from_str(net_addr, net_addr_len, ip_info)
+ vm_ip_dict[vm_name] = ip
+
+ return vm_ip_dict
+
+ def remove_old_vms(self, vm_list, prefix):
+ """
+ For vms with format name_timestamp, only keep the one with the latest timestamp.
+ E.g.,
+ zdcpe1cpe01brgemu01_201805222148 (drop this)
+ zdcpe1cpe01brgemu01_201805222229 (keep this)
+ zdcpe1cpe01gw01_201805162201
+ """
+ new_vm_list = []
+ same_type_vm_dict = {}
+ for vm in vm_list:
+ fields = vm.split('_')
+ if vm.startswith(prefix) and len(fields) == 2 and len(fields[-1]) == len('201805222148') and fields[-1].isdigit():
+ if vm > same_type_vm_dict.get(fields[0], '0'):
+ same_type_vm_dict[fields[0]] = vm
+ else:
+ new_vm_list.append(vm)
+
+ new_vm_list.extend(same_type_vm_dict.values())
+ return new_vm_list
+
+ def select_subset_vm_ip(self, all_vm_ip_dict, vm_name_keyword_list):
+ vm_ip_dict = {}
+ for keyword in vm_name_keyword_list:
+ for vm, ip in all_vm_ip_dict.items():
+ if keyword in vm:
+ vm_ip_dict[keyword] = ip
+ break
+ return vm_ip_dict
+
def del_vgmux_ves_mode(self):
url = self.vpp_ves_url.format(self.hosts['mux']) + '/mode'
r = requests.delete(url, headers=self.vpp_api_headers, auth=self.vpp_api_userpass)
@@ -329,8 +373,8 @@ class VcpeCommon:
def set_vgmux_ves_collector(self ):
url = self.vpp_ves_url.format(self.hosts['mux'])
data = {'config':
- {'server-addr': self.hosts['dcaedoks00'],
- 'server-port': '8080',
+ {'server-addr': self.hosts[self.dcae_ves_collector_name],
+ 'server-port': '8081',
'read-interval': '10',
'is-add':'1'
}
@@ -400,6 +444,26 @@ class VcpeCommon:
with open(filepathname, 'rb') as fin:
return pickle.load(fin)
+ @staticmethod
+ def increase_ip_address_or_vni_in_template(vnf_template_file, vnf_parameter_name_list):
+ with open(vnf_template_file) as json_input:
+ json_data = json.load(json_input)
+ param_list = json_data['VNF-API:input']['VNF-API:vnf-topology-information']['VNF-API:vnf-parameters']
+ for param in param_list:
+ if param['vnf-parameter-name'] in vnf_parameter_name_list:
+ ipaddr_or_vni = param['vnf-parameter-value'].split('.')
+ number = int(ipaddr_or_vni[-1])
+ if 254 == number:
+ number = 10
+ else:
+ number = number + 1
+ ipaddr_or_vni[-1] = str(number)
+ param['vnf-parameter-value'] = '.'.join(ipaddr_or_vni)
+
+ assert json_data is not None
+ with open(vnf_template_file, 'w') as json_output:
+ json.dump(json_data, json_output, indent=4, sort_keys=True)
+
def save_preload_data(self, preload_data):
self.save_object(preload_data, self.preload_dict_file)