blob: 750ea847516bf4d2cb365cfb86d3d83d6107e75a [file] [log] [blame]
dhanasekaran6f0aed32022-05-17 14:12:40 +02001# 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 ***
garciadeblasf4ebaa82022-06-23 13:33:26 +020014Documentation [SOL003-01] Sol003 Api testing
garciadeblasd7f75d72022-06-25 18:38:32 +020015
garciadeblasf4ebaa82022-06-23 13:33:26 +020016Library OperatingSystem
17Library String
18Library Collections
19Library RequestsLibrary
20Library yaml
21Library JsonValidator
22Library JSONLibrary
garciadeblasd7f75d72022-06-25 18:38:32 +020023
garciadeblasf4ebaa82022-06-23 13:33:26 +020024Resource %{ROBOT_DEVOPS_FOLDER}/lib/sol003_common_lib.robot
25Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
garciadeblas43f34482023-02-23 17:37:47 +010026Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
27Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnf_lib.robot
garciadeblasf4ebaa82022-06-23 13:33:26 +020028Resource %{ROBOT_DEVOPS_FOLDER}/lib/vim_lib.robot
dhanasekaran6f0aed32022-05-17 14:12:40 +020029
garciadeblasd7f75d72022-06-25 18:38:32 +020030Force Tags sol003_01 cluster_sol003 daily
31
32Suite Teardown Run Keyword And Ignore Error Suite Cleanup
33
34
dhanasekaran6f0aed32022-05-17 14:12:40 +020035*** Variables ***
garciadeblasf4ebaa82022-06-23 13:33:26 +020036${vnfd_pkg} hackfest_basic_metrics_vnf
37${vnfd_name} hackfest_basic_metrics-vnf
dhanasekaran6f0aed32022-05-17 14:12:40 +020038
garciadeblasd7f75d72022-06-25 18:38:32 +020039
dhanasekaran6f0aed32022-05-17 14:12:40 +020040*** Test Cases ***
41Create VNF package from JSON file descriptor
garciadeblasf4ebaa82022-06-23 13:33:26 +020042 [Documentation] Test case to create a VNF Identifier
garciadeblas43f34482023-02-23 17:37:47 +010043 Get VNFDs List
garciadeblasf4ebaa82022-06-23 13:33:26 +020044 ${id}= Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg}'
45 Set Suite Variable ${vnfid} ${id}
46 ${created_vim_account_id}= Get VIM Target ID %{VIM_TARGET}
47 Set Suite Variable ${created_vim_account_id}
dhanasekaran6f0aed32022-05-17 14:12:40 +020048 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +020049 ${json_path}= Read Directory
50 ${json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json
51 ${json_obj}= Get Variable Value ${json_obj['data'][0]}
garciadeblas43f34482023-02-23 17:37:47 +010052 ${updated_json_obj}= JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${created_vim_account_id}
53 Log ${updated_json_obj}
54 ${updated_json_obj}= JSONLibrary.Update Value To Json ${updated_json_obj} $..additionalParams.virtual-link-desc[0][id] %{VIM_MGMT_NET}
55 Log ${updated_json_obj}
56 ${updated_json_obj}= JSONLibrary.Update Value To Json ${updated_json_obj} $..additionalParams.virtual-link-profile-id %{VIM_MGMT_NET}
57 Log ${updated_json_obj}
garciadeblasf4ebaa82022-06-23 13:33:26 +020058 Set Test Variable ${updated_json_obj}
59 Post API Request ${vnf_instance_uri}
60 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed
61 ${id}= Get Value From Json ${request_response.json()} $..id
62 Set Suite Variable ${createid} ${id[0]}
garciadeblas43f34482023-02-23 17:37:47 +010063 Get VNFDs List
dhanasekaran6f0aed32022-05-17 14:12:40 +020064
65Instantiate VNF
garciadeblasf4ebaa82022-06-23 13:33:26 +020066 [Documentation] Test case to Instantiate a VNF
garciadeblas43f34482023-02-23 17:37:47 +010067 Get Ns List
68 Get Vnf List
dhanasekaran6f0aed32022-05-17 14:12:40 +020069 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +020070 ${json_path}= Read Directory
71 ${json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json
72 ${json_obj}= Get Variable Value ${json_obj['data'][1]}
garciadeblas43f34482023-02-23 17:37:47 +010073 ${updated_json_obj}= JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${created_vim_account_id}
74 ${updated_json_obj}= JSONLibrary.Update Value To Json ${updated_json_obj} $..vnfId ${createid}
garciadeblasf4ebaa82022-06-23 13:33:26 +020075 Set Test Variable ${updated_json_obj}
76 Post API Request ${vnf_instantiate_uri}/${createid}/instantiate
77 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Instantiate VNF Instance completed
78 ${id}= Get Value From Json ${request_response.json()} $..id
79 Set Suite Variable ${instantiateid} ${id[0]}
80 Sleep 12s
garciadeblas43f34482023-02-23 17:37:47 +010081 Get Ns List
82 Get Vnf List
dhanasekaran6f0aed32022-05-17 14:12:40 +020083
84Query VNF Instances
garciadeblasf4ebaa82022-06-23 13:33:26 +020085 [Documentation] Test case to query VNF Instance
dhanasekaran6f0aed32022-05-17 14:12:40 +020086 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +020087 Get Api Request ${vnf_instance_uri}
88 ${value}= Get ID nsState
89 Should Be Equal ${value} INSTANTIATED
90 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed
91 ${id}= Get Value From Json ${request_response.json()} $.._id
92 Set Suite Variable ${Queryid} ${id[0]}
dhanasekaran6f0aed32022-05-17 14:12:40 +020093
94Query VNF Instance ID
garciadeblasf4ebaa82022-06-23 13:33:26 +020095 [Documentation] Test case to query Vnf instance ID
dhanasekaran6f0aed32022-05-17 14:12:40 +020096 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +020097 Get Api Request ${vnf_instance_uri}/${Queryid}
98 ${value}= Get ID nsState
99 Should Be Equal ${value} INSTANTIATED
100 Should Be Equal As Strings ${RequestResponse.status_code} 200
101 ${id}= Get Value From Json ${request_response.json()} $.._id
102 Set Suite Variable ${Instanceid} ${id[0]}
dhanasekaran6f0aed32022-05-17 14:12:40 +0200103
104Query VNF LCM Ops
garciadeblasf4ebaa82022-06-23 13:33:26 +0200105 [Documentation] Test case to Query VNF LCM operation
dhanasekaran6f0aed32022-05-17 14:12:40 +0200106 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200107 Get Api Request ${vnf_instance_lcm_ops}
108 ${ID1}= Get Value From Json ${request_response.json()} $.._id
109 Set Suite Variable ${lcmops} ${ID1[0]}
110 FOR ${Index} IN RANGE 0 15
111 Get Api Request ${vnf_instance_lcm_ops}
112 ${value}= Get ID operationState
113 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
114 Run Keyword If ${status} Exit For Loop
115 ... ELSE Sleep 10s
dhanasekaran6f0aed32022-05-17 14:12:40 +0200116 END
117
118Query VNF LCM Ops ID
119 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200120 Get Api Request ${vnf_instance_lcm_ops}/${lcmops}
121 ${ID1}= Get Value From Json ${request_response.json()} $.._id
122 Set Suite Variable ${lcmopsid} ${ID1[0]}
123 FOR ${Index} IN RANGE 0 15
124 Get Api Request ${vnf_instance_lcm_ops}/${lcmops}
125 ${value}= Get ID operationState
126 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
127 Run Keyword If ${status} Exit For Loop
128 ... ELSE Sleep 10s
dhanasekaran6f0aed32022-05-17 14:12:40 +0200129 END
130
131Scale VNF
garciadeblasf4ebaa82022-06-23 13:33:26 +0200132 [Documentation] Test case to Scale out VNF
dhanasekaran6f0aed32022-05-17 14:12:40 +0200133 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200134 ${json_path}= Read Directory
135 ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json
136 ${updated_json_obj}= Get Variable Value ${updated_json_obj['data'][2]}
137 Set Test Variable ${updated_json_obj}
138 Post API Request ${vnf_instance_uri}/${createid}/scale
139 ${value}= Get ID id
140 ${ID1}= Get Value From Json ${request_response.json()} $..id
141 Set Suite Variable ${scaleoutid} ${ID1[0]}
142 Get Api Request ${vnf_instance_lcm_ops}/${scaleoutid}
143 ${LcmopsScale}= Get Value From Json ${request_response.json()} $.._id
144 Set Suite Variable ${lcmopsscaleid} ${LcmopsScale[0]}
145 FOR ${Index} IN RANGE 0 15
146 Get Api Request ${vnf_instance_lcm_ops}/${scaleoutid}
147 ${value}= Get ID operationState
148 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
149 Run Keyword If ${status} Exit For Loop
150 ... ELSE Sleep 10s
dhanasekaran6f0aed32022-05-17 14:12:40 +0200151 END
garciadeblasf4ebaa82022-06-23 13:33:26 +0200152 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Scale VNF instance completed
dhanasekaran6f0aed32022-05-17 14:12:40 +0200153
154Terminate VNF
garciadeblasf4ebaa82022-06-23 13:33:26 +0200155 [Documentation] Test case to terminate the VNF
dhanasekaran6f0aed32022-05-17 14:12:40 +0200156 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200157 ${json_path}= Read Directory
158 ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json
159 ${updated_json_obj}= Get Variable Value ${updated_json_obj['data'][3]}
160 Set Suite Variable ${updated_json_obj}
dhanasekaran6f0aed32022-05-17 14:12:40 +0200161 Post API Request ${vnf_instance_uri}/${createid}/terminate
garciadeblasf4ebaa82022-06-23 13:33:26 +0200162 ${id}= Get Value From Json ${request_response.json()} $..id
163 Set Suite Variable ${terminateid} ${id[0]}
164 Get Api Request ${vnf_instance_lcm_ops}/${terminateid}
165 ${LcmopsTerminate}= Get Value From Json ${request_response.json()} $.._id
166 Set Suite Variable ${lcmopsscaleid} ${LcmopsTerminate[0]}
167 FOR ${Index} IN RANGE 0 15
168 Get Api Request ${vnf_instance_lcm_ops}/${terminateid}
169 ${value}= Get ID operationState
170 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
171 Run Keyword If ${status} Exit For Loop
172 ... ELSE Sleep 10s
dhanasekaran6f0aed32022-05-17 14:12:40 +0200173 END
garciadeblasf4ebaa82022-06-23 13:33:26 +0200174 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Terminate VNF instance completed
dhanasekaran6f0aed32022-05-17 14:12:40 +0200175
176Delete VNF
garciadeblasf4ebaa82022-06-23 13:33:26 +0200177 [Documentation] Test case to delete VNF
dhanasekaran6f0aed32022-05-17 14:12:40 +0200178 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200179 Create Session APISession ${HOST}
180 &{Headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${AccessToken}
181 ${resp}= DELETE On Session APISession ${vnf_instance_uri}/${createid} headers=${Headers}
182 Pass Execution If ${resp.status_code} in ${success_status_code_list} Delete VNF Instance completed
dhanasekaran6f0aed32022-05-17 14:12:40 +0200183
184Delete VNF Descriptor Test
185 [Tags] cleanup
186
187 Delete VNFD ${vnfd_name}
188
garciadeblasd7f75d72022-06-25 18:38:32 +0200189
dhanasekaran6f0aed32022-05-17 14:12:40 +0200190*** Keywords ***
191Suite Cleanup
garciadeblasf4ebaa82022-06-23 13:33:26 +0200192 [Documentation] Test Suit Cleanup: Deleting Descriptor
dhanasekaran6f0aed32022-05-17 14:12:40 +0200193
194 Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name}
garciadeblasd7f75d72022-06-25 18:38:32 +0200195