blob: 6e8454175a223cfaba671448b3d9e853eb076a93 [file] [log] [blame]
garciadeblas7a9e0312023-12-11 22:24:46 +01001*** Comments ***
dhanasekaran6f0aed32022-05-17 14:12:40 +02002# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License
13
garciadeblas7a9e0312023-12-11 22:24:46 +010014
dhanasekaran6f0aed32022-05-17 14:12:40 +020015*** Settings ***
garciadeblasf4ebaa82022-06-23 13:33:26 +020016Documentation [SOL003-01] Sol003 Api testing
garciadeblasd7f75d72022-06-25 18:38:32 +020017
garciadeblasf4ebaa82022-06-23 13:33:26 +020018Library OperatingSystem
19Library String
20Library Collections
21Library RequestsLibrary
22Library yaml
23Library JsonValidator
24Library JSONLibrary
garciadeblasd7f75d72022-06-25 18:38:32 +020025
garciadeblas7a9e0312023-12-11 22:24:46 +010026Resource ../lib/rest_lib.resource
27Resource ../lib/vnfd_lib.resource
28Resource ../lib/ns_lib.resource
29Resource ../lib/vnf_lib.resource
30Resource ../lib/vim_lib.resource
dhanasekaran6f0aed32022-05-17 14:12:40 +020031
garciadeblas166c8912023-12-16 10:51:48 +010032Test Tags sol003_01 cluster_osm_rest daily regression
garciadeblasd7f75d72022-06-25 18:38:32 +020033
34Suite Teardown Run Keyword And Ignore Error Suite Cleanup
35
36
dhanasekaran6f0aed32022-05-17 14:12:40 +020037*** Variables ***
garciadeblas68eac4a2023-06-27 11:21:05 +020038# SOL003 API URI paths
garciadeblas7a9e0312023-12-11 22:24:46 +010039${VNF_INSTANCE_URI} /osm/vnflcm/v1/vnf_instances
40${VNF_INSTANCE_LCM_OPS} /osm/vnflcm/v1/vnf_lcm_op_occs
garciadeblas68eac4a2023-06-27 11:21:05 +020041
42# NS and VNF descriptor package folder and ids
garciadeblas7a9e0312023-12-11 22:24:46 +010043${VNFD_PKG} hackfest_basic_metrics_vnf
44${VNFD_NAME} hackfest_basic_metrics-vnf
dhanasekaran6f0aed32022-05-17 14:12:40 +020045
garciadeblasd7f75d72022-06-25 18:38:32 +020046
dhanasekaran6f0aed32022-05-17 14:12:40 +020047*** Test Cases ***
garciadeblas7a9e0312023-12-11 22:24:46 +010048Create VNF Package From JSON File
49 [Documentation] Create a VNF package and update it via SOL003 interface using a JSON file
garciadeblas43f34482023-02-23 17:37:47 +010050 Get VNFDs List
garciadeblas7a9e0312023-12-11 22:24:46 +010051 ${id}= Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG}'
52 Log ${id}
53 ${CREATED_VIM_ACCOUNT_ID}= Get VIM Target ID %{VIM_TARGET}
54 Set Suite Variable ${CREATED_VIM_ACCOUNT_ID}
dhanasekaran6f0aed32022-05-17 14:12:40 +020055 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +020056 ${json_path}= Read Directory
57 ${json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json
58 ${json_obj}= Get Variable Value ${json_obj['data'][0]}
garciadeblas7a9e0312023-12-11 22:24:46 +010059 ${UPDATED_JSON_OBJ}= JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${CREATED_VIM_ACCOUNT_ID}
60 Log ${UPDATED_JSON_OBJ}
61 ${UPDATED_JSON_OBJ}= JSONLibrary.Update Value To Json ${UPDATED_JSON_OBJ} $..additionalParams.virtual-link-desc[0][id] %{VIM_MGMT_NET}
62 Log ${UPDATED_JSON_OBJ}
63 ${UPDATED_JSON_OBJ}= JSONLibrary.Update Value To Json ${UPDATED_JSON_OBJ} $..additionalParams.virtual-link-profile-id %{VIM_MGMT_NET}
64 Log ${UPDATED_JSON_OBJ}
65 Set Test Variable ${UPDATED_JSON_OBJ}
66 Post Api Request ${VNF_INSTANCE_URI} ${UPDATED_JSON_OBJ}
67 Pass Execution If ${request_response.status_code} in ${SUCCESS_STATUS_CODE_LIST} Query VNF Instance completed
garciadeblasf4ebaa82022-06-23 13:33:26 +020068 ${id}= Get Value From Json ${request_response.json()} $..id
garciadeblas7a9e0312023-12-11 22:24:46 +010069 Set Suite Variable ${CREATEID} ${id[0]}
garciadeblas43f34482023-02-23 17:37:47 +010070 Get VNFDs List
dhanasekaran6f0aed32022-05-17 14:12:40 +020071
72Instantiate VNF
garciadeblasf4ebaa82022-06-23 13:33:26 +020073 [Documentation] Test case to Instantiate a VNF
garciadeblas43f34482023-02-23 17:37:47 +010074 Get Ns List
75 Get Vnf List
dhanasekaran6f0aed32022-05-17 14:12:40 +020076 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +020077 ${json_path}= Read Directory
78 ${json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json
79 ${json_obj}= Get Variable Value ${json_obj['data'][1]}
garciadeblas7a9e0312023-12-11 22:24:46 +010080 ${UPDATED_JSON_OBJ}= JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${CREATED_VIM_ACCOUNT_ID}
81 ${UPDATED_JSON_OBJ}= JSONLibrary.Update Value To Json ${UPDATED_JSON_OBJ} $..vnfId ${CREATEID}
82 Set Test Variable ${UPDATED_JSON_OBJ}
83 Post Api Request ${VNF_INSTANCE_URI}/${CREATEID}/instantiate ${UPDATED_JSON_OBJ}
84 Pass Execution If ${request_response.status_code} in ${SUCCESS_STATUS_CODE_LIST} Instantiate VNF Instance completed
garciadeblasf4ebaa82022-06-23 13:33:26 +020085 ${id}= Get Value From Json ${request_response.json()} $..id
garciadeblas7a9e0312023-12-11 22:24:46 +010086 Set Suite Variable ${INSTANTIATEID} ${id[0]}
garciadeblasf4ebaa82022-06-23 13:33:26 +020087 Sleep 12s
garciadeblas43f34482023-02-23 17:37:47 +010088 Get Ns List
89 Get Vnf List
dhanasekaran6f0aed32022-05-17 14:12:40 +020090
91Query VNF Instances
garciadeblasf4ebaa82022-06-23 13:33:26 +020092 [Documentation] Test case to query VNF Instance
dhanasekaran6f0aed32022-05-17 14:12:40 +020093 Get Auth Token
garciadeblas7a9e0312023-12-11 22:24:46 +010094 Get Api Request ${VNF_INSTANCE_URI}
garciadeblasf4ebaa82022-06-23 13:33:26 +020095 ${value}= Get ID nsState
96 Should Be Equal ${value} INSTANTIATED
garciadeblas7a9e0312023-12-11 22:24:46 +010097 Pass Execution If ${request_response.status_code} in ${SUCCESS_STATUS_CODE_LIST} Query VNF Instance completed
garciadeblasf4ebaa82022-06-23 13:33:26 +020098 ${id}= Get Value From Json ${request_response.json()} $.._id
garciadeblas7a9e0312023-12-11 22:24:46 +010099 Set Suite Variable ${QUERYID} ${id[0]}
dhanasekaran6f0aed32022-05-17 14:12:40 +0200100
101Query VNF Instance ID
garciadeblasf4ebaa82022-06-23 13:33:26 +0200102 [Documentation] Test case to query Vnf instance ID
dhanasekaran6f0aed32022-05-17 14:12:40 +0200103 Get Auth Token
garciadeblas7a9e0312023-12-11 22:24:46 +0100104 Get Api Request ${VNF_INSTANCE_URI}/${QUERYID}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200105 ${value}= Get ID nsState
106 Should Be Equal ${value} INSTANTIATED
107 Should Be Equal As Strings ${RequestResponse.status_code} 200
108 ${id}= Get Value From Json ${request_response.json()} $.._id
garciadeblas7a9e0312023-12-11 22:24:46 +0100109 Set Suite Variable ${INSTANCEID} ${id[0]}
dhanasekaran6f0aed32022-05-17 14:12:40 +0200110
111Query VNF LCM Ops
garciadeblasf4ebaa82022-06-23 13:33:26 +0200112 [Documentation] Test case to Query VNF LCM operation
dhanasekaran6f0aed32022-05-17 14:12:40 +0200113 Get Auth Token
garciadeblas7a9e0312023-12-11 22:24:46 +0100114 Get Api Request ${VNF_INSTANCE_LCM_OPS}
115 ${id1}= Get Value From Json ${request_response.json()} $.._id
116 Set Suite Variable ${LCMOPS} ${id1[0]}
117 FOR ${index} IN RANGE 0 15
118 Log ${index}
119 Get Api Request ${VNF_INSTANCE_LCM_OPS}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200120 ${value}= Get ID operationState
121 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
garciadeblas7a9e0312023-12-11 22:24:46 +0100122 IF ${status}
123 BREAK
124 ELSE
125 Sleep 10s
126 END
dhanasekaran6f0aed32022-05-17 14:12:40 +0200127 END
128
129Query VNF LCM Ops ID
garciadeblas7a9e0312023-12-11 22:24:46 +0100130 [Documentation] Check if the operation has completed.
dhanasekaran6f0aed32022-05-17 14:12:40 +0200131 Get Auth Token
garciadeblas7a9e0312023-12-11 22:24:46 +0100132 Get Api Request ${VNF_INSTANCE_LCM_OPS}/${LCMOPS}
133 ${id1}= Get Value From Json ${request_response.json()} $.._id
134 Set Suite Variable ${LCMOPSID} ${id1[0]}
135 FOR ${index} IN RANGE 0 15
136 Log ${index}
137 Get Api Request ${VNF_INSTANCE_LCM_OPS}/${LCMOPS}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200138 ${value}= Get ID operationState
139 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
garciadeblas7a9e0312023-12-11 22:24:46 +0100140 IF ${status}
141 BREAK
142 ELSE
143 Sleep 10s
144 END
dhanasekaran6f0aed32022-05-17 14:12:40 +0200145 END
146
147Scale VNF
garciadeblas7a9e0312023-12-11 22:24:46 +0100148 [Documentation] Scale out VNF
dhanasekaran6f0aed32022-05-17 14:12:40 +0200149 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200150 ${json_path}= Read Directory
151 ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json
garciadeblas7a9e0312023-12-11 22:24:46 +0100152 ${updated_json_obj}= Get Variable Value ${UPDATED_JSON_OBJ['data'][2]}
153 Set Test Variable ${UPDATED_JSON_OBJ}
154 Post Api Request ${VNF_INSTANCE_URI}/${CREATEID}/scale ${UPDATED_JSON_OBJ}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200155 ${value}= Get ID id
garciadeblas7a9e0312023-12-11 22:24:46 +0100156 ${id1}= Get Value From Json ${request_response.json()} $..id
157 Set Suite Variable ${SCALEOUTID} ${id1[0]}
158 Get Api Request ${VNF_INSTANCE_LCM_OPS}/${SCALEOUTID}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200159 ${LcmopsScale}= Get Value From Json ${request_response.json()} $.._id
garciadeblas7a9e0312023-12-11 22:24:46 +0100160 Set Suite Variable ${LCMOPSSCALEID} ${LcmopsScale[0]}
161 FOR ${index} IN RANGE 0 15
162 Log ${index}
163 Get Api Request ${VNF_INSTANCE_LCM_OPS}/${SCALEOUTID}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200164 ${value}= Get ID operationState
165 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
garciadeblas7a9e0312023-12-11 22:24:46 +0100166 IF ${status}
167 BREAK
168 ELSE
169 Sleep 10s
170 END
dhanasekaran6f0aed32022-05-17 14:12:40 +0200171 END
garciadeblas7a9e0312023-12-11 22:24:46 +0100172 Pass Execution If ${request_response.status_code} in ${SUCCESS_STATUS_CODE_LIST} Scale VNF instance completed
dhanasekaran6f0aed32022-05-17 14:12:40 +0200173
174Terminate VNF
garciadeblasf4ebaa82022-06-23 13:33:26 +0200175 [Documentation] Test case to terminate the VNF
dhanasekaran6f0aed32022-05-17 14:12:40 +0200176 Get Auth Token
garciadeblasf4ebaa82022-06-23 13:33:26 +0200177 ${json_path}= Read Directory
178 ${updated_json_obj}= Load JSON From File ${json_path}/sol003_01-vnf-lifecycle-management.json
garciadeblas7a9e0312023-12-11 22:24:46 +0100179 ${updated_json_obj}= Get Variable Value ${UPDATED_JSON_OBJ['data'][3]}
180 Set Suite Variable ${UPDATED_JSON_OBJ}
181 Post Api Request ${VNF_INSTANCE_URI}/${CREATEID}/terminate ${UPDATED_JSON_OBJ}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200182 ${id}= Get Value From Json ${request_response.json()} $..id
garciadeblas7a9e0312023-12-11 22:24:46 +0100183 Set Suite Variable ${TERMINATEID} ${id[0]}
184 Get Api Request ${VNF_INSTANCE_LCM_OPS}/${TERMINATEID}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200185 ${LcmopsTerminate}= Get Value From Json ${request_response.json()} $.._id
garciadeblas7a9e0312023-12-11 22:24:46 +0100186 Set Suite Variable ${LCMOPSSCALEID} ${LcmopsTerminate[0]}
187 FOR ${index} IN RANGE 0 15
188 Log ${index}
189 Get Api Request ${VNF_INSTANCE_LCM_OPS}/${TERMINATEID}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200190 ${value}= Get ID operationState
191 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
garciadeblas7a9e0312023-12-11 22:24:46 +0100192 IF ${status}
193 BREAK
194 ELSE
195 Sleep 10s
196 END
dhanasekaran6f0aed32022-05-17 14:12:40 +0200197 END
garciadeblas7a9e0312023-12-11 22:24:46 +0100198 Pass Execution If ${request_response.status_code} in ${SUCCESS_STATUS_CODE_LIST} Terminate VNF instance completed
dhanasekaran6f0aed32022-05-17 14:12:40 +0200199
200Delete VNF
garciadeblas7a9e0312023-12-11 22:24:46 +0100201 [Documentation] Delete VNF instance.
dhanasekaran6f0aed32022-05-17 14:12:40 +0200202 Get Auth Token
garciadeblas7a9e0312023-12-11 22:24:46 +0100203 Create Session APISession ${REST_API_HOST}
204 &{Headers}= Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${ACCESS_TOKEN}
205 ${resp}= DELETE On Session APISession ${VNF_INSTANCE_URI}/${CREATEID} headers=${Headers}
206 Pass Execution If ${resp.status_code} in ${SUCCESS_STATUS_CODE_LIST} Delete VNF Instance completed
dhanasekaran6f0aed32022-05-17 14:12:40 +0200207
208Delete VNF Descriptor Test
garciadeblas7a9e0312023-12-11 22:24:46 +0100209 [Documentation] Delete VNF package from OSM.
dhanasekaran6f0aed32022-05-17 14:12:40 +0200210 [Tags] cleanup
garciadeblas7a9e0312023-12-11 22:24:46 +0100211 Delete VNFD ${VNFD_NAME}
dhanasekaran6f0aed32022-05-17 14:12:40 +0200212
garciadeblasd7f75d72022-06-25 18:38:32 +0200213
dhanasekaran6f0aed32022-05-17 14:12:40 +0200214*** Keywords ***
215Suite Cleanup
garciadeblasf4ebaa82022-06-23 13:33:26 +0200216 [Documentation] Test Suit Cleanup: Deleting Descriptor
garciadeblas7a9e0312023-12-11 22:24:46 +0100217 Run Keyword If Any Tests Failed Delete VNFD ${VNFD_NAME}