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
5 # http://www.apache.org/licenses/LICENSE-2.0
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
14 Documentation Sol003-02 Sol003 This script launches dual-stack IP addresses NS in VIM and verify the dualstack ip
16 Library OperatingSystem
19 Library RequestsLibrary
24 Resource %{ROBOT_DEVOPS_FOLDER}/lib/rest_lib.robot
25 Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
26 Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
27 Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnf_lib.robot
28 Resource %{ROBOT_DEVOPS_FOLDER}/lib/vim_lib.robot
30 Force Tags sol003_02 cluster_osm_rest daily
32 Suite Teardown Run Keyword And Ignore Error Suite Cleanup
36 # 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
41 # NS and VNF descriptor package folder and ids
42 ${vnfd_pkg} hackfest_basic_vnf
43 ${vnfd_name} hackfest_basic-vnf
48 Create VNFD Descriptor
49 [Documentation] Test case to create a VNF Identifier
50 ${vnfd_id}= Create VNFD %{PACKAGES_FOLDER}/${vnfd_pkg}
51 Set Suite Variable ${vnfd_id}
52 ${created_vim_account_id}= Get VIM Target ID %{VIM_TARGET}
53 Set Suite Variable ${created_vim_account_id}
55 ${json_path}= Read Directory
56 ${json_obj}= Load JSON From File ${json_path}/sol003_DualStackip.json
57 ${json_obj}= Get Variable Value ${json_obj['data'][0]}
58 ${ns_name}= Get Variable Value ${json_obj['vnfInstanceName']}
59 Set Suite Variable ${ns_name}
60 ${Value1}= Get Variable Value ${json_obj['additionalParams']['ip-address']}
61 Set Suite Variable ${Value1}
62 ${updated_json_obj}= JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${created_vim_account_id}
63 Log ${updated_json_obj}
64 ${updated_json_obj}= JSONLibrary.Update Value To Json ${updated_json_obj} $..additionalParams.virtual-link-desc[0][id] %{VIM_MGMT_NET}
65 Log ${updated_json_obj}
66 ${updated_json_obj}= JSONLibrary.Update Value To Json ${updated_json_obj} $..additionalParams.virtual-link-profile-id %{VIM_MGMT_NET}
67 Log ${updated_json_obj}
68 Set Test Variable ${updated_json_obj}
69 Post API Request ${vnf_instance_uri}
70 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed
71 ${id}= Get Value From Json ${request_response.json()} $..id
72 Set Suite Variable ${createid} ${id[0]}
76 [Documentation] Test case to Instantiate a VNF
80 ${json_path}= Read Directory
81 ${json_obj}= Load JSON From File ${json_path}/sol003_DualStackip.json
82 ${json_obj}= Get Variable Value ${json_obj['data'][1]}
83 ${updated_json_obj}= JSONLibrary.Update Value To Json ${json_obj} $..vimAccountId ${created_vim_account_id}
84 ${updated_json_obj}= JSONLibrary.Update Value To Json ${updated_json_obj} $..vnfId ${createid}
85 Set Test Variable ${updated_json_obj}
86 Post API Request ${vnf_instantiate_uri}/${createid}/instantiate
87 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Instantiate VNF Instance completed
88 ${id}= Get Value From Json ${request_response.json()} $..id
89 Set Suite Variable ${instantiateid} ${id[0]}
95 [Documentation] Get the ns id from the ns list
96 ${id}= Get Ns Id ${ns_name}
97 Set Suite Variable ${ns_id} ${id}
100 [Documentation] Get the ip from the ns list
101 ${id}= Get Dual Ip ${ns_id}
102 Set Suite Variable ${ip} ${id}
105 [Documentation] Test case to query VNF Instance
107 Get Api Request ${vnf_instance_uri}
108 ${value}= Get ID nsState
109 Should Be Equal ${value} INSTANTIATED
110 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Query VNF Instance completed
111 ${id}= Get Value From Json ${request_response.json()} $.._id
112 Set Suite Variable ${Queryid} ${id[0]}
114 Query VNF Instance ID
115 [Documentation] Test case to query Vnf instance ID
117 Get Api Request ${vnf_instance_uri}/${Queryid}
118 ${value}= Get ID nsState
119 Should Be Equal ${value} INSTANTIATED
120 Should Be Equal As Strings ${RequestResponse.status_code} 200
121 ${id}= Get Value From Json ${request_response.json()} $.._id
122 Set Suite Variable ${Instanceid} ${id[0]}
125 [Documentation] Test case to Query VNF LCM operation
127 Get Api Request ${vnf_instance_lcm_ops}
128 ${ID1}= Get Value From Json ${request_response.json()} $.._id
129 Set Suite Variable ${lcmops} ${ID1[0]}
130 FOR ${Index} IN RANGE 0 15
131 Get Api Request ${vnf_instance_lcm_ops}
132 ${value}= Get ID operationState
133 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
134 Run Keyword If ${status} Exit For Loop
139 [Documentation] Test case to Query VNF LCM operation id
141 Get Api Request ${vnf_instance_lcm_ops}/${lcmops}
142 ${ID1}= Get Value From Json ${request_response.json()} $.._id
143 Set Suite Variable ${lcmopsid} ${ID1[0]}
144 FOR ${Index} IN RANGE 0 15
145 Get Api Request ${vnf_instance_lcm_ops}/${lcmops}
146 ${value}= Get ID operationState
147 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
148 Run Keyword If ${status} Exit For Loop
153 Should Be Equal ${ip} ${Value1}
157 [Documentation] Test case to terminate the VNF
159 ${json_path}= Read Directory
160 ${updated_json_obj}= Load JSON From File ${json_path}/sol003_DualStackip.json
161 ${updated_json_obj}= Get Variable Value ${updated_json_obj['data'][3]}
162 Set Suite Variable ${updated_json_obj}
163 Post API Request ${vnf_instance_uri}/${createid}/terminate
164 ${id}= Get Value From Json ${request_response.json()} $..id
165 Set Suite Variable ${terminateid} ${id[0]}
166 Get Api Request ${vnf_instance_lcm_ops}/${terminateid}
167 ${LcmopsTerminate}= Get Value From Json ${request_response.json()} $.._id
168 Set Suite Variable ${lcmopsscaleid} ${LcmopsTerminate[0]}
169 FOR ${Index} IN RANGE 0 15
170 Get Api Request ${vnf_instance_lcm_ops}/${terminateid}
171 ${value}= Get ID operationState
172 ${status}= Run Keyword And Return Status Should Be Equal ${value} COMPLETED
173 Run Keyword If ${status} Exit For Loop
176 Pass Execution If ${request_response.status_code} in ${success_status_code_list} Terminate VNF instance completed
179 [Documentation] Test case to delete VNF
181 Create Session APISession ${HOST}
182 &{Headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${AccessToken}
183 ${resp}= DELETE On Session APISession ${vnf_instance_uri}/${createid} headers=${Headers}
184 Pass Execution If ${resp.status_code} in ${success_status_code_list} Delete VNF Instance completed
186 Delete VNF Descriptor Test
187 [Documentation] Test case to delete the VNF descriptor test
190 Delete VNFD ${vnfd_name}
195 [Documentation] Test Suit Cleanup: Deleting Descriptor
197 Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name}