From 131273f73ec21a5632de9069f8b04f75631ce790 Mon Sep 17 00:00:00 2001 From: Jerry Flood Date: Thu, 25 Apr 2019 16:46:35 -0400 Subject: Remove dead code. Add robot tests Move interface mocking test code from cmso to robot. Issue-ID: OPTFRA-474 Change-Id: Ib98f0b16d783e01f888279266dfdee858e30b787 Signed-off-by: Jerry Flood --- cmso-robot/docker/Dockerfile | 2 + cmso-robot/docker/assembly/cmso-files.xml | 7 + cmso-robot/ete.sh | 15 ++- cmso-robot/mocking/mock.py | 100 ++++++++++++++ .../robot/testsuites/ChangeManagementCancel.robot | 2 +- .../testsuites/ChangeManagementDBFailover.robot | 2 +- .../robot/testsuites/ChangeManagementFailure.robot | 2 +- .../robot/testsuites/ChangeManagementFuture.robot | 2 +- .../testsuites/ChangeManagementImmediate.robot | 2 +- .../ChangeManagementImmediateFailure.robot | 2 +- .../testsuites/ChangeManagementRejection.robot | 2 +- cmso-robot/robot/testsuites/CheckLog.robot | 2 +- .../robot/testsuites/CheckScheduleStatus.robot | 2 +- cmso-robot/robot/testsuites/MiscTests.robot | 149 ++++++++++++--------- cmso-robot/setup.sh | 0 15 files changed, 219 insertions(+), 72 deletions(-) create mode 100755 cmso-robot/mocking/mock.py mode change 100644 => 100755 cmso-robot/robot/testsuites/MiscTests.robot mode change 100644 => 100755 cmso-robot/setup.sh (limited to 'cmso-robot') diff --git a/cmso-robot/docker/Dockerfile b/cmso-robot/docker/Dockerfile index aa41520..91630a9 100644 --- a/cmso-robot/docker/Dockerfile +++ b/cmso-robot/docker/Dockerfile @@ -27,6 +27,7 @@ RUN apt-get update \ COPY /onap-cmso/robot /opt/cmso-robot/robot +COPY /onap-cmso/mocking /opt/cmso-robot/mocking COPY /onap-cmso/ete.sh /opt/cmso-robot RUN chmod 777 /opt/cmso-robot/ete.sh @@ -40,6 +41,7 @@ RUN pip --version RUN pip install robotframework==3.1.1 RUN pip install Flask +RUN pip install requests RUN pip install selenium RUN pip install robotframework-sshlibrary RUN pip install robotframework-requests diff --git a/cmso-robot/docker/assembly/cmso-files.xml b/cmso-robot/docker/assembly/cmso-files.xml index cb61e5a..4865639 100644 --- a/cmso-robot/docker/assembly/cmso-files.xml +++ b/cmso-robot/docker/assembly/cmso-files.xml @@ -33,6 +33,13 @@ ${project.basedir}/robot /robot + + + ** + + ${project.basedir}/mocking + /mocking + ete.sh diff --git a/cmso-robot/ete.sh b/cmso-robot/ete.sh index 107c661..dbd058f 100755 --- a/cmso-robot/ete.sh +++ b/cmso-robot/ete.sh @@ -1,17 +1,30 @@ #!/bin/bash # + ROBOT_CMD="python -m robot.run" ROBOT_HOME=`pwd` -ROBOT_PATH=${ROBOT_PATH}:${ROBOT_HOME}/robot/library +ROBOT_PATH=${ROBOT_PATH}:${ROBOT_HOME}/library ROBOT_PATH=${ROBOT_PATH}:${ROBOT_HOME}/robot/locallibrary/cmsoUtils VARIABLE_FILES="${VARIABLE_FILES} -V ${ROBOT_HOME}/robot/assets/test_properties.py" VARIABLES="${VARIABLES} -v GLOBAL_SCHEDULER_URL:${GLOBAL_SCHEDULER_URL}" VARIABLES="${VARIABLES} -v GLOBAL_OPTIMIZER_URL:${GLOBAL_OPTIMIZER_URL}" +VARIABLES="${VARIABLES} -v GLOBAL_TICKET_MGT_URL:${GLOBAL_TICKET_MGT_URL}" +VARIABLES="${VARIABLES} -v GLOBAL_TOPOLOGY_URL:${GLOBAL_TOPOLOGY_URL}" VARIABLES="${VARIABLES} -v CMSO_STARTUP_WAIT_TIME:${CMSO_STARTUP_WAIT_TIME}" HTTP_PROXY= HTTPS_PROXY= +export PYTHONPATH=${ROBOT_PATH}:${PYTHONPATH} +echo PYTHONPATH=${PYTHONPATH} +pgrep -f mock.py +if [ $? == 1 ] +then + nohup python ${ROBOT_HOME}/mocking/mock.py & +fi + + ${ROBOT_CMD} ${OUTPUT} -P ${ROBOT_PATH} ${VARIABLE_FILES} ${VARIABLES} ${TAGS} ${ROBOT_HOME} +pkill -f mock.py \ No newline at end of file diff --git a/cmso-robot/mocking/mock.py b/cmso-robot/mocking/mock.py new file mode 100755 index 0000000..2cb8c3c --- /dev/null +++ b/cmso-robot/mocking/mock.py @@ -0,0 +1,100 @@ +from flask import Flask +from flask import request +from flask import Response +from flask import json +from flask import send_from_directory +import requests +from threading import Thread +import time + +import os +import fnmatch +import re +import time +import datetime + +app = Flask(__name__) +ROOT_MOCK_DIR = os.path.dirname(os.path.abspath(__file__)) +DATA_DIR = os.path.join(ROOT_MOCK_DIR, "data") +global requestNum +requestNum = 1 + +######################################################################## +######################################################################## +@app.route('/onap/so/infra/orchestrationRequests/v7/schedule/', methods=['GET', 'POST']) +def soSchedule(VNFNAME): + if request.method == 'POST': + testid = request.headers.environ["HTTP_X_TRANSACTIONID"] + response = { + "status" : "202", + "entity" : { + "requestReferences" : { + "requestId" : "000001" + } + } + } + resp = Response(json.dumps(response), 200, mimetype='application/json') + return resp + + + else : + return "Helloooooo!!!!" + +######################################################################## +######################################################################## +@app.route('/onap/so/infra/orchestrationRequests/v7/', methods=['GET']) +def soStatus(REQUESTID): + response = {"request" : { "requestStatus" : { + "requestState" : "COMPLETE", + "statusMessage" : "Done.", + "percentProgress" : 100, + "finishTime" : "" + }}} + now = datetime.datetime.utcnow() + #response["finishTime"] = now.strftime("%Y-%m-%dT%H:%M:%SZ") + response["request"]["requestStatus"]["finishTime"] = now.strftime("%a, %d %b %Y %H:%M:%S GMT") + resp = Response(json.dumps(response), 200, mimetype='application/json') + + return resp + + +######################################################################## +######################################################################## +@app.route('/optimizer/v1/optimize/schedule', methods=['POST']) +def optimizePost(): + response = {} + resp = Response(json.dumps(response), 200, mimetype='application/json') + return resp + + +######################################################################## +######################################################################## +@app.route('/optimizer/v1/optimize/schedule/', methods=['GET']) +def optimizeGet(ID): + response = {} + resp = Response(json.dumps(response), 200, mimetype='application/json') + + return resp + +######################################################################## +######################################################################## +@app.route('/optimizer/v1/optimize/schedule/', methods=['DELETE']) +def optimizeDelete(ID): + response = {} + resp = Response(json.dumps(response), 200, mimetype='application/json') + return resp + +######################################################################## +######################################################################## +@app.route('/optimizer/v1/policies', methods=['GET']) +def getPolicies(): + reponse = [] + resp = Response(json.dumps(response), 200, mimetype='application/json') + + return resp + +######################################################################## +######################################################################## +if __name__ == "__main__": + app.run(host= '0.0.0.0',port=5000) + #app.run() \ No newline at end of file diff --git a/cmso-robot/robot/testsuites/ChangeManagementCancel.robot b/cmso-robot/robot/testsuites/ChangeManagementCancel.robot index ad193f6..30ad8c0 100644 --- a/cmso-robot/robot/testsuites/ChangeManagementCancel.robot +++ b/cmso-robot/robot/testsuites/ChangeManagementCancel.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Creates VID VNF Instance +Documentation Verify CMSO schedule cancel. Library StringTemplater Library UUID diff --git a/cmso-robot/robot/testsuites/ChangeManagementDBFailover.robot b/cmso-robot/robot/testsuites/ChangeManagementDBFailover.robot index a951145..81268e1 100644 --- a/cmso-robot/robot/testsuites/ChangeManagementDBFailover.robot +++ b/cmso-robot/robot/testsuites/ChangeManagementDBFailover.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Creates VID VNF Instance +Documentation Test specialized DB failover scenarios (not part of ete) Library StringTemplater Library UUID diff --git a/cmso-robot/robot/testsuites/ChangeManagementFailure.robot b/cmso-robot/robot/testsuites/ChangeManagementFailure.robot index 5e74105..14d96fa 100644 --- a/cmso-robot/robot/testsuites/ChangeManagementFailure.robot +++ b/cmso-robot/robot/testsuites/ChangeManagementFailure.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Creates VID VNF Instance +Documentation Change Management Validation Testing Library StringTemplater Library UUID diff --git a/cmso-robot/robot/testsuites/ChangeManagementFuture.robot b/cmso-robot/robot/testsuites/ChangeManagementFuture.robot index 5dad749..8218233 100644 --- a/cmso-robot/robot/testsuites/ChangeManagementFuture.robot +++ b/cmso-robot/robot/testsuites/ChangeManagementFuture.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Creates VID VNF Instance +Documentation Verifies ETE Scheduling for future requests Library StringTemplater Library UUID diff --git a/cmso-robot/robot/testsuites/ChangeManagementImmediate.robot b/cmso-robot/robot/testsuites/ChangeManagementImmediate.robot index f7e399a..761deb7 100644 --- a/cmso-robot/robot/testsuites/ChangeManagementImmediate.robot +++ b/cmso-robot/robot/testsuites/ChangeManagementImmediate.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Creates VID VNF Instance +Documentation Verifies ETE Scheduling for immediate requests Library StringTemplater Library UUID diff --git a/cmso-robot/robot/testsuites/ChangeManagementImmediateFailure.robot b/cmso-robot/robot/testsuites/ChangeManagementImmediateFailure.robot index 74f1959..a2de1a9 100644 --- a/cmso-robot/robot/testsuites/ChangeManagementImmediateFailure.robot +++ b/cmso-robot/robot/testsuites/ChangeManagementImmediateFailure.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Creates VID VNF Instance +Documentation Verifies immediate request failures Library StringTemplater Library UUID diff --git a/cmso-robot/robot/testsuites/ChangeManagementRejection.robot b/cmso-robot/robot/testsuites/ChangeManagementRejection.robot index ea63ac8..e00fe99 100644 --- a/cmso-robot/robot/testsuites/ChangeManagementRejection.robot +++ b/cmso-robot/robot/testsuites/ChangeManagementRejection.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Creates VID VNF Instance +Documentation Verifies rejection of optimized schedules Library StringTemplater Library UUID diff --git a/cmso-robot/robot/testsuites/CheckLog.robot b/cmso-robot/robot/testsuites/CheckLog.robot index 13d7b1c..d1d1304 100644 --- a/cmso-robot/robot/testsuites/CheckLog.robot +++ b/cmso-robot/robot/testsuites/CheckLog.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Creates VID VNF Instance +Documentation Verifies log output (Not part of ETE) Library StringTemplater Library UUID diff --git a/cmso-robot/robot/testsuites/CheckScheduleStatus.robot b/cmso-robot/robot/testsuites/CheckScheduleStatus.robot index 2f96ecb..6ee3c65 100644 --- a/cmso-robot/robot/testsuites/CheckScheduleStatus.robot +++ b/cmso-robot/robot/testsuites/CheckScheduleStatus.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Creates VID VNF Instance +Documentation Verifies scheduler queries Library StringTemplater Library UUID diff --git a/cmso-robot/robot/testsuites/MiscTests.robot b/cmso-robot/robot/testsuites/MiscTests.robot old mode 100644 new mode 100755 index a3b9428..12da302 --- a/cmso-robot/robot/testsuites/MiscTests.robot +++ b/cmso-robot/robot/testsuites/MiscTests.robot @@ -1,62 +1,87 @@ -*** Settings *** -Documentation Creates VID VNF Instance - -Library StringTemplater -Library UUID -Library Collections - -Resource ../resources/optimizer_common.robot -Resource ../resources/scheduler_common.robot -Resource ../resources/ticketmgt_common.robot -Resource ../resources/topology_common.robot - -# Test Setup -# Test Teardown -*** Variable*** -${user_name}= -${password}= -${uuid_list_file}= robot/assets/get_schedule_UUIDs.txt -${template_folder}= robot/assets/templates/changemanagement -*** Test Cases *** -Test CMSO Optimizer Admin - [Tags] ete - ${response}= Get Optimizer Plain Text alias admin/password - Should Contain ${response.text} kECFDaLusYNHTN6Q4DmsYw== - -Test CMSO Service Admin - [Tags] ete - ${response}= Get Scheduler Plain Text alias /cmso/v1/admin/password - Should Contain ${response.text} kECFDaLusYNHTN6Q4DmsYw== - -Test CMSO Ticket Mgt Admin - [Tags] ete - ${response}= Get Ticket Mgt Plain Text alias admin/password - Should Contain ${response.text} kECFDaLusYNHTN6Q4DmsYw== - -Test CMSO Topology Admin - [Tags] ete - ${response}= Get Topology Plain Text alias admin/password - Should Contain ${response.text} kECFDaLusYNHTN6Q4DmsYw== - -Test CMSO Optimizer Health - [Tags] ete - ${response}= Get Optimizer alias health - Dictionary Should Contain Item ${response.json()} healthy True - -Test CMSO Service Health - [Tags] ete - ${response}= Get Scheduler alias /cmso/v1/health - Dictionary Should Contain Item ${response.json()} healthy True - - -Test CMSO Ticket Mgt Health - [Tags] ete - ${response}= Get Ticket Mgt alias health - Dictionary Should Contain Item ${response.json()} healthy True - - -Test CMSO Topology Health - [Tags] ete - ${response}= Get Topology alias health - Dictionary Should Contain Item ${response.json()} healthy True - +*** Settings *** +Documentation Creates VID VNF Instance + +Library StringTemplater +Library UUID +Library Collections + +Resource ../resources/optimizer_common.robot +Resource ../resources/scheduler_common.robot +Resource ../resources/ticketmgt_common.robot +Resource ../resources/topology_common.robot + +# Test Setup +# Test Teardown +*** Variable*** +${user_name}= +${password}= +${uuid_list_file}= robot/assets/get_schedule_UUIDs.txt +${template_folder}= robot/assets/templates/changemanagement +*** Test Cases *** +Test CMSO Optimizer Admin + [Tags] ete + ${response}= Get Optimizer Plain Text alias admin/password + Should Contain ${response.text} kECFDaLusYNHTN6Q4DmsYw== + +Test CMSO Service Admin + [Tags] ete + ${response}= Get Scheduler Plain Text alias /cmso/v1/admin/password + Should Contain ${response.text} kECFDaLusYNHTN6Q4DmsYw== + +Test CMSO Ticket Mgt Admin + [Tags] ete + ${response}= Get Ticket Mgt Plain Text alias admin/password + Should Contain ${response.text} kECFDaLusYNHTN6Q4DmsYw== + +Test CMSO Topology Admin + [Tags] ete + ${response}= Get Topology Plain Text alias admin/password + Should Contain ${response.text} kECFDaLusYNHTN6Q4DmsYw== + +Test CMSO Optimizer Health + [Tags] ete + ${response}= Get Optimizer alias health + Dictionary Should Contain Item ${response.json()} healthy True + +Test CMSO Service Health + [Tags] ete + ${response}= Get Scheduler alias /cmso/v1/health + Dictionary Should Contain Item ${response.json()} healthy True + + +Test CMSO Ticket Mgt Health + [Tags] ete + ${response}= Get Ticket Mgt alias health + Dictionary Should Contain Item ${response.json()} healthy True + + +Test CMSO Topology Health + [Tags] ete + ${response}= Get Topology alias health + Dictionary Should Contain Item ${response.json()} healthy True + +Test CMSO Optimizer Policies + [Tags] ete + ${response}= Get Optimizer alias policies + ##Should Contain ${response.json()} kECFDaLusYNHTN6Q4DmsYw== + +Test CMSO Optimizer Get Schedule + [Tags] ete + ${response}= Get Optimizer alias optimize/schedule/id1 + ##Should Contain ${response.json()} kECFDaLusYNHTN6Q4DmsYw== + +Test CMSO Optimizer Delete Schedule + [Tags] ete + ${response}= Delete Optimizer alias optimize/schedule/id1 + ##Should Contain ${response.json()} kECFDaLusYNHTN6Q4DmsYw== + + +Test CMSO Ticket Mgt Get Tickets + [Tags] ete + ${response}= Get Ticket Mgt alias tickets + ##Dictionary Should Contain Item ${response.json()} healthy True + +Test CMSO Ticket Mgt Get Ticket + [Tags] ete + ${response}= Get Ticket Mgt alias ticket/none + ##Dictionary Should Contain Item ${response.json()} healthy True diff --git a/cmso-robot/setup.sh b/cmso-robot/setup.sh old mode 100644 new mode 100755 -- cgit 1.2.3-korg