| dhanasekaran | 6f0aed3 | 2022-05-17 14:12:40 +0200 | [diff] [blame] | 1 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | # you may not use this file except in compliance with the License. |
| 3 | # You may obtain a copy of the License at |
| 4 | # |
| 5 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | # |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | # See the License for the specific language governing permissions and |
| 11 | # limitations under the License |
| 12 | |
| 13 | *** Settings *** |
| 14 | Documentation [SOL003-01] Sol003 Api testing |
| 15 | Suite Teardown Run Keyword And Ignore Error Suite Cleanup |
| 16 | Force Tags sol003_01 cluster_sol003 daily |
| 17 | Library OperatingSystem |
| 18 | Library String |
| 19 | Library Collections |
| 20 | Library RequestsLibrary |
| 21 | Library yaml |
| 22 | Library JsonValidator |
| 23 | Library JSONLibrary |
| 24 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/sol003_common_lib.robot |
| 25 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot |
| 26 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/vim_lib.robot |
| 27 | |
| 28 | *** Variables *** |
| 29 | ${vnfd_pkg} hackfest_basic_metrics_vnf |
| 30 | ${vnfd_name} hackfest_basic_metrics-vnf |
| 31 | |
| 32 | *** Test Cases *** |
| 33 | Create VNF package from JSON file descriptor |
| 34 | [Documentation] Test case to create a VNF Identifier |
| 35 | ${id}= Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg}' |
| 36 | Set Suite Variable ${vnfid} ${id} |
| 37 | ${created_vim_account_id}= Get VIM Target ID %{VIM_TARGET} |
| 38 | Set Suite Variable ${created_vim_account_id} |
| 39 | Get Auth Token |
| 40 | ${json_path}= Read Directory |
| 41 | ${json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json |
| 42 | ${json_obj}= Get Variable Value ${json_obj['data'][0]} |
| 43 | ${updated_json_obj} JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${created_vim_account_id} |
| 44 | ${updated_json_obj} JSONLibrary.Update Value To Json ${updated_json_obj} $..additionalParams.virtual-link-desc[0][id] %{VIM_MGMT_NET} |
| 45 | ${updated_json_obj} JSONLibrary.Update Value To Json ${updated_json_obj} $..additionalParams.virtual-link-profile-id %{VIM_MGMT_NET} |
| 46 | Set Test Variable ${updated_json_obj} |
| 47 | Post API Request ${vnf_instance_uri} |
| 48 | Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed |
| 49 | ${id}= Get Value From Json ${request_response.json()} $..id |
| 50 | Set Suite Variable ${createid} ${id[0]} |
| 51 | |
| 52 | Instantiate VNF |
| 53 | [Documentation] Test case to Instantiate a VNF |
| 54 | Get Auth Token |
| 55 | ${json_path}= Read Directory |
| 56 | ${json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json |
| 57 | ${json_obj}= Get Variable Value ${json_obj['data'][1]} |
| 58 | ${updated_json_obj} JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${created_vim_account_id} |
| 59 | ${updated_json_obj} JSONLibrary.Update Value To Json ${json_obj} $..vnfId ${createid} |
| 60 | Set Test Variable ${updated_json_obj} |
| 61 | Post API Request ${vnf_instantiate_uri}/${createid}/instantiate |
| 62 | Pass Execution If ${request_response.status_code} in ${success_status_code_list} Instantiate VNF Instance completed |
| 63 | ${id}= Get Value From Json ${request_response.json()} $..id |
| 64 | Set Suite Variable ${instantiateid} ${id[0]} |
| 65 | Sleep 12s |
| 66 | |
| 67 | Query VNF Instances |
| 68 | [Documentation] Test case to query VNF Instance |
| 69 | Get Auth Token |
| 70 | Get Api Request ${vnf_instance_uri} |
| 71 | ${value}= Get ID nsState |
| 72 | Should Be Equal ${value} INSTANTIATED |
| 73 | Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed |
| 74 | ${id}= Get Value From Json ${request_response.json()} $.._id |
| 75 | Set Suite Variable ${Queryid} ${id[0]} |
| 76 | |
| 77 | Query VNF Instance ID |
| 78 | [Documentation] Test case to query Vnf instance ID |
| 79 | Get Auth Token |
| 80 | Get Api Request ${vnf_instance_uri}/${Queryid} |
| 81 | ${value}= Get ID nsState |
| 82 | Should Be Equal ${value} INSTANTIATED |
| 83 | Should Be Equal As Strings ${RequestResponse.status_code} 200 |
| 84 | ${id}= Get Value From Json ${request_response.json()} $.._id |
| 85 | Set Suite Variable ${Instanceid} ${id[0]} |
| 86 | |
| 87 | Query VNF LCM Ops |
| 88 | [Documentation] Test case to Query VNF LCM operation |
| 89 | Get Auth Token |
| 90 | Get Api Request ${vnf_instance_lcm_ops} |
| 91 | ${ID1}= Get Value From Json ${request_response.json()} $.._id |
| 92 | Set Suite Variable ${lcmops} ${ID1[0]} |
| 93 | FOR ${Index} IN RANGE 0 15 |
| 94 | Get Api Request ${vnf_instance_lcm_ops} |
| 95 | ${value}= Get ID operationState |
| 96 | ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED |
| 97 | Run Keyword If ${status} Exit For Loop |
| 98 | ... ELSE Sleep 10s |
| 99 | END |
| 100 | |
| 101 | Query VNF LCM Ops ID |
| 102 | Get Auth Token |
| 103 | Get Api Request ${vnf_instance_lcm_ops}/${lcmops} |
| 104 | ${ID1}= Get Value From Json ${request_response.json()} $.._id |
| 105 | Set Suite Variable ${lcmopsid} ${ID1[0]} |
| 106 | FOR ${Index} IN RANGE 0 15 |
| 107 | Get Api Request ${vnf_instance_lcm_ops}/${lcmops} |
| 108 | ${value}= Get ID operationState |
| 109 | ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED |
| 110 | Run Keyword If ${status} Exit For Loop |
| 111 | ... ELSE Sleep 10s |
| 112 | END |
| 113 | |
| 114 | Scale VNF |
| 115 | [Documentation] Test case to Scale out VNF |
| 116 | Get Auth Token |
| 117 | ${json_path}= Read Directory |
| 118 | ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json |
| 119 | ${updated_json_obj}= Get Variable Value ${updated_json_obj['data'][2]} |
| 120 | Set Test Variable ${updated_json_obj} |
| 121 | Post API Request ${vnf_instance_uri}/${createid}/scale |
| 122 | ${value}= Get ID id |
| 123 | ${ID1}= Get Value From Json ${request_response.json()} $..id |
| 124 | Set Suite Variable ${scaleoutid} ${ID1[0]} |
| 125 | Get Api Request ${vnf_instance_lcm_ops}/${scaleoutid} |
| 126 | ${LcmopsScale}= Get Value From Json ${request_response.json()} $.._id |
| 127 | Set Suite Variable ${lcmopsscaleid} ${LcmopsScale[0]} |
| 128 | FOR ${Index} IN RANGE 0 15 |
| 129 | Get Api Request ${vnf_instance_lcm_ops}/${scaleoutid} |
| 130 | ${value}= Get ID operationState |
| 131 | ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED |
| 132 | Run Keyword If ${status} Exit For Loop |
| 133 | ... ELSE Sleep 10s |
| 134 | END |
| 135 | Pass Execution If ${request_response.status_code} in ${success_status_code_list} Scale VNF instance completed |
| 136 | |
| 137 | Terminate VNF |
| 138 | [Documentation] Test case to terminate the VNF |
| 139 | Get Auth Token |
| 140 | ${json_path}= Read Directory |
| 141 | ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json |
| 142 | ${updated_json_obj}= Get Variable Value ${updated_json_obj['data'][3]} |
| 143 | Set Suite Variable ${updated_json_obj} |
| 144 | Post API Request ${vnf_instance_uri}/${createid}/terminate |
| 145 | ${id}= Get Value From Json ${request_response.json()} $..id |
| 146 | Set Suite Variable ${terminateid} ${id[0]} |
| 147 | Get Api Request ${vnf_instance_lcm_ops}/${terminateid} |
| 148 | ${LcmopsTerminate}= Get Value From Json ${request_response.json()} $.._id |
| 149 | Set Suite Variable ${lcmopsscaleid} ${LcmopsTerminate[0]} |
| 150 | FOR ${Index} IN RANGE 0 15 |
| 151 | Get Api Request ${vnf_instance_lcm_ops}/${terminateid} |
| 152 | ${value}= Get ID operationState |
| 153 | ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED |
| 154 | Run Keyword If ${status} Exit For Loop |
| 155 | ... ELSE Sleep 10s |
| 156 | END |
| 157 | Pass Execution If ${request_response.status_code} in ${success_status_code_list} Terminate VNF instance completed |
| 158 | |
| 159 | Delete VNF |
| 160 | [Documentation] Test case to delete VNF |
| 161 | Get Auth Token |
| 162 | Create Session APISession ${HOST} |
| 163 | &{Headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${AccessToken} |
| 164 | ${resp}= DELETE On Session APISession ${vnf_instance_uri}/${createid} headers=${Headers} |
| 165 | Pass Execution If ${resp.status_code} in ${success_status_code_list} Delete VNF Instance completed |
| 166 | |
| 167 | Delete VNF Descriptor Test |
| 168 | [Tags] cleanup |
| 169 | |
| 170 | Delete VNFD ${vnfd_name} |
| 171 | |
| 172 | *** Keywords *** |
| 173 | Suite Cleanup |
| 174 | [Documentation] Test Suit Cleanup: Deleting Descriptor |
| 175 | |
| 176 | Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name} |