From: dhanasekaran Date: Thu, 28 Apr 2022 08:03:07 +0000 (+0000) Subject: Feature 10915: SOL003 STD Support for OSM - Robot Support X-Git-Tag: v12.0.0rc1~25 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=7b8a0026ea790561beb96b47e40546a6cdd6706a;p=osm%2Ftests.git Feature 10915: SOL003 STD Support for OSM - Robot Support Robot tests for Sol003 feature Change-Id: I06ca0ebac196fa83f20c34dfeb61e12d6f13eb43 Signed-off-by: dhanasekaran --- diff --git a/robot-systest/lib/sol003_common_lib.robot b/robot-systest/lib/sol003_common_lib.robot new file mode 100644 index 0000000..87352ef --- /dev/null +++ b/robot-systest/lib/sol003_common_lib.robot @@ -0,0 +1,116 @@ +# 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 + +*** Settings *** +Documentation Library with sol003 keywords and variables . + +Library RequestsLibrary +Library HttpLibrary.HTTP +Library JsonValidator +Library yaml +Library JSONLibrary +Library String +Library OperatingSystem +Resource %{ROBOT_DEVOPS_FOLDER}/lib/vim_lib.robot +Variables %{ROBOT_DEVOPS_FOLDER}/resources/basic_01-crud_operations_on_vim_targets_data.py + +*** Variables *** +&{HEADERS} Content-Type=application/json Accept=application/json +&{data} username=admin password=admin project-id=admin +@{success_status_code_list} 200 201 202 204 +${descriptor_content_type_gzip} application/gzip +${auth_token_uri} /osm/admin/v1/tokens +${HOST} ${EMPTY} +${vnf_instance_uri} /osm/vnflcm/v1/vnf_instances +${vnf_instantiate_uri} /osm/vnflcm/v1/vnf_instances +${vnf_instance_lcm_ops} /osm/vnflcm/v1/vnf_lcm_op_occs + +*** Keywords *** +Get Auth Token + [Tags] auth_token + Get Hostname + Create Session osmhit ${HOST} verify=${FALSE} debug=1 data=${data} headers=${HEADERS} + Log Many ${auth_token_uri} @{data} ${data} + ${resp}= Post Request osmhit ${auth_token_uri} data=${data} + log ${resp} + Pass Execution If ${resp.status_code} in ${success_status_code_list} Get Auth Token completed + Set Suite Variable ${token_status_code} ${resp.status_code} + ${access_token}= Get Value From Json ${resp.json()} $..id + Set Suite Variable ${access_token} ${access_token[0]} + Set Suite Variable ${token_response} ${resp} + sleep 2s + +Set Dockerized Host + [Arguments] ${env_host} + Set Suite Variable ${HOST} https://${env_host} + +Set Standalone Host + [Arguments] ${env_host} + Set Suite Variable ${HOST} https://${env_host}:9999 + +Create VIM + [Documentation] Create a VIM Target only with the mandatory parameters. + Pass Execution If '${vim_account_type}' != 'openstack' Not applicable for ${vim_account_type} VIM + ${rand}= Generate Random String 6 [NUMBERS] + ${vim_name}= Catenate SEPARATOR=_ ${vim_name_prefix} ${rand} + Set Suite Variable ${vim_name} + ${created_vim_account_id}= Create VIM Target ${vim_name} ${vim_user} ${vim_password} ${vim_auth_url} ${vim_tenant} + ... ${vim_account_type} + Set Suite Variable ${created_vim_account_id} + Check VIM Target Operational State ${vim_name} + +Read Directory + [Documentation] To Read Current Direct ory + ${Directory}= Replace String ${CURDIR} testsuite \\resources/ + ${json_path}= Set Variable ${Directory} + [Return] ${JsonPath} + +Post Api Request + [Arguments] ${PostApi} + [Documentation] Keword to Post API Request + Create Session APISession ${HOST} + &{headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${access_token} + ${request_response}= Post Request APISession ${PostApi} data=${updated_json_obj} headers=${headers} + Set Suite Variable ${request_response} + ${response_statuscode} Convert To String ${request_response.status_code} + Set Suite Variable ${response_statuscode} + +Get HostName + [Documentation] Keyword to get the default osm Hostname + ${nbi_host}= Get Environment Variable OSM_HOSTNAME + ${passed}= Run Keyword And Return Status Should Contain ${nbi_host} : + Run Keyword If ${passed} Set Dockerized Host ${nbi_host} + ... ELSE Set Standalone Host ${nbi_host} + +Get ID + [Arguments] ${Key} + Pass Execution If ${request_response.status_code} in ${success_status_code_list} Get Auth Token completed + ${id}= Get Value From Json ${request_response.json()} $..${Key} + Set Suite Variable ${value} ${id[0]} + [Return] ${value} + +Update Json Value + [Arguments] ${JsonInput} ${key} + ${json_path}= Read Directory + ${json_obj}= Load JSON From File ${json_path}/${JsonInput} + ${updated_json_obj} JSONLibrary.Update Value To Json ${json_obj} $..${key} ${created_vim_account_id} + Set Suite Variable ${updated_json_obj} + +Get Api Request + [Arguments] ${uri} + [Documentation] Keyword to Get API Request + Create Session Session ${HOST} + &{headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${access_token} + ${request_response}= Get Request Session ${uri} headers=${Headers} + Set Suite Variable ${request_response} + ${response_statuscode} Convert To String ${request_response.status_code} + Set Suite Variable ${response_statuscode} diff --git a/robot-systest/resources/sol003_01-vnf-lifecycle-management.json b/robot-systest/resources/sol003_01-vnf-lifecycle-management.json new file mode 100644 index 0000000..267dd03 --- /dev/null +++ b/robot-systest/resources/sol003_01-vnf-lifecycle-management.json @@ -0,0 +1,38 @@ +{ + "data":[ + { + "vnfdId":"hackfest_basic_metrics-vnf", + "vnfInstanceName":"sol003-instance", + "vnfInstanceDescription":"Test vnfm instance description", + "vimAccountId":"8dc2f11d-e08a-4ec7-920c-6b8a88bff1e5", + "additionalParams":{ + "virtual-link-desc":[ + { + "id":"mgmtnet", + "mgmt-network":true + } + ], + "constituent-cpd-id":"vnf-cp0-ext", + "virtual-link-profile-id":"mgmtnet" + } + }, + { + "vnfName":"sol003-instance", + "vnfDescription":"vnf package", + "vnfId":"70b47595-fafa-4f63-904b-fc3ada60eebb", + "vimAccountId":"8dc2f11d-e08a-4ec7-920c-6b8a88bff1e5" + }, + { + "type":"SCALE_OUT", + "aspectId":"vdu_autoscale", + "numberOfSteps":"1", + "additionalParams":{ + "member-vnf-index":"1" + } + }, + { + "terminationType":"GRACEFUL", + "gracefulTerminationTimeout":"5" + } + ] +} diff --git a/robot-systest/testsuite/sol003_01-vnf-lifecycle-management.robot b/robot-systest/testsuite/sol003_01-vnf-lifecycle-management.robot new file mode 100644 index 0000000..18a2e13 --- /dev/null +++ b/robot-systest/testsuite/sol003_01-vnf-lifecycle-management.robot @@ -0,0 +1,147 @@ +# 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 + +*** Settings *** +Documentation [SOL003-01] Sol003 Api testing +Suite Teardown Run Keyword And Ignore Error Suite Cleanup +Force Tags sol003_01 cluster_sol003 daily +Library OperatingSystem +Library String +Library Collections +Library RequestsLibrary +Library HttpLibrary.HTTP +Library yaml +Library JsonValidator +Library JSONLibrary +Resource %{ROBOT_DEVOPS_FOLDER}/lib/sol003-common.robot +Variables %{ROBOT_DEVOPS_FOLDER}/resources/sol003_01-vnf-lifecycle-management.json +Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot + +*** Variables *** +${vnfd_pkg} hackfest_basic_metrics_vnf +${vnfd_name} hackfest_basic_metrics_vnf + +*** Test Cases *** +Create VNF package from JSON file descriptor + [Documentation] Test case to create a VNF Identifier + Create VIM + Get Auth Token + ${json_path}= Read Directory + ${json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json + ${json_obj}= Get Variable Value ${json_obj['data'][0]} + ${updated_json_obj} JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${created_vim_account_id} + ${updated_json_obj} JSONLibrary.Update Value To Json ${updated_json_obj} $..additionalParams.virtual-link-desc[0][id] %{VIM_MGMT_NET} + ${updated_json_obj} JSONLibrary.Update Value To Json ${updated_json_obj} $..additionalParams.virtual-link-profile-id %{VIM_MGMT_NET} + Set Suite Variable ${updated_json_obj} + Post API Request ${vnf_instance_uri} + Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed + ${id}= Get Value From Json ${request_response.json()} $..id + Set Suite Variable ${createid} ${id[0]} + +Instantiate VNF + [Documentation] Test case to Instantiate a VNF + ${id}= Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg}' + Set Suite Variable ${vnfid} ${id} + Get Auth Token + ${json_path}= Read Directory + ${json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json + ${json_obj}= Get Variable Value ${json_obj['data'][1]} + ${updated_json_obj} JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${created_vim_account_id} + ${updated_json_obj} JSONLibrary.Update Value To Json ${json_obj} $..vnfId ${createid} + Post API Request ${vnf_instantiate_uri}/${createid}/instantiate + Pass Execution If ${request_response.status_code} in ${success_status_code_list} Instantiate VNF Instance completed + ${id}= Get Value From Json ${request_response.json()} $..id + Set Suite Variable ${instantiateid} ${id[0]} + Sleep 12s + +Query VNF Instances + [Documentation] Test case to query VNF Instance + Get Auth Token + Get Api Request ${vnf_instance_uri} + ${value}= Get ID nsState + Should Be Equal ${value} INSTANTIATED + Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed + ${id}= Get Value From Json ${request_response.json()} $.._id + Set Suite Variable ${Queryid} ${id[0]} + +Query VNF Instance ID + [Documentation] Test case to query Vnf instance ID + Get Auth Token + Get Api Request ${vnf_instance_uri}/${Queryid} + ${value}= Get ID nsState + Should Be Equal ${value} INSTANTIATED + Should Be Equal As Strings ${RequestResponse.status_code} 202 + ${id}= Get Value From Json ${request_response.json()} $.._id + Set Suite Variable ${Instanceid} ${id[0]} + +Query VNF LCM Ops + [Documentation] Test case to Query VNF LCM operation + Get Auth Token + Get Api Request ${vnf_instance_lcm_ops} + ${ID1}= Get Value From Json ${request_response.json()} $.._id + Set Suite Variable ${lcmops} ${ID1[0]} + ${value}= Get ID operationState + Should Be Equal ${value} COMPLETED + +Query VNF LCM Ops ID + Get Auth Token + Get Api Request ${vnf_instance_lcm_ops}/${lcmops} + ${ID1}= Get Value From Json ${request_response.json()} $.._id + Set Suite Variable ${lcmopsid} ${ID1[0]} + ${value}= Get ID operationState + : FOR ${Index} IN RANGE 0 15 + \ ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED + \ Run Keyword Unless ${status} Sleep 10s + \ Run Keyword If ${status} Exit For Loop + +Scale VNF + [Documentation] Test case to Scale in and Scale out VNF + Get Auth Token + ${json_path}= Read Directory + ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json + ${updated_json_obj}= Get Variable Value ${updated_json_obj['data'][2]} + Set Suite Variable ${updated_json_obj} + Post API Request ${vnf_instance_uri}/${createid}/scale + ${value}= Get ID id + ${ID1}= Get Value From Json ${request_response.json()} $..id + Set Suite Variable ${scaleoutid} ${ID1[0]} + Sleep 5s + ${json_path}= Read Directory + ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json + ${updated_json_obj} JSONLibrary.Update Value To Json ${updated_json_obj} $..type SCALE_IN + Set Suite Variable ${updated_json_obj} + Post API Request ${vnf_instance_uri}/${createid}/scale + Pass Execution If ${request_response.status_code} in ${success_status_code_list} Scale VNF instance completed + ${id}= Get Value From Json ${request_response.json()} $..id + Set Suite Variable ${scaleind} ${id[0]} + Sleep 10s + +Terminate VNF + [Documentation] Test case to terminate the VNF + Get Auth Token + ${json_path}= Read Directory + ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json + ${updated_json_obj}= Get Variable Value ${updated_json_obj['data'][3]} + Set Suite Variable ${updated_json_obj} + Post API Request ${vnf_instance_uri}/${createid}/terminate + ${id}= Get Value From Json ${request_response.json()} $..id + Set Suite Variable ${terminateid} ${id[0]} + Pass Execution If ${request_response.status_code} in ${success_status_code_list} Terminate VNF instance completed + sleep 10s + +Delete VNF + [Documentation] Test case to delete VNF + Get Auth Token + Create Session APISession ${HOST} + &{Headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${AccessToken} + ${resp}= Delete Request APISession ${vnf_instance_uri}/${createid} + Pass Execution If ${resp.status_code} in ${success_status_code_list} Delete VNF Instance completed