blob: a238fb170a4ed95dc889d796e2cf21128ff5cdf5 [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
garciadeblas68eac4a2023-06-27 11:21:05 +020024Resource %{ROBOT_DEVOPS_FOLDER}/lib/rest_lib.robot
garciadeblasf4ebaa82022-06-23 13:33:26 +020025Resource %{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
garciadeblasfaaa0262023-06-27 12:19:31 +020030Force Tags sol003_01 cluster_osm_rest daily
garciadeblasd7f75d72022-06-25 18:38:32 +020031
32Suite Teardown Run Keyword And Ignore Error Suite Cleanup
33
34
dhanasekaran6f0aed32022-05-17 14:12:40 +020035*** Variables ***
garciadeblas68eac4a2023-06-27 11:21:05 +020036# SOL003 API URI paths
37${vnf_instance_uri} /osm/vnflcm/v1/vnf_instances
38${vnf_instantiate_uri} /osm/vnflcm/v1/vnf_instances
39${vnf_instance_lcm_ops} /osm/vnflcm/v1/vnf_lcm_op_occs
40
41# NS and VNF descriptor package folder and ids
garciadeblasf4ebaa82022-06-23 13:33:26 +020042${vnfd_pkg} hackfest_basic_metrics_vnf
43${vnfd_name} hackfest_basic_metrics-vnf
dhanasekaran6f0aed32022-05-17 14:12:40 +020044
garciadeblasd7f75d72022-06-25 18:38:32 +020045
dhanasekaran6f0aed32022-05-17 14:12:40 +020046*** Test Cases ***
47Create VNF package from JSON file descriptor
garciadeblasf4ebaa82022-06-23 13:33:26 +020048 [Documentation] Test case to create a VNF Identifier
garciadeblas43f34482023-02-23 17:37:47 +010049 Get VNFDs List
garciadeblasf4ebaa82022-06-23 13:33:26 +020050 ${id}= Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg}'
51 Set Suite Variable ${vnfid} ${id}
52 ${created_vim_account_id}= Get VIM Target ID %{VIM_TARGET}
53 Set Suite Variable ${created_vim_account_id}
dhanasekaran6f0aed32022-05-17 14:12:40 +020054 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +020055 ${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'][0]}
garciadeblas43f34482023-02-23 17:37:47 +010058 ${updated_json_obj}= JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${created_vim_account_id}
59 Log ${updated_json_obj}
60 ${updated_json_obj}= JSONLibrary.Update Value To Json ${updated_json_obj} $..additionalParams.virtual-link-desc[0][id] %{VIM_MGMT_NET}
61 Log ${updated_json_obj}
62 ${updated_json_obj}= JSONLibrary.Update Value To Json ${updated_json_obj} $..additionalParams.virtual-link-profile-id %{VIM_MGMT_NET}
63 Log ${updated_json_obj}
garciadeblasf4ebaa82022-06-23 13:33:26 +020064 Set Test Variable ${updated_json_obj}
65 Post API Request ${vnf_instance_uri}
66 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed
67 ${id}= Get Value From Json ${request_response.json()} $..id
68 Set Suite Variable ${createid} ${id[0]}
garciadeblas43f34482023-02-23 17:37:47 +010069 Get VNFDs List
dhanasekaran6f0aed32022-05-17 14:12:40 +020070
71Instantiate VNF
garciadeblasf4ebaa82022-06-23 13:33:26 +020072 [Documentation] Test case to Instantiate a VNF
garciadeblas43f34482023-02-23 17:37:47 +010073 Get Ns List
74 Get Vnf List
dhanasekaran6f0aed32022-05-17 14:12:40 +020075 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +020076 ${json_path}= Read Directory
77 ${json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json
78 ${json_obj}= Get Variable Value ${json_obj['data'][1]}
garciadeblas43f34482023-02-23 17:37:47 +010079 ${updated_json_obj}= JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${created_vim_account_id}
80 ${updated_json_obj}= JSONLibrary.Update Value To Json ${updated_json_obj} $..vnfId ${createid}
garciadeblasf4ebaa82022-06-23 13:33:26 +020081 Set Test Variable ${updated_json_obj}
82 Post API Request ${vnf_instantiate_uri}/${createid}/instantiate
83 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Instantiate VNF Instance completed
84 ${id}= Get Value From Json ${request_response.json()} $..id
85 Set Suite Variable ${instantiateid} ${id[0]}
86 Sleep 12s
garciadeblas43f34482023-02-23 17:37:47 +010087 Get Ns List
88 Get Vnf List
dhanasekaran6f0aed32022-05-17 14:12:40 +020089
90Query VNF Instances
garciadeblasf4ebaa82022-06-23 13:33:26 +020091 [Documentation] Test case to query VNF Instance
dhanasekaran6f0aed32022-05-17 14:12:40 +020092 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +020093 Get Api Request ${vnf_instance_uri}
94 ${value}= Get ID nsState
95 Should Be Equal ${value} INSTANTIATED
96 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed
97 ${id}= Get Value From Json ${request_response.json()} $.._id
98 Set Suite Variable ${Queryid} ${id[0]}
dhanasekaran6f0aed32022-05-17 14:12:40 +020099
100Query VNF Instance ID
garciadeblasf4ebaa82022-06-23 13:33:26 +0200101 [Documentation] Test case to query Vnf instance ID
dhanasekaran6f0aed32022-05-17 14:12:40 +0200102 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200103 Get Api Request ${vnf_instance_uri}/${Queryid}
104 ${value}= Get ID nsState
105 Should Be Equal ${value} INSTANTIATED
106 Should Be Equal As Strings ${RequestResponse.status_code} 200
107 ${id}= Get Value From Json ${request_response.json()} $.._id
108 Set Suite Variable ${Instanceid} ${id[0]}
dhanasekaran6f0aed32022-05-17 14:12:40 +0200109
110Query VNF LCM Ops
garciadeblasf4ebaa82022-06-23 13:33:26 +0200111 [Documentation] Test case to Query VNF LCM operation
dhanasekaran6f0aed32022-05-17 14:12:40 +0200112 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200113 Get Api Request ${vnf_instance_lcm_ops}
114 ${ID1}= Get Value From Json ${request_response.json()} $.._id
115 Set Suite Variable ${lcmops} ${ID1[0]}
116 FOR ${Index} IN RANGE 0 15
117 Get Api Request ${vnf_instance_lcm_ops}
118 ${value}= Get ID operationState
119 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
120 Run Keyword If ${status} Exit For Loop
121 ... ELSE Sleep 10s
dhanasekaran6f0aed32022-05-17 14:12:40 +0200122 END
123
124Query VNF LCM Ops ID
125 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200126 Get Api Request ${vnf_instance_lcm_ops}/${lcmops}
127 ${ID1}= Get Value From Json ${request_response.json()} $.._id
128 Set Suite Variable ${lcmopsid} ${ID1[0]}
129 FOR ${Index} IN RANGE 0 15
130 Get Api Request ${vnf_instance_lcm_ops}/${lcmops}
131 ${value}= Get ID operationState
132 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
133 Run Keyword If ${status} Exit For Loop
134 ... ELSE Sleep 10s
dhanasekaran6f0aed32022-05-17 14:12:40 +0200135 END
136
137Scale VNF
garciadeblasf4ebaa82022-06-23 13:33:26 +0200138 [Documentation] Test case to Scale out VNF
dhanasekaran6f0aed32022-05-17 14:12:40 +0200139 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200140 ${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'][2]}
143 Set Test Variable ${updated_json_obj}
144 Post API Request ${vnf_instance_uri}/${createid}/scale
145 ${value}= Get ID id
146 ${ID1}= Get Value From Json ${request_response.json()} $..id
147 Set Suite Variable ${scaleoutid} ${ID1[0]}
148 Get Api Request ${vnf_instance_lcm_ops}/${scaleoutid}
149 ${LcmopsScale}= Get Value From Json ${request_response.json()} $.._id
150 Set Suite Variable ${lcmopsscaleid} ${LcmopsScale[0]}
151 FOR ${Index} IN RANGE 0 15
152 Get Api Request ${vnf_instance_lcm_ops}/${scaleoutid}
153 ${value}= Get ID operationState
154 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
155 Run Keyword If ${status} Exit For Loop
156 ... ELSE Sleep 10s
dhanasekaran6f0aed32022-05-17 14:12:40 +0200157 END
garciadeblasf4ebaa82022-06-23 13:33:26 +0200158 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Scale VNF instance completed
dhanasekaran6f0aed32022-05-17 14:12:40 +0200159
160Terminate VNF
garciadeblasf4ebaa82022-06-23 13:33:26 +0200161 [Documentation] Test case to terminate the VNF
dhanasekaran6f0aed32022-05-17 14:12:40 +0200162 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200163 ${json_path}= Read Directory
164 ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json
165 ${updated_json_obj}= Get Variable Value ${updated_json_obj['data'][3]}
166 Set Suite Variable ${updated_json_obj}
dhanasekaran6f0aed32022-05-17 14:12:40 +0200167 Post API Request ${vnf_instance_uri}/${createid}/terminate
garciadeblasf4ebaa82022-06-23 13:33:26 +0200168 ${id}= Get Value From Json ${request_response.json()} $..id
169 Set Suite Variable ${terminateid} ${id[0]}
170 Get Api Request ${vnf_instance_lcm_ops}/${terminateid}
171 ${LcmopsTerminate}= Get Value From Json ${request_response.json()} $.._id
172 Set Suite Variable ${lcmopsscaleid} ${LcmopsTerminate[0]}
173 FOR ${Index} IN RANGE 0 15
174 Get Api Request ${vnf_instance_lcm_ops}/${terminateid}
175 ${value}= Get ID operationState
176 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
177 Run Keyword If ${status} Exit For Loop
178 ... ELSE Sleep 10s
dhanasekaran6f0aed32022-05-17 14:12:40 +0200179 END
garciadeblasf4ebaa82022-06-23 13:33:26 +0200180 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Terminate VNF instance completed
dhanasekaran6f0aed32022-05-17 14:12:40 +0200181
182Delete VNF
garciadeblasf4ebaa82022-06-23 13:33:26 +0200183 [Documentation] Test case to delete VNF
dhanasekaran6f0aed32022-05-17 14:12:40 +0200184 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200185 Create Session APISession ${HOST}
186 &{Headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${AccessToken}
187 ${resp}= DELETE On Session APISession ${vnf_instance_uri}/${createid} headers=${Headers}
188 Pass Execution If ${resp.status_code} in ${success_status_code_list} Delete VNF Instance completed
dhanasekaran6f0aed32022-05-17 14:12:40 +0200189
190Delete VNF Descriptor Test
191 [Tags] cleanup
192
193 Delete VNFD ${vnfd_name}
194
garciadeblasd7f75d72022-06-25 18:38:32 +0200195
dhanasekaran6f0aed32022-05-17 14:12:40 +0200196*** Keywords ***
197Suite Cleanup
garciadeblasf4ebaa82022-06-23 13:33:26 +0200198 [Documentation] Test Suit Cleanup: Deleting Descriptor
dhanasekaran6f0aed32022-05-17 14:12:40 +0200199
200 Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name}
garciadeblasd7f75d72022-06-25 18:38:32 +0200201