Revert "Feature 11001: Robot framework linting for E2E tests"
[osm/tests.git] / robot-systest / testsuite / sol003_02-dualstack_ip_vnfm.robot
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
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 ***
14 Documentation Sol003-02 Sol003   This script launches dual-stack IP addresses NS in VIM and verify the dualstack ip
15
16 Library   OperatingSystem
17 Library   String
18 Library   Collections
19 Library   RequestsLibrary
20 Library   yaml
21 Library   JsonValidator
22 Library   JSONLibrary
23
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
29
30 Force Tags   sol003_02   cluster_osm_rest   daily
31
32 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
33
34
35 *** Variables ***
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
40
41 # NS and VNF descriptor package folder and ids
42 ${vnfd_pkg}   hackfest_basic_vnf
43 ${vnfd_name}   hackfest_basic-vnf
44
45
46 *** Test Cases ***
47
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}
54     Get Auth Token
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]}
73     Get VNFDs List
74
75 Instantiate VNF
76     [Documentation]   Test case to Instantiate a VNF
77     Get Ns List
78     Get Vnf List
79     Get Auth Token
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]}
90     Sleep   12s
91     Get Ns List
92     Get Vnf List
93
94 Get Ns Id
95     [Documentation]   Get the ns id from the ns list
96     ${id}=   Get Ns Id   ${ns_name}
97     Set Suite Variable   ${ns_id}   ${id}
98
99 Get Dual Ip
100     [Documentation]   Get the ip from the ns list
101     ${id}=   Get Dual Ip   ${ns_id}
102     Set Suite Variable   ${ip}   ${id}
103
104 Query VNF Instances
105     [Documentation]   Test case to query VNF Instance
106     Get Auth Token
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]}
113
114 Query VNF Instance ID
115     [Documentation]   Test case to query Vnf instance ID
116     Get Auth Token
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]}
123
124 Query VNF LCM Ops
125     [Documentation]   Test case to Query VNF LCM operation
126     Get Auth Token
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
135     ...   ELSE   Sleep   10s
136     END
137
138 Query VNF LCM Ops ID
139     [Documentation]   Test case to Query VNF LCM operation id
140     Get Auth Token
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
149         ...   ELSE   Sleep   10s
150     END
151
152 Verify Dual Ip
153     Should Be Equal   ${ip}   ${Value1}
154
155
156 Terminate VNF
157     [Documentation]   Test case to terminate the VNF
158     Get Auth Token
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
174         ...   ELSE   Sleep   10s
175     END
176     Pass Execution If   ${request_response.status_code} in ${success_status_code_list}   Terminate VNF instance completed
177
178 Delete VNF
179     [Documentation]   Test case to delete VNF
180     Get Auth Token
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
185
186 Delete VNF Descriptor Test
187     [Documentation]   Test case to delete the VNF descriptor test
188     [Tags]   cleanup
189
190     Delete VNFD   ${vnfd_name}
191
192
193 *** Keywords ***
194 Suite Cleanup
195     [Documentation]   Test Suit Cleanup: Deleting Descriptor
196
197     Run Keyword If Any Tests Failed   Delete VNFD   ${vnfd_name}
198
199
200
201