blob: 581ac68aaec978896cc07eae8fb3edd048c3fb2c [file] [log] [blame]
Kailash Khalasib6e87fc2017-04-18 15:08:19 -07001*** Settings ***
Kailash Khalasi3a4e0f52017-06-01 16:35:59 -07002Documentation Test suite for VTN Functionality
Kailash Khalasib6e87fc2017-04-18 15:08:19 -07003Suite Setup Suite Setup
4Suite Teardown Suite Teardown
5Variables ../Framework/restApi.py
6Library Collections
7Library String
8Library OperatingSystem
9Library XML
10Library RequestsLibrary
11Library ../Framework/utils/utils.py
12Library ../Framework/restApi.py
Kailash Khalasi2adbad82017-05-15 14:53:40 -070013Library ../Framework/utils/openstackUtils.py
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070014Variables ../Properties/RestApiProperties.py
15Resource ../Framework/utils/utils.robot
16
17*** Variables ***
Kailash Khalasi2adbad82017-05-15 14:53:40 -070018${VM_USER} admin
19${VM_PASS} admin
20${SSH_KEY} id_rsa.pub
21${ONOS_CORDVTN_API} http://onos-cord:8182/onos/cordvtn
22${CORE_SERVICE_PATHFILE} ${CURDIR}/data/Service.json
23${CORE_NETWORK_PATHFILE} ${CURDIR}/data/CoreNetwork.json
24${CORE_SLICE_PATHFILE} ${CURDIR}/data/CoreSlice.json
25${CORE_NETWORK_SLICE_PATHFILE} ${CURDIR}/data/CoreNetworkSlice.json
26${CORE_INSTANCE_PATHFILE} ${CURDIR}/data/CoreInstance.json
27${CORD_SUBSCRIBER_PATHFILE} ${CURDIR}/data/CordSubscriber.json
28${VOLT_TENANT_PATHFILE} ${CURDIR}/data/CordVoltTenant.json
Kailash Khalasi3a4e0f52017-06-01 16:35:59 -070029${ciab_local} True
Kailash Khalasi9d8412d2017-06-09 15:00:33 -070030${physical_pod} True
31${default_flow_count} 42
32${final_flow_count} 49
33${expected_num_networks} 4
34${expected_num_ports} 5
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070035
36*** Test Cases ***
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070037Validate Default OVS Flow Count
38 [Documentation] Logs into the compute-node where OVS is running and validates the default flow count
39 [Tags] ovsflows
Kailash Khalasi9d8412d2017-06-09 15:00:33 -070040 Wait Until Keyword Succeeds 30s 5s Validate Flow Count ${default_flow_count}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070041
42Validate Current VTN Service Networks and Ports
Kailash Khalasi2adbad82017-05-15 14:53:40 -070043 [Documentation] Makes rest calls to XOS to validate the default VTN Service Networks + Ports (public,management,exampleservice_network,mysite_vsg-access)
Kailash Khalasi9d8412d2017-06-09 15:00:33 -070044 [Tags] vtn pod
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070045 Validate Default CIAB Service Networks and Ports via XOS
Kailash Khalasi2adbad82017-05-15 14:53:40 -070046
47Validate Default Subscriber
48 [Documentation] Validates the default subscriber set up in CIAB (My House)
49 [Tags] vsg
50 ${resp}= CORD GET ${SERVER_IP} ${VOLT_SUBSCRIBER}/1
51 Should Be Equal As Strings ${resp.status_code} 200
52 Log ${resp.content}
53 ${name}= Get Json Value ${resp.content} /name
54 ${service_specific_id}= Get Json Value ${resp.content} /service_specific_id
55 ${uplink_speed}= Get Json Value ${resp.content} /uplink_speed
56 Should Be Equal As Strings ${name} "My House"
57 Should Be Equal As Strings ${service_specific_id} "123"
58 Should Be Equal As Strings ${uplink_speed} 1000000000
59
60Create New Test Service
61 [Documentation] Creates a generic service that will be used for the new VTN Network
Kailash Khalasi9d8412d2017-06-09 15:00:33 -070062 [Tags] vtn pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -070063 ${updatedcservList}= utils.setFieldValueInDict ${cservlist[0]} name CordVTN-Test-Service
64 ${updatedcservList}= utils.setFieldValueInDict ${updatedcservList} description Test Service for CordVTN Test Suite
65 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_SERVICES} ${updatedcservList}
66 Should Be Equal As Strings ${resp.status_code} 200
67 ${name}= Get Json Value ${resp.content} /name
68 ${generic_service_id}= Get Json Value ${resp.content} /id
69 ${description}= Get Json Value ${resp.content} /description
70 ${kind}= Get Json Value ${resp.content} /kind
71 Should Be Equal As Strings ${name} "CordVTN-Test-Service"
72 Should Be Equal As Strings ${description} "Test Service for CordVTN Test Suite"
73 Should Be Equal As Strings ${kind} "generic"
74 Set Suite Variable ${generic_service_id}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070075
76Create New VTN Service Network
Kailash Khalasi2adbad82017-05-15 14:53:40 -070077 [Documentation] Makes a POST Request to XOS to create a new core network
Kailash Khalasi9d8412d2017-06-09 15:00:33 -070078 [Tags] vtn pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -070079 ${updatedCnList}= utils.setFieldValueInDict ${cnlist[0]} template_id ${vsg_network_template_id}
80 ${updatedCnList}= utils.setFieldValueInDict ${updatedCnList} owner_id ${vsg_slice_id}
81 Log ${updatedCnList}
82 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_NETWORKS} ${cnlist[0]}
83 Should Be Equal As Strings ${resp.status_code} 200
84 ${name}= Get Json Value ${resp.content} /name
85 ${network_id}= Get Json Value ${resp.content} /id
86 ${subnet}= Get Json Value ${resp.content} /subnet
87 ${start_ip}= Get Json Value ${resp.content} /start_ip
88 ${end_ip}= Get Json Value ${resp.content} /end_ip
89 Should Be Equal As Strings ${name} "test-network"
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070090 Should Be Equal As Strings ${subnet} "2.2.2.0/24"
Kailash Khalasi2adbad82017-05-15 14:53:40 -070091 Should Be Equal As Strings ${start_ip} "2.2.2.2"
92 Should Be Equal As Strings ${end_ip} "2.2.2.254"
93 Set Suite Variable ${network_id}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070094
Kailash Khalasi2adbad82017-05-15 14:53:40 -070095Create New Slice with New Test Service
96 [Documentation] Makes a POST Request to XOS to create a new slice and adds new generic test service to that slice
Kailash Khalasi9d8412d2017-06-09 15:00:33 -070097 [Tags] vtn pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -070098 ${updatedCsList}= utils.setFieldValueInDict ${cslist[0]} service_id ${generic_service_id}
99 Log ${updatedCsList}
100 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_SLICES} ${updatedCsList}
101 Should Be Equal As Strings ${resp.status_code} 200
102 ${name}= Get Json Value ${resp.content} /name
103 ${new_slice_id}= Get Json Value ${resp.content} /id
104 ${max_instances}= Get Json Value ${resp.content} /max_instances
105 ${ser_id}= Get Json Value ${resp.content} /service_id
106 ${default_isolation}= Get Json Value ${resp.content} /default_isolation
107 Should Be Equal As Strings ${name} "mysite_testservice"
108 Should Be Equal As Strings ${max_instances} 10
109 Should Be Equal As Strings ${ser_id} ${generic_service_id}
110 Should Be Equal As Strings ${default_isolation} "vm"
111 Set Suite Variable ${new_slice_id}
112
113Add Networks to New Test Network Slice
114 [Documentation] Creates a new network slice for the new slice and adds mgmt and new network to it
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700115 [Tags] vsg pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700116 ${updatedCsList}= utils.setFieldValueInDict ${cnslist[0]} network_id ${network_id}
117 ${updatedCsList}= utils.setFieldValueInDict ${updatedCsList} slice_id ${new_slice_id}
118 Log ${updatedCsList}
119 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_NETWORK_SLICES} ${updatedCsList}
120 Should Be Equal As Strings ${resp.status_code} 200
121 ${s_id}= Get Json Value ${resp.content} /slice_id
122 ${n_id}= Get Json Value ${resp.content} /network_id
123 Should Be Equal As Strings ${s_id} ${new_slice_id}
124 Should Be Equal As Strings ${n_id} ${network_id}
125 ##Add mgmt network to this network slice
126 ${updatedCsList}= utils.setFieldValueInDict ${cnslist[0]} network_id ${mgmt_network_id}
127 ${updatedCsList}= utils.setFieldValueInDict ${updatedCsList} slice_id ${new_slice_id}
128 Log ${updatedCsList}
129 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_NETWORK_SLICES} ${updatedCsList}
130 Should Be Equal As Strings ${resp.status_code} 200
131 ${s_id}= Get Json Value ${resp.content} /slice_id
132 ${n_id}= Get Json Value ${resp.content} /network_id
133 Should Be Equal As Strings ${s_id} ${new_slice_id}
134 Should Be Equal As Strings ${n_id} ${mgmt_network_id}
135
136Create New Test Instance
137 [Documentation] Creates a new instance for the test service
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700138 [Tags] vsg pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700139 ${updatedCiList}= utils.setFieldValueInDict ${cilist[0]} slice_id ${new_slice_id}
140 ${updatedCiList}= utils.setFieldValueInDict ${updatedCiList} image_id ${image_id}
141 Log ${updatedCiList}
142 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_INSTANCES} ${updatedCiList}
143 Should Be Equal As Strings ${resp.status_code} 200
144 ${new_instance_id}= Get Json Value ${resp.content} /id
145 ${slice_id}= Get Json Value ${resp.content} /slice_id
146 ${i_id}= Get Json Value ${resp.content} /image_id
147 ${node_id}= Get Json Value ${resp.content} /node_id
148 ${name}= Get Json Value ${resp.content} /name
149 ${instance_name}= Get Json Value ${resp.content} /instance_name
150 Should Be Equal As Strings ${slice_id} ${new_slice_id}
151 Should Be Equal As Strings ${i_id} ${image_id}
152 Should Be Equal As Strings ${node_id} 1
153 Should Be Equal As Strings ${name} "mysite_testservice"
154 Should Be Equal As Strings ${instance_name} "mysite_testservice-1"
155 Set Suite Variable ${new_instance_id}
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700156 FATAL ERROR
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700157
158Validate New OVS Flow Count
159 [Documentation] Logs into the compute-node where OVS is running and validates the new flow count (new flow rules for new volt tenant instance)
160 [Tags] ovsflows
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700161 Wait Until Keyword Succeeds 300s 5s Validate Flow Count ${final_flow_count}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700162
163Validate Creation of Openstack Resources
164 [Documentation] Retrieves openstack compute node state and validates the new network and instance has been created properly
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700165 [Tags] openstack pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700166 Wait Until Keyword Succeeds 300s 5s Validate Openstack Network test-network 2.2.2.0/24
167 Wait Until Keyword Succeeds 300s 5s Validate Openstack Nova Instance mysite_testservice-1* test-network
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700168
169Validate New Flows Pushed to OVS
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700170 [Documentation] Logs into the compute-node where OVS is running and validates the new flows added
Kailash Khalasi3a4e0f52017-06-01 16:35:59 -0700171 [Tags] ovsflows
172 ${ovs_flow_count}= Run Keyword If '${ciab_local}' == 'False' Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int | grep 2.2.2.0 | wc -l ELSE Execute Command Locally ssh -q root@${compute_node_hostname} "ovs-ofctl dump-flows br-int | grep 2.2.2.0 | wc -l"
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700173 ${ovs_flow_count}= Get Line ${ovs_flow_count} 0
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700174 Should Be Equal As Integers ${ovs_flow_count} 2
Kailash Khalasi3a4e0f52017-06-01 16:35:59 -0700175 ${flows_added}= Run Keyword If '${ciab_local}' == 'False' Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int ELSE Execute Command Locally ssh -q root@${compute_node_hostname} "ovs-ofctl dump-flows br-int"
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700176 ${flows_added}= Get Lines Containing String ${flows_added} cookie=
177 Log ${flows_added}
178 ## Match src/dst (bi-directional) rules on new flows added
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700179 Should Contain ${flows_added} nw_src=2.2.2.0/24,nw_dst=2.2.2.0/24
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700180
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700181Create New Cord Subscriber
182 [Documentation] Creates a new cord root subscriber
183 [Tags] vsg
184 ${blacklist_sr_ids}= Get Subscriber Root IDs in Use
185 ${ss_id}= Generate Random Number from Blacklist ${blacklist_sr_ids}
186 Set Suite Variable ${ss_id}
187 ${updatedcsList}= utils.setFieldValueInDict ${csubList[0]} service_specific_id ${ss_id}
188 Log ${updatedcsList}
189 ${resp}= Cord POST ${SERVER_IP} ${VOLT_SUBSCRIBER} ${updatedcsList}
190 Should Be Equal As Strings ${resp.status_code} 200
191 ${subscriber_root_id}= Get Json Value ${resp.content} /id
192 ${kind}= Get Json Value ${resp.content} /kind
193 ${enable_uverse}= Get Json Value ${resp.content} /enable_uverse
194 ${uplink_speed}= Get Json Value ${resp.content} /uplink_speed
195 ${downlink_speed}= Get Json Value ${resp.content} /downlink_speed
196 ${status}= Get Json Value ${resp.content} /status
197 ${is_demo_user}= Get Json Value ${resp.content} /is_demo_user
198 ${service_specific_id}= Get Json Value ${resp.content} /service_specific_id
199 Should Be Equal As Strings ${kind} "CordSubscriberRoot"
200 Should Be Equal As Strings ${enable_uverse} true
201 Should Be Equal As Strings ${uplink_speed} 1000000011
202 Should Be Equal As Strings ${downlink_speed} 1000000011
203 Should Be Equal As Strings ${status} "enabled"
204 Should Be Equal As Strings ${is_demo_user} false
205 Should Be Equal As Strings ${service_specific_id} "${ss_id}"
206 Set Suite Variable ${service_specific_id}
207 Set Suite Variable ${subscriber_root_id}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700208
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700209Create New Volt Tenant for New Cord Subscriber
210 [Documentation] Creates a new volt tenant for the newly created cord root subscriber
211 [Tags] vsg
212 ${blacklist_tags}= Get Tags in Use
213 Log ${blacklist_tags}
214 ${s_tag}= Generate Random Number from Blacklist ${blacklist_tags} 1 4096 True
215 Append To List ${blacklist_tags} ${s_tag}
216 ${c_tag}= Generate Random Number from Blacklist ${blacklist_tags} 1 4096 True
217 Append To List ${blacklist_tags} ${c_tag}
218 Log ${blacklist_tags}
219 ${updatedvtList}= utils.setFieldValueInDict ${vtList[0]} provider_service_id ${volt_service_id}
220 ${updatedvtList}= utils.setFieldValueInDict ${updatedvtList} subscriber_root_id ${subscriber_root_id}
221 ${updatedvtList}= utils.setFieldValueInDict ${updatedvtList} s_tag ${s_tag}
222 ${updatedvtList}= utils.setFieldValueInDict ${updatedvtList} c_tag ${c_tag}
223 Log ${updatedvtList}
224 ${resp}= Cord POST ${SERVER_IP} ${VOLT_TENANT} ${vtList[0]}
225 Should Be Equal As Strings ${resp.status_code} 200
226 ${volt_tenant_id}= Get Json Value ${resp.content} /id
227 ${stag}= Get Json Value ${resp.content} /s_tag
228 ${ctag}= Get Json Value ${resp.content} /c_tag
229 ${kind}= Get Json Value ${resp.content} /kind
230 ${prov_service_id}= Get Json Value ${resp.content} /provider_service_id
231 Should Be Equal As Strings ${stag} ${s_tag}
232 Should Be Equal As Strings ${ctag} ${c_tag}
233 Should Be Equal As Strings ${kind} "vOLT"
234 Should Be Equal As Strings ${prov_service_id} ${volt_service_id}
235 Set Suite Variable ${volt_tenant_id}
236
237Validate Creation of New Subscriber Instance
238 [Documentation] Validates instance (vm) for new subscriber is created in the vsg slice
239 [Tags] openstack
240 Wait Until Keyword Succeeds 300s 5s Validate Openstack Nova Instance mysite_vsg-* mysite_vsg-access
241
242Delete Volt Tenant
243 [Documentation] Deletes new volt tenant
244 [Tags] delete
245 ${resp}= Cord DELETE ${SERVER_IP} ${VOLT_TENANT} ${volt_tenant_id}
246 Should Be Equal As Strings ${resp.status_code} 200
247
248Delete Cord Subscriber
249 [Documentation] Deletes new cord subscriber
Kailash Khalasid01bec62017-05-30 13:53:01 -0700250 [Tags] delete
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700251 ${resp}= Cord DELETE ${SERVER_IP} ${VOLT_SUBSCRIBER} ${subscriber_root_id}
252 Should Be Equal As Strings ${resp.status_code} 200
253
254Delete Test Instance
255 [Documentation] Deletes the test instance created previously
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700256 [Tags] delete pod
257 Sleep 300
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700258 ${resp}= Cord DELETE ${SERVER_IP} ${CH_CORE_INSTANCES} ${new_instance_id}
259 Should Be Equal As Strings ${resp.status_code} 200
260
261Delete Test Slice
262 [Documentation] Deletes the test slice created previously
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700263 [Tags] delete pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700264 ${resp}= Cord DELETE ${SERVER_IP} ${CH_CORE_SLICES} ${new_slice_id}
265 Should Be Equal As Strings ${resp.status_code} 200
266
267Delete VTN Test Network
268 [Documentation] Deletes the test network created previously
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700269 [Tags] delete pod
Kailash Khalasi3a4e0f52017-06-01 16:35:59 -0700270 ## Wait for test network to be destroyed via get neutron lists
271 ##TODO: Find someting to poll on rather than wait 5 mins
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700272 #Sleep 300
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700273 ${resp}= Cord DELETE ${SERVER_IP} ${CH_CORE_NETWORKS} ${network_id}
274 Should Be Equal As Strings ${resp.status_code} 200
275
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700276Delete Test Service
277 [Documentation] Deletes the test service created
278 [Tags] delete pod
279 ${resp}= Cord DELETE ${SERVER_IP} ${CH_CORE_SERVICES} ${generic_service_id}
280 Should Be Equal As Strings ${resp.status_code} 200
281
Kailash Khalasid01bec62017-05-30 13:53:01 -0700282Validate OVS Flow Count Back to Default
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700283 [Documentation] Logs into the compute-node where OVS is running and validates the new flow count (new flow rules for new volt tenant instance)
284 [Tags] ovsflows
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700285 Wait Until Keyword Succeeds 60s 5s Validate Flow Count ${final_flow_count}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700286
287Validate New Flows Removed From OVS
288 [Documentation] Validates that the flow rules added by ONOS from the network creation has been removed
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700289 [Tags] ovsflows
Kailash Khalasi3a4e0f52017-06-01 16:35:59 -0700290 ${ovs_flow_count}= Run Keyword If '${ciab_local}' == 'False' Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int | grep 2.2.2.0 | wc -l ELSE Execute Command Locally ssh -q root@${compute_node_hostname} "ovs-ofctl dump-flows br-int | grep 2.2.2.0 | wc -l"
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700291 ${ovs_flow_count}= Get Line ${ovs_flow_count} 0
292 Should Be Equal As Integers ${ovs_flow_count} 0
Kailash Khalasi3a4e0f52017-06-01 16:35:59 -0700293 ${flows_added}= Run Keyword If '${ciab_local}' == 'False' Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int ELSE Execute Command Locally ssh -q root@${compute_node_hostname} "ovs-ofctl dump-flows br-int"
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700294 ${flows_added}= Get Lines Containing String ${flows_added} cookie=
295 Log ${flows_added}
296 ## Validate flow rules arent in the flows table
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700297 Should Not Contain ${flows_added} nw_src=2.2.2.0/24,nw_dst=2.2.2.0/24
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700298
299*** Keywords ***
300Suite Setup
301 ${auth} = Create List ${USER} ${PASSWD}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700302 ${HEADERS} Create Dictionary Content-Type=application/json
303 Create Session ${SERVER_IP} http://${SERVER_IP}:${SERVER_PORT} auth=${AUTH} headers=${HEADERS}
304 Read InputFile
305 ${vsg_service_id}= Get ID ${CH_CORE_SERVICES} name vsg
306 Set Suite Variable ${vsg_service_id}
307 ${vsg_network_template_id}= Get ID ${CH_CORE_NETWORK_TEMPLATES} name vsg
308 Set Suite Variable ${vsg_network_template_id}
309 ${mgmt_network_id}= Get ID ${CH_CORE_NETWORKS} name management
310 Set Suite Variable ${mgmt_network_id}
311 ${vsg_slice_id}= Get ID ${CH_CORE_SLICES} name mysite_vsg
312 Set Suite Variable ${vsg_slice_id}
313 ${volt_service_id}= Get ID ${CH_CORE_SERVICES} name volt
314 Set Suite Variable ${volt_service_id}
315 ${image_id}= Get ID ${CH_CORE_IMAGES} name trusty-server-multi-nic
316 Set Suite Variable ${image_id}
317 ##Get compute node information
Kailash Khalasi3a4e0f52017-06-01 16:35:59 -0700318 ${compute_node_hostname}= Run Keyword If '${ciab_local}' == 'False' Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod cord prov list | grep node | awk '{print $2}' ELSE Execute Command Locally cord prov list | grep node | awk '{print $2}'
319 ${compute_node_ip}= Run Keyword If '${ciab_local}' == 'False' Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod cord prov list | grep node | awk '{print $4}' ELSE Execute Command Locally cord prov list | grep node | awk '{print $4}'
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700320 Set Suite Variable ${compute_node_hostname}
321 set suite variable ${compute_node_ip}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700322
323Suite Teardown
324 Delete All Sessions
325 Close All Connections
326
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700327Read InputFile
328 ${coreServiceList} = utils.jsonToList ${CORE_SERVICE_PATHFILE} ServiceInfo
329 Set Suite Variable ${cservlist} ${coreServiceList}
330 ${coreNetworkList} = utils.jsonToList ${CORE_NETWORK_PATHFILE} NetworkInfo
331 Set Suite Variable ${cnlist} ${coreNetworkList}
332 ${coreSliceList} = utils.jsonToList ${CORE_SLICE_PATHFILE} SliceInfo
333 Set Suite Variable ${cslist} ${coreSliceList}
334 ${coreNetworkSliceList} = utils.jsonToList ${CORE_NETWORK_SLICE_PATHFILE} NetworkSliceInfo
335 Set Suite Variable ${cnslist} ${coreNetworkSliceList}
336 ${coreInstanceList} = utils.jsonToList ${CORE_INSTANCE_PATHFILE} InstanceInfo
337 Set Suite Variable ${cilist} ${coreInstanceList}
338 ${cordSubscriberList} = utils.jsonToList ${CORD_SUBSCRIBER_PATHFILE} CordSubscriberInfo
339 Set Suite Variable ${csubList} ${cordSubscriberList}
340 ${voltTenantList} = utils.jsonToList ${VOLT_TENANT_PATHFILE} VoltTenantInfo
341 Set Suite Variable ${vtList} ${voltTenantList}
342
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700343CORD Get
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700344 [Documentation] Make a GET call to the CORD controller
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700345 [Arguments] ${session} ${service}
346 ${resp}= Get Request ${session} ${service}
347 Log ${resp.content}
348 [Return] ${resp}
349
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700350CORD Post
351 [Documentation] Make a POST call to the CORD controller
352 [Arguments] ${session} ${service} ${data}
353 ${data}= Evaluate json.dumps(${data}) json
354 ${resp}= Post Request ${session} uri=${service} data=${data}
355 Log ${resp.content}
356 [Return] ${resp}
357
358CORD Delete
359 [Documentation] Make a DELETE call to the CORD controller
360 [Arguments] ${session} ${service} ${id}
361 ${resp}= Delete Request ${session} uri=${service}/${id}
362 Log ${resp.content}
363 [Return] ${resp}
364
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700365Validate Default CIAB Service Networks and Ports via XOS
366 [Documentation] Using XOS API, this validates the default VTN Service Networks + Ports for a CIAB Environment
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700367 @{expected_network_names}= Create List public management exampleservice_network mysite_vsg-access
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700368 Run Keyword If '${physical_pod}' == 'True' Remove Values From List ${expected_network_names} exampleservice_network
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700369 @{names}= Create List
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700370 @{network_names}= Create List
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700371 ${resp}= CORD GET ${SERVER_IP} ${CH_CORE_NETWORKS}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700372 Should Be Equal As Strings ${resp.status_code} 200
373 ${jsondata}= To Json ${resp.content}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700374 Log ${jsondata}
375 ${length}= Get Length ${jsondata['items']}
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700376 Should Be Equal As Integers ${length} ${expected_num_networks}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700377 : FOR ${INDEX} IN RANGE 0 ${length}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700378 \ ${item}= Get From List ${jsondata['items']} ${INDEX}
379 \ ${name}= Get From Dictionary ${item} name
380 \ Append To List ${names} ${name}
381 : FOR ${value} IN @{expected_network_names}
382 \ List Should Contain Value ${names} ${value}
383 ${resp}= CORD GET ${SERVER_IP} ${CH_CORE_PORTS}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700384 Should Be Equal As Strings ${resp.status_code} 200
385 ${jsondata}= To Json ${resp.content}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700386 ${length}= Get Length ${jsondata['items']}
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700387 Should Be Equal As Integers ${length} ${expected_num_ports}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700388
389Validate Default CIAB Service Networks via ONOSCORD
390 [Documentation] Validates the default VTN Service Network via ONOSCORD for a CIAB Environment
391 [Arguments] ${jsondata}
392 @{network_ids}= Create List
393 @{expected_types}= Create List PUBLIC PRIVATE MANAGEMENT_LOCAL VSG
394 @{expected_names}= Create List public exampleservice_network management mysite_vsg-access
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700395 Run Keyword If '${physical_pod}' == 'True' Remove From List ${expected_types} VSG
396 Run Keyword If '${physical_pod}' == 'True' Remove From List ${expected_names} exampleservice_network
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700397 @{types}= Create List
398 @{names}= Create List
399 ${jsondata}= To Json ${jsondata}
400 ${length}= Get Length ${jsondata['ServiceNetworks']}
401 Should Be Equal As Integers ${length} 4
402 : FOR ${INDEX} IN RANGE 0 ${length}
403 \ ${item}= Get From List ${jsondata['ServiceNetworks']} ${INDEX}
404 \ ${network_id}= Get From Dictionary ${item} id
405 \ ${type}= Get From Dictionary ${item} type
406 \ ${name}= Get From Dictionary ${item} name
407 \ Append To List ${network_ids} ${network_id}
408 \ Append To List ${types} ${type}
409 \ Append To List ${names} ${name}
410 \ Run Keyword If "${name}" == "management" Set Suite Variable ${management_network_id} ${network_id}
411 \ Run Keyword If "${name}" == "public" Set Suite Variable ${public_network_id} ${network_id}
412 : FOR ${value} IN @{expected_types}
413 \ List Should Contain Value ${types} ${value}
414 : FOR ${value} IN @{expected_names}
415 \ List Should Contain Value ${names} ${value}
416 Set Suite Variable ${network_ids}
417
418Validate Default CIAB Service Ports via ONOSCORD
419 [Documentation] Validates the default VTN Service Ports via ONOSCORD for a CIAB Environment
420 [Arguments] ${jsondata}
421 ${net_ids}= Create List
422 ${jsondata}= To Json ${jsondata}
423 ${length}= Get Length ${jsondata['ServicePorts']}
424 Should Be Equal As Integers ${length} 5
425 : FOR ${INDEX} IN RANGE 0 ${length}
426 \ ${item}= Get From List ${jsondata['ServicePorts']} ${INDEX}
427 \ ${net_id}= Get From Dictionary ${item} network_id
428 \ Append To List ${net_ids} ${net_id}
429 : FOR ${value} IN @{net_ids}
430 \ List Should Contain Value ${network_ids} ${value}
431 ${management_len}= Count Values in List ${net_ids} ${management_network_id}
432 Should Be Equal As Integers ${management_len} 2
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700433
434Get ID
435 [Documentation] Retreives the id of any specific component
436 [Arguments] ${endpoint} ${item} ${match}
437 ${resp}= CORD GET ${SERVER_IP} ${endpoint}
438 Should Be Equal As Strings ${resp.status_code} 200
439 ${jsondata}= To Json ${resp.content}
440 Log ${jsondata}
441 ${length}= Get Length ${jsondata['items']}
442 : FOR ${INDEX} IN RANGE 0 ${length}
443 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
444 \ ${name}= Get From Dictionary ${value} ${item}
445 \ ${id}= Get From Dictionary ${value} id
446 \ Run Keyword If '${name}' == '${match}' Exit For Loop
447 [Return] ${id}
448
449Validate Flow Count
450 [Documentation] Gets the count of the flows pushed to an ovs switch and validates that against expected count
451 [Arguments] ${count}
Kailash Khalasi3a4e0f52017-06-01 16:35:59 -0700452 ${ovs_flow_count}= Run Keyword If '${ciab_local}' == 'False' Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int | wc -l ELSE Execute Command Locally ssh -q root@${compute_node_hostname} "ovs-ofctl dump-flows br-int | wc -l"
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700453 ${ovs_flow_count}= Get Line ${ovs_flow_count} 0
454 Should Be Equal As Integers ${ovs_flow_count} ${count}
455
456Get Subscriber Root IDs in Use
457 [Documentation] Retrieves information for current subscribers and "blacklists" their subscriber root ids
458 @{sr_id_blacklist}= Create List
459 ${resp}= CORD GET ${SERVER_IP} ${VOLT_SUBSCRIBER}
460 ${jsondata}= To Json ${resp.content}
461 ${length}= Get Length ${jsondata['items']}
462 : FOR ${INDEX} IN RANGE 0 ${length}
463 \ ${item}= Get From List ${jsondata['items']} ${INDEX}
464 \ ${id}= Get From Dictionary ${item} service_specific_id
465 \ Append To List ${sr_id_blacklist} ${id}
466 [Return] @{sr_id_blacklist}
467
468Get Tags in Use
469 [Documentation] Retrieves information for current active volt tenants and "blacklists" their s/c tags
470 @{tag_blacklist}= Create List
471 ${resp}= CORD GET ${SERVER_IP} ${VOLT_TENANT}
472 ${jsondata}= To Json ${resp.content}
473 ${length}= Get Length ${jsondata['items']}
474 : FOR ${INDEX} IN RANGE 0 ${length}
475 \ ${item}= Get From List ${jsondata['items']} ${INDEX}
476 \ ${s_tag}= Get From Dictionary ${item} s_tag
477 \ ${c_tag}= Get From Dictionary ${item} c_tag
478 \ Append To List ${tag_blacklist} ${s_tag}
479 \ Append To List ${tag_blacklist} ${c_tag}
480 [Return] @{tag_blacklist}
481
482Get Openstack Info
483 [Documentation] Executes a command in the prod vm in a CIAB environment where openstack is running
484 [Arguments] ${cmd}
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700485 ${output}= Run Keyword If '${ciab_local}' == 'False' Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod source /home/vagrant/admin-openrc.sh; ${cmd} strip_line=False ELSE Execute Command Locally . %{HOME}/admin-openrc.sh; ${cmd}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700486 Log ${output}
487 [Return] ${output}
488
489Validate Openstack Network
490 [Documentation] Validates that a particular network/subnet exists
491 [Arguments] ${network_name} ${subnet}
492 ${netlist}= Get Openstack Info neutron net-list
493 Log ${netlist}
494 ${NET_DICT}= openstackUtils.Get Neutron Lists ${netlist}
495 Log ${NET_DICT}
496 ${test-net}= Get From Dictionary ${NET_DICT} ${network_name}
497 Should Contain ${test-net} ${subnet}
498
499Validate Openstack Nova Instance
500 [Documentation] Validates that a particular nova instance/tenant exists
501 [Arguments] ${instance_name} ${network} ${destroyed}=False
502 ${novalist}= Get Openstack Info nova list --all-tenants
503 Log ${novalist}
504 ${NOVA_DICT}= openstackUtils.Get Nova Lists ${novalist} ${instance_name}
505 Log ${NOVA_DICT}
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700506 Should Contain ${NOVA_DICT} ${network}