blob: 32194d81e6a8701e6ad076d367203169b318d7e5 [file] [log] [blame]
garciadeblas7a9e0312023-12-11 22:24:46 +01001*** Comments ***
rarikbbae1a72023-11-20 22:58:32 +05302# 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
rarikbbae1a72023-11-20 22:58:32 +053015*** Settings ***
garciadeblas7a9e0312023-12-11 22:24:46 +010016Documentation [Sol003-02] Sol003 Dual Stack IP in VNFM NB interface
rarikbbae1a72023-11-20 22:58:32 +053017
18Library OperatingSystem
19Library String
20Library Collections
21Library RequestsLibrary
22Library yaml
23Library JsonValidator
24Library JSONLibrary
25
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
sritharan9e5450f2023-12-26 07:04:44 +000031Resource ../lib/nsd_lib.resource
rarikbbae1a72023-11-20 22:58:32 +053032
garciadeblas4f3854b2025-07-16 16:50:20 +020033Test Tags sol003_02 cluster_sol003 daily
rarikbbae1a72023-11-20 22:58:32 +053034
garciadeblas4f3854b2025-07-16 16:50:20 +020035Suite Setup Run Keyword And Ignore Error Suite Preparation
rarikbbae1a72023-11-20 22:58:32 +053036Suite Teardown Run Keyword And Ignore Error Suite Cleanup
37
38
39*** Variables ***
40# SOL003 API URI paths
garciadeblas7a9e0312023-12-11 22:24:46 +010041${VNF_INSTANCE_URI} /osm/vnflcm/v1/vnf_instances
42${VNF_INSTANCE_LCM_OPS} /osm/vnflcm/v1/vnf_lcm_op_occs
rarikbbae1a72023-11-20 22:58:32 +053043
44# NS and VNF descriptor package folder and ids
garciadeblas7a9e0312023-12-11 22:24:46 +010045${VNFD_PKG} hackfest_basic_vnf
46${VNFD_NAME} hackfest_basic-vnf
rarikbbae1a72023-11-20 22:58:32 +053047
48
49*** Test Cases ***
rarikbbae1a72023-11-20 22:58:32 +053050Create VNFD Descriptor
51 [Documentation] Test case to create a VNF Identifier
garciadeblas7a9e0312023-12-11 22:24:46 +010052 ${VNFD_ID}= Create VNFD %{PACKAGES_FOLDER}/${VNFD_PKG}
53 Set Suite Variable ${VNFD_ID}
54 ${CREATED_VIM_ACCOUNT_ID}= Get VIM Target ID %{VIM_TARGET}
55 Set Suite Variable ${CREATED_VIM_ACCOUNT_ID}
rarikbbae1a72023-11-20 22:58:32 +053056 Get Auth Token
garciadeblas4f3854b2025-07-16 16:50:20 +020057 ${json_obj}= Load JSON From File ${RESOURCE_DIR}/sol003_02-dualstack_ip_vnfm.json
rarikbbae1a72023-11-20 22:58:32 +053058 ${json_obj}= Get Variable Value ${json_obj['data'][0]}
garciadeblas7a9e0312023-12-11 22:24:46 +010059 ${NS_NAME}= Get Variable Value ${json_obj['vnfInstanceName']}
60 Set Suite Variable ${NS_NAME}
garciadeblas7a9e0312023-12-11 22:24:46 +010061 ${UPDATED_JSON_OBJ}= JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${CREATED_VIM_ACCOUNT_ID}
62 Log ${UPDATED_JSON_OBJ}
63 ${UPDATED_JSON_OBJ}= JSONLibrary.Update Value To Json ${UPDATED_JSON_OBJ} $..additionalParams.virtual-link-desc[0][id] %{VIM_MGMT_NET}
64 Log ${UPDATED_JSON_OBJ}
65 ${UPDATED_JSON_OBJ}= JSONLibrary.Update Value To Json ${UPDATED_JSON_OBJ} $..additionalParams.virtual-link-profile-id %{VIM_MGMT_NET}
66 Log ${UPDATED_JSON_OBJ}
67 Set Test Variable ${UPDATED_JSON_OBJ}
68 Post Api Request ${VNF_INSTANCE_URI} ${UPDATED_JSON_OBJ}
rarikbbae1a72023-11-20 22:58:32 +053069 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed
70 ${id}= Get Value From Json ${request_response.json()} $..id
garciadeblas7a9e0312023-12-11 22:24:46 +010071 Set Suite Variable ${CREATEID} ${id[0]}
rarikbbae1a72023-11-20 22:58:32 +053072 Get VNFDs List
73
74Instantiate VNF
75 [Documentation] Test case to Instantiate a VNF
76 Get Ns List
77 Get Vnf List
78 Get Auth Token
garciadeblas4f3854b2025-07-16 16:50:20 +020079 ${json_obj}= Load JSON From File ${RESOURCE_DIR}/sol003_02-dualstack_ip_vnfm.json
rarikbbae1a72023-11-20 22:58:32 +053080 ${json_obj}= Get Variable Value ${json_obj['data'][1]}
garciadeblas7a9e0312023-12-11 22:24:46 +010081 ${UPDATED_JSON_OBJ}= JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${CREATED_VIM_ACCOUNT_ID}
82 ${UPDATED_JSON_OBJ}= JSONLibrary.Update Value To Json ${UPDATED_JSON_OBJ} $..vnfId ${CREATEID}
83 Set Test Variable ${UPDATED_JSON_OBJ}
84 Post Api Request ${VNF_INSTANCE_URI}/${CREATEID}/instantiate ${UPDATED_JSON_OBJ}
rarikbbae1a72023-11-20 22:58:32 +053085 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Instantiate VNF Instance completed
86 ${id}= Get Value From Json ${request_response.json()} $..id
garciadeblas7a9e0312023-12-11 22:24:46 +010087 Set Suite Variable ${VNF_INSTANCE_ID} ${id[0]}
rarikbbae1a72023-11-20 22:58:32 +053088 Sleep 12s
sritharan9e5450f2023-12-26 07:04:44 +000089 Check For NS Instance For Failure ${ns_name}
rarikbbae1a72023-11-20 22:58:32 +053090 Get Ns List
91 Get Vnf List
92
93Get Ns Id
sritharan9e5450f2023-12-26 07:04:44 +000094 [Documentation] Get the NS instance id
rarikbbae1a72023-11-20 22:58:32 +053095 ${id}= Get Ns Id ${ns_name}
garciadeblas7a9e0312023-12-11 22:24:46 +010096 Set Suite Variable ${NS_ID} ${id}
rarikbbae1a72023-11-20 22:58:32 +053097
sritharan9e5450f2023-12-26 07:04:44 +000098Get Ip From The NSD
99 [Documentation] Get the IP address from the NSD
100 ${id}= Get NSD ID From The NS ${NS_ID}
101 Set Suite Variable ${NSD_ID} ${id}
102 ${Nsd_IP}= Get NSD Ip ${NSD_ID}
103 Log ${Nsd_IP}
104 ${Nsd_IP}= Split String ${Nsd_IP}
105 Set Suite Variable ${IPV6NSD} ${Nsd_IP}[0]
106 Set Suite Variable ${IPV4NSD} ${Nsd_IP}[1]
107 Log ${IPV4NSD}
108 Log ${IPV6NSD}
109
110Get Dual Ip
garciadeblas7a9e0312023-12-11 22:24:46 +0100111 [Documentation] Get the IP address from the NS
sritharan9e5450f2023-12-26 07:04:44 +0000112 ${Ns_IP}= Get Dual Ip ${NS_ID}
113 Log ${Ns_IP}
114 ${Ns_IP}= Split String ${Ns_IP}
115 Set Suite Variable ${IPV6NS} ${Ns_IP}[0]
116 Set Suite Variable ${IPV4NS} ${Ns_IP}[1]
117 Log ${IPV4NS}
118 Log ${IPV6NS}
rarikbbae1a72023-11-20 22:58:32 +0530119
120Verify Dual Ip
sritharan9e5450f2023-12-26 07:04:44 +0000121 [Documentation] Test case to validate the IP address.
122 Should Be Equal ${IPV4NS} ${IPV4NSD}
123 Should Be Equal ${IPV6NS} ${IPV6NSD}
rarikbbae1a72023-11-20 22:58:32 +0530124
125Terminate VNF
126 [Documentation] Test case to terminate the VNF
127 Get Auth Token
garciadeblas4f3854b2025-07-16 16:50:20 +0200128 ${UPDATED_JSON_OBJ}= Load JSON From File ${RESOURCE_DIR}/sol003_02-dualstack_ip_vnfm.json
garciadeblas7a9e0312023-12-11 22:24:46 +0100129 ${UPDATED_JSON_OBJ}= Get Variable Value ${UPDATED_JSON_OBJ['data'][3]}
130 Set Suite Variable ${UPDATED_JSON_OBJ}
131 Post Api Request ${VNF_INSTANCE_URI}/${CREATEID}/terminate ${UPDATED_JSON_OBJ}
rarikbbae1a72023-11-20 22:58:32 +0530132 ${id}= Get Value From Json ${request_response.json()} $..id
garciadeblas7a9e0312023-12-11 22:24:46 +0100133 ${terminateid}= Set Variable ${id[0]}
134 Get Api Request ${VNF_INSTANCE_LCM_OPS}/${terminateid}
rarikbbae1a72023-11-20 22:58:32 +0530135 ${LcmopsTerminate}= Get Value From Json ${request_response.json()} $.._id
garciadeblas7a9e0312023-12-11 22:24:46 +0100136 Log ${LcmopsTerminate[0]}
137 FOR ${index} IN RANGE 0 15
138 Log ${index}
139 Get Api Request ${VNF_INSTANCE_LCM_OPS}/${terminateid}
rarikbbae1a72023-11-20 22:58:32 +0530140 ${value}= Get ID operationState
141 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
garciadeblas7a9e0312023-12-11 22:24:46 +0100142 IF ${status}
143 BREAK
144 ELSE
145 Sleep 10s
146 END
rarikbbae1a72023-11-20 22:58:32 +0530147 END
148 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Terminate VNF instance completed
149
150Delete VNF
151 [Documentation] Test case to delete VNF
152 Get Auth Token
garciadeblas7a9e0312023-12-11 22:24:46 +0100153 Create Session APISession ${REST_API_HOST}
154 &{Headers}= Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${AccessToken}
155 ${resp}= DELETE On Session APISession ${VNF_INSTANCE_URI}/${CREATEID} headers=${Headers}
rarikbbae1a72023-11-20 22:58:32 +0530156 Pass Execution If ${resp.status_code} in ${success_status_code_list} Delete VNF Instance completed
157
158Delete VNF Descriptor Test
sritharan9e5450f2023-12-26 07:04:44 +0000159 [Documentation] Test case to delete the VNF descriptor.
rarikbbae1a72023-11-20 22:58:32 +0530160 [Tags] cleanup
garciadeblas7a9e0312023-12-11 22:24:46 +0100161 Delete VNFD ${VNFD_NAME}
rarikbbae1a72023-11-20 22:58:32 +0530162
163
164*** Keywords ***
garciadeblas4f3854b2025-07-16 16:50:20 +0200165Suite Preparation
garciadeblasfb26ba22025-07-16 18:08:45 +0200166 [Documentation] Set Testsuite Variables
garciadeblas4f3854b2025-07-16 16:50:20 +0200167 ${RESOURCE_DIR}= Get Resource Directory
168 Set Suite Variable ${RESOURCE_DIR}
169
rarikbbae1a72023-11-20 22:58:32 +0530170Suite Cleanup
171 [Documentation] Test Suit Cleanup: Deleting Descriptor
garciadeblas7a9e0312023-12-11 22:24:46 +0100172 Run Keyword If Any Tests Failed Delete VNFD ${VNFD_NAME}