+++ /dev/null
-# Licensed under the Apache License, Version 2.0 (the "License");\r
-# you may not use this file except in compliance with the License.\r
-# You may obtain a copy of the License at\r
-#\r
-# http://www.apache.org/licenses/LICENSE-2.0\r
-#\r
-# Unless required by applicable law or agreed to in writing, software\r
-# distributed under the License is distributed on an "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# See the License for the specific language governing permissions and\r
-# limitations under the License\r
-\r
-*** Settings ***\r
-Documentation Library with sol003 keywords and variables .\r
-\r
-Library RequestsLibrary\r
-Library HttpLibrary.HTTP\r
-Library JsonValidator\r
-Library yaml\r
-Library JSONLibrary\r
-Library String\r
-Library OperatingSystem\r
-Resource %{ROBOT_DEVOPS_FOLDER}/lib/vim_lib.robot\r
-Variables %{ROBOT_DEVOPS_FOLDER}/resources/basic_01-crud_operations_on_vim_targets_data.py\r
-\r
-*** Variables ***\r
-&{HEADERS} Content-Type=application/json Accept=application/json\r
-&{data} username=admin password=admin project-id=admin\r
-@{success_status_code_list} 200 201 202 204\r
-${descriptor_content_type_gzip} application/gzip\r
-${auth_token_uri} /osm/admin/v1/tokens\r
-${HOST} ${EMPTY}\r
-${vnf_instance_uri} /osm/vnflcm/v1/vnf_instances\r
-${vnf_instantiate_uri} /osm/vnflcm/v1/vnf_instances\r
-${vnf_instance_lcm_ops} /osm/vnflcm/v1/vnf_lcm_op_occs\r
-\r
-*** Keywords ***\r
-Get Auth Token\r
- [Tags] auth_token\r
- Get Hostname\r
- Create Session osmhit ${HOST} verify=${FALSE} debug=1 data=${data} headers=${HEADERS}\r
- Log Many ${auth_token_uri} @{data} ${data}\r
- ${resp}= Post Request osmhit ${auth_token_uri} data=${data}\r
- log ${resp}\r
- Pass Execution If ${resp.status_code} in ${success_status_code_list} Get Auth Token completed\r
- Set Suite Variable ${token_status_code} ${resp.status_code}\r
- ${access_token}= Get Value From Json ${resp.json()} $..id\r
- Set Suite Variable ${access_token} ${access_token[0]}\r
- Set Suite Variable ${token_response} ${resp}\r
- sleep 2s\r
-\r
-Set Dockerized Host\r
- [Arguments] ${env_host}\r
- Set Suite Variable ${HOST} https://${env_host}\r
-\r
-Set Standalone Host\r
- [Arguments] ${env_host}\r
- Set Suite Variable ${HOST} https://${env_host}:9999\r
-\r
-Create VIM\r
- [Documentation] Create a VIM Target only with the mandatory parameters.\r
- Pass Execution If '${vim_account_type}' != 'openstack' Not applicable for ${vim_account_type} VIM\r
- ${rand}= Generate Random String 6 [NUMBERS]\r
- ${vim_name}= Catenate SEPARATOR=_ ${vim_name_prefix} ${rand}\r
- Set Suite Variable ${vim_name}\r
- ${created_vim_account_id}= Create VIM Target ${vim_name} ${vim_user} ${vim_password} ${vim_auth_url} ${vim_tenant}\r
- ... ${vim_account_type}\r
- Set Suite Variable ${created_vim_account_id}\r
- Check VIM Target Operational State ${vim_name}\r
-\r
-Read Directory\r
- [Documentation] To Read Current Direct ory\r
- ${Directory}= Replace String ${CURDIR} testsuite \\resources/\r
- ${json_path}= Set Variable ${Directory}\r
- [Return] ${JsonPath}\r
-\r
-Post Api Request\r
- [Arguments] ${PostApi}\r
- [Documentation] Keword to Post API Request\r
- Create Session APISession ${HOST}\r
- &{headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${access_token}\r
- ${request_response}= Post Request APISession ${PostApi} data=${updated_json_obj} headers=${headers}\r
- Set Suite Variable ${request_response}\r
- ${response_statuscode} Convert To String ${request_response.status_code}\r
- Set Suite Variable ${response_statuscode}\r
-\r
-Get HostName\r
- [Documentation] Keyword to get the default osm Hostname\r
- ${nbi_host}= Get Environment Variable OSM_HOSTNAME\r
- ${passed}= Run Keyword And Return Status Should Contain ${nbi_host} :\r
- Run Keyword If ${passed} Set Dockerized Host ${nbi_host}\r
- ... ELSE Set Standalone Host ${nbi_host}\r
-\r
-Get ID\r
- [Arguments] ${Key}\r
- Pass Execution If ${request_response.status_code} in ${success_status_code_list} Get Auth Token completed\r
- ${id}= Get Value From Json ${request_response.json()} $..${Key}\r
- Set Suite Variable ${value} ${id[0]}\r
- [Return] ${value}\r
-\r
-Update Json Value\r
- [Arguments] ${JsonInput} ${key}\r
- ${json_path}= Read Directory\r
- ${json_obj}= Load JSON From File ${json_path}/${JsonInput}\r
- ${updated_json_obj} JSONLibrary.Update Value To Json ${json_obj} $..${key} ${created_vim_account_id}\r
- Set Suite Variable ${updated_json_obj}\r
-\r
-Get Api Request\r
- [Arguments] ${uri}\r
- [Documentation] Keyword to Get API Request\r
- Create Session Session ${HOST}\r
- &{headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${access_token}\r
- ${request_response}= Get Request Session ${uri} headers=${Headers}\r
- Set Suite Variable ${request_response}\r
- ${response_statuscode} Convert To String ${request_response.status_code}\r
- Set Suite Variable ${response_statuscode}\r
+++ /dev/null
-# Licensed under the Apache License, Version 2.0 (the "License");\r
-# you may not use this file except in compliance with the License.\r
-# You may obtain a copy of the License at\r
-#\r
-# http://www.apache.org/licenses/LICENSE-2.0\r
-#\r
-# Unless required by applicable law or agreed to in writing, software\r
-# distributed under the License is distributed on an "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# See the License for the specific language governing permissions and\r
-# limitations under the License\r
-\r
-*** Settings ***\r
-Documentation [SOL003-01] Sol003 Api testing\r
-Suite Teardown Run Keyword And Ignore Error Suite Cleanup\r
-Force Tags sol003_01 cluster_sol003 daily\r
-Library OperatingSystem\r
-Library String\r
-Library Collections\r
-Library RequestsLibrary\r
-Library HttpLibrary.HTTP\r
-Library yaml\r
-Library JsonValidator\r
-Library JSONLibrary\r
-Resource %{ROBOT_DEVOPS_FOLDER}/lib/sol003-common.robot\r
-Variables %{ROBOT_DEVOPS_FOLDER}/resources/sol003_01-vnf-lifecycle-management.json\r
-Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot\r
-\r
-*** Variables ***\r
-${vnfd_pkg} hackfest_basic_metrics_vnf\r
-${vnfd_name} hackfest_basic_metrics_vnf\r
-\r
-*** Test Cases ***\r
-Create VNF package from JSON file descriptor\r
- [Documentation] Test case to create a VNF Identifier\r
- Create VIM\r
- Get Auth Token\r
- ${json_path}= Read Directory\r
- ${json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json\r
- ${json_obj}= Get Variable Value ${json_obj['data'][0]}\r
- ${updated_json_obj} JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${created_vim_account_id}\r
- ${updated_json_obj} JSONLibrary.Update Value To Json ${updated_json_obj} $..additionalParams.virtual-link-desc[0][id] %{VIM_MGMT_NET}\r
- ${updated_json_obj} JSONLibrary.Update Value To Json ${updated_json_obj} $..additionalParams.virtual-link-profile-id %{VIM_MGMT_NET}\r
- Set Suite Variable ${updated_json_obj}\r
- Post API Request ${vnf_instance_uri}\r
- Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed\r
- ${id}= Get Value From Json ${request_response.json()} $..id\r
- Set Suite Variable ${createid} ${id[0]}\r
-\r
-Instantiate VNF\r
- [Documentation] Test case to Instantiate a VNF\r
- ${id}= Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg}'\r
- Set Suite Variable ${vnfid} ${id}\r
- Get Auth Token\r
- ${json_path}= Read Directory\r
- ${json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json\r
- ${json_obj}= Get Variable Value ${json_obj['data'][1]}\r
- ${updated_json_obj} JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${created_vim_account_id}\r
- ${updated_json_obj} JSONLibrary.Update Value To Json ${json_obj} $..vnfId ${createid}\r
- Post API Request ${vnf_instantiate_uri}/${createid}/instantiate\r
- Pass Execution If ${request_response.status_code} in ${success_status_code_list} Instantiate VNF Instance completed\r
- ${id}= Get Value From Json ${request_response.json()} $..id\r
- Set Suite Variable ${instantiateid} ${id[0]}\r
- Sleep 12s\r
-\r
-Query VNF Instances\r
- [Documentation] Test case to query VNF Instance\r
- Get Auth Token\r
- Get Api Request ${vnf_instance_uri}\r
- ${value}= Get ID nsState\r
- Should Be Equal ${value} INSTANTIATED\r
- Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed\r
- ${id}= Get Value From Json ${request_response.json()} $.._id\r
- Set Suite Variable ${Queryid} ${id[0]}\r
-\r
-Query VNF Instance ID\r
- [Documentation] Test case to query Vnf instance ID\r
- Get Auth Token\r
- Get Api Request ${vnf_instance_uri}/${Queryid}\r
- ${value}= Get ID nsState\r
- Should Be Equal ${value} INSTANTIATED\r
- Should Be Equal As Strings ${RequestResponse.status_code} 202\r
- ${id}= Get Value From Json ${request_response.json()} $.._id\r
- Set Suite Variable ${Instanceid} ${id[0]}\r
-\r
-Query VNF LCM Ops\r
- [Documentation] Test case to Query VNF LCM operation\r
- Get Auth Token\r
- Get Api Request ${vnf_instance_lcm_ops}\r
- ${ID1}= Get Value From Json ${request_response.json()} $.._id\r
- Set Suite Variable ${lcmops} ${ID1[0]}\r
- ${value}= Get ID operationState\r
- Should Be Equal ${value} COMPLETED\r
-\r
-Query VNF LCM Ops ID\r
- Get Auth Token\r
- Get Api Request ${vnf_instance_lcm_ops}/${lcmops}\r
- ${ID1}= Get Value From Json ${request_response.json()} $.._id\r
- Set Suite Variable ${lcmopsid} ${ID1[0]}\r
- ${value}= Get ID operationState\r
- : FOR ${Index} IN RANGE 0 15\r
- \ ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED\r
- \ Run Keyword Unless ${status} Sleep 10s\r
- \ Run Keyword If ${status} Exit For Loop\r
-\r
-Scale VNF\r
- [Documentation] Test case to Scale in and Scale out VNF\r
- Get Auth Token\r
- ${json_path}= Read Directory\r
- ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json\r
- ${updated_json_obj}= Get Variable Value ${updated_json_obj['data'][2]}\r
- Set Suite Variable ${updated_json_obj}\r
- Post API Request ${vnf_instance_uri}/${createid}/scale\r
- ${value}= Get ID id\r
- ${ID1}= Get Value From Json ${request_response.json()} $..id\r
- Set Suite Variable ${scaleoutid} ${ID1[0]}\r
- Sleep 5s\r
- ${json_path}= Read Directory\r
- ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json\r
- ${updated_json_obj} JSONLibrary.Update Value To Json ${updated_json_obj} $..type SCALE_IN\r
- Set Suite Variable ${updated_json_obj}\r
- Post API Request ${vnf_instance_uri}/${createid}/scale\r
- Pass Execution If ${request_response.status_code} in ${success_status_code_list} Scale VNF instance completed\r
- ${id}= Get Value From Json ${request_response.json()} $..id\r
- Set Suite Variable ${scaleind} ${id[0]}\r
- Sleep 10s\r
-\r
-Terminate VNF\r
- [Documentation] Test case to terminate the VNF\r
- Get Auth Token\r
- ${json_path}= Read Directory\r
- ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json\r
- ${updated_json_obj}= Get Variable Value ${updated_json_obj['data'][3]}\r
- Set Suite Variable ${updated_json_obj}\r
- Post API Request ${vnf_instance_uri}/${createid}/terminate\r
- ${id}= Get Value From Json ${request_response.json()} $..id\r
- Set Suite Variable ${terminateid} ${id[0]}\r
- Pass Execution If ${request_response.status_code} in ${success_status_code_list} Terminate VNF instance completed\r
- sleep 10s\r
-\r
-Delete VNF\r
- [Documentation] Test case to delete VNF\r
- Get Auth Token\r
- Create Session APISession ${HOST}\r
- &{Headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${AccessToken}\r
- ${resp}= Delete Request APISession ${vnf_instance_uri}/${createid}\r
- Pass Execution If ${resp.status_code} in ${success_status_code_list} Delete VNF Instance completed\r