blob: 668d24d386f7bc6af15ea72046840fd1b5979793 [file] [log] [blame]
Kailash Khalasib6e87fc2017-04-18 15:08:19 -07001*** Settings ***
2Documentation Test suite for Utility Synchronizer API
3Suite 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 Khalasib6e87fc2017-04-18 15:08:19 -070029
30*** Test Cases ***
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070031Validate Default OVS Flow Count
32 [Documentation] Logs into the compute-node where OVS is running and validates the default flow count
33 [Tags] ovsflows
Kailash Khalasi2adbad82017-05-15 14:53:40 -070034 Wait Until Keyword Succeeds 30s 5s Validate Flow Count 42
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070035
36Validate Current VTN Service Networks and Ports
Kailash Khalasi2adbad82017-05-15 14:53:40 -070037 [Documentation] Makes rest calls to XOS to validate the default VTN Service Networks + Ports (public,management,exampleservice_network,mysite_vsg-access)
38 [Tags] vtn
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070039 Validate Default CIAB Service Networks and Ports via XOS
Kailash Khalasi2adbad82017-05-15 14:53:40 -070040
41Validate Default Subscriber
42 [Documentation] Validates the default subscriber set up in CIAB (My House)
43 [Tags] vsg
44 ${resp}= CORD GET ${SERVER_IP} ${VOLT_SUBSCRIBER}/1
45 Should Be Equal As Strings ${resp.status_code} 200
46 Log ${resp.content}
47 ${name}= Get Json Value ${resp.content} /name
48 ${service_specific_id}= Get Json Value ${resp.content} /service_specific_id
49 ${uplink_speed}= Get Json Value ${resp.content} /uplink_speed
50 Should Be Equal As Strings ${name} "My House"
51 Should Be Equal As Strings ${service_specific_id} "123"
52 Should Be Equal As Strings ${uplink_speed} 1000000000
53
54Create New Test Service
55 [Documentation] Creates a generic service that will be used for the new VTN Network
56 [Tags] vtn
57 ${updatedcservList}= utils.setFieldValueInDict ${cservlist[0]} name CordVTN-Test-Service
58 ${updatedcservList}= utils.setFieldValueInDict ${updatedcservList} description Test Service for CordVTN Test Suite
59 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_SERVICES} ${updatedcservList}
60 Should Be Equal As Strings ${resp.status_code} 200
61 ${name}= Get Json Value ${resp.content} /name
62 ${generic_service_id}= Get Json Value ${resp.content} /id
63 ${description}= Get Json Value ${resp.content} /description
64 ${kind}= Get Json Value ${resp.content} /kind
65 Should Be Equal As Strings ${name} "CordVTN-Test-Service"
66 Should Be Equal As Strings ${description} "Test Service for CordVTN Test Suite"
67 Should Be Equal As Strings ${kind} "generic"
68 Set Suite Variable ${generic_service_id}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070069
70Create New VTN Service Network
Kailash Khalasi2adbad82017-05-15 14:53:40 -070071 [Documentation] Makes a POST Request to XOS to create a new core network
72 [Tags] vtn
73 ${updatedCnList}= utils.setFieldValueInDict ${cnlist[0]} template_id ${vsg_network_template_id}
74 ${updatedCnList}= utils.setFieldValueInDict ${updatedCnList} owner_id ${vsg_slice_id}
75 Log ${updatedCnList}
76 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_NETWORKS} ${cnlist[0]}
77 Should Be Equal As Strings ${resp.status_code} 200
78 ${name}= Get Json Value ${resp.content} /name
79 ${network_id}= Get Json Value ${resp.content} /id
80 ${subnet}= Get Json Value ${resp.content} /subnet
81 ${start_ip}= Get Json Value ${resp.content} /start_ip
82 ${end_ip}= Get Json Value ${resp.content} /end_ip
83 Should Be Equal As Strings ${name} "test-network"
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070084 Should Be Equal As Strings ${subnet} "2.2.2.0/24"
Kailash Khalasi2adbad82017-05-15 14:53:40 -070085 Should Be Equal As Strings ${start_ip} "2.2.2.2"
86 Should Be Equal As Strings ${end_ip} "2.2.2.254"
87 Set Suite Variable ${network_id}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070088
Kailash Khalasi2adbad82017-05-15 14:53:40 -070089Create New Slice with New Test Service
90 [Documentation] Makes a POST Request to XOS to create a new slice and adds new generic test service to that slice
91 [Tags] vtn
92 ${updatedCsList}= utils.setFieldValueInDict ${cslist[0]} service_id ${generic_service_id}
93 Log ${updatedCsList}
94 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_SLICES} ${updatedCsList}
95 Should Be Equal As Strings ${resp.status_code} 200
96 ${name}= Get Json Value ${resp.content} /name
97 ${new_slice_id}= Get Json Value ${resp.content} /id
98 ${max_instances}= Get Json Value ${resp.content} /max_instances
99 ${ser_id}= Get Json Value ${resp.content} /service_id
100 ${default_isolation}= Get Json Value ${resp.content} /default_isolation
101 Should Be Equal As Strings ${name} "mysite_testservice"
102 Should Be Equal As Strings ${max_instances} 10
103 Should Be Equal As Strings ${ser_id} ${generic_service_id}
104 Should Be Equal As Strings ${default_isolation} "vm"
105 Set Suite Variable ${new_slice_id}
106
107Add Networks to New Test Network Slice
108 [Documentation] Creates a new network slice for the new slice and adds mgmt and new network to it
109 [Tags] vsg
110 ${updatedCsList}= utils.setFieldValueInDict ${cnslist[0]} network_id ${network_id}
111 ${updatedCsList}= utils.setFieldValueInDict ${updatedCsList} slice_id ${new_slice_id}
112 Log ${updatedCsList}
113 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_NETWORK_SLICES} ${updatedCsList}
114 Should Be Equal As Strings ${resp.status_code} 200
115 ${s_id}= Get Json Value ${resp.content} /slice_id
116 ${n_id}= Get Json Value ${resp.content} /network_id
117 Should Be Equal As Strings ${s_id} ${new_slice_id}
118 Should Be Equal As Strings ${n_id} ${network_id}
119 ##Add mgmt network to this network slice
120 ${updatedCsList}= utils.setFieldValueInDict ${cnslist[0]} network_id ${mgmt_network_id}
121 ${updatedCsList}= utils.setFieldValueInDict ${updatedCsList} slice_id ${new_slice_id}
122 Log ${updatedCsList}
123 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_NETWORK_SLICES} ${updatedCsList}
124 Should Be Equal As Strings ${resp.status_code} 200
125 ${s_id}= Get Json Value ${resp.content} /slice_id
126 ${n_id}= Get Json Value ${resp.content} /network_id
127 Should Be Equal As Strings ${s_id} ${new_slice_id}
128 Should Be Equal As Strings ${n_id} ${mgmt_network_id}
129
130Create New Test Instance
131 [Documentation] Creates a new instance for the test service
132 [Tags] vsg
133 ${updatedCiList}= utils.setFieldValueInDict ${cilist[0]} slice_id ${new_slice_id}
134 ${updatedCiList}= utils.setFieldValueInDict ${updatedCiList} image_id ${image_id}
135 Log ${updatedCiList}
136 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_INSTANCES} ${updatedCiList}
137 Should Be Equal As Strings ${resp.status_code} 200
138 ${new_instance_id}= Get Json Value ${resp.content} /id
139 ${slice_id}= Get Json Value ${resp.content} /slice_id
140 ${i_id}= Get Json Value ${resp.content} /image_id
141 ${node_id}= Get Json Value ${resp.content} /node_id
142 ${name}= Get Json Value ${resp.content} /name
143 ${instance_name}= Get Json Value ${resp.content} /instance_name
144 Should Be Equal As Strings ${slice_id} ${new_slice_id}
145 Should Be Equal As Strings ${i_id} ${image_id}
146 Should Be Equal As Strings ${node_id} 1
147 Should Be Equal As Strings ${name} "mysite_testservice"
148 Should Be Equal As Strings ${instance_name} "mysite_testservice-1"
149 Set Suite Variable ${new_instance_id}
150
151Validate New OVS Flow Count
152 [Documentation] Logs into the compute-node where OVS is running and validates the new flow count (new flow rules for new volt tenant instance)
153 [Tags] ovsflows
154 Wait Until Keyword Succeeds 300s 5s Validate Flow Count 49
155
156Validate Creation of Openstack Resources
157 [Documentation] Retrieves openstack compute node state and validates the new network and instance has been created properly
158 [Tags] openstack
159 Wait Until Keyword Succeeds 300s 5s Validate Openstack Network test-network 2.2.2.0/24
160 Wait Until Keyword Succeeds 300s 5s Validate Openstack Nova Instance mysite_testservice-1* test-network
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700161
162Validate New Flows Pushed to OVS
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700163 [Documentation] Logs into the compute-node where OVS is running and validates the new flows added
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700164 [Tags] vtnservice
165 ${ovs_flow_count}= 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
166 ${ovs_flow_count}= Get Line ${ovs_flow_count} 0
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700167 Should Be Equal As Integers ${ovs_flow_count} 2
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700168 ${flows_added}= Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int
169 ${flows_added}= Get Lines Containing String ${flows_added} cookie=
170 Log ${flows_added}
171 ## Match src/dst (bi-directional) rules on new flows added
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700172 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 -0700173
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700174Create New Cord Subscriber
175 [Documentation] Creates a new cord root subscriber
176 [Tags] vsg
177 ${blacklist_sr_ids}= Get Subscriber Root IDs in Use
178 ${ss_id}= Generate Random Number from Blacklist ${blacklist_sr_ids}
179 Set Suite Variable ${ss_id}
180 ${updatedcsList}= utils.setFieldValueInDict ${csubList[0]} service_specific_id ${ss_id}
181 Log ${updatedcsList}
182 ${resp}= Cord POST ${SERVER_IP} ${VOLT_SUBSCRIBER} ${updatedcsList}
183 Should Be Equal As Strings ${resp.status_code} 200
184 ${subscriber_root_id}= Get Json Value ${resp.content} /id
185 ${kind}= Get Json Value ${resp.content} /kind
186 ${enable_uverse}= Get Json Value ${resp.content} /enable_uverse
187 ${uplink_speed}= Get Json Value ${resp.content} /uplink_speed
188 ${downlink_speed}= Get Json Value ${resp.content} /downlink_speed
189 ${status}= Get Json Value ${resp.content} /status
190 ${is_demo_user}= Get Json Value ${resp.content} /is_demo_user
191 ${service_specific_id}= Get Json Value ${resp.content} /service_specific_id
192 Should Be Equal As Strings ${kind} "CordSubscriberRoot"
193 Should Be Equal As Strings ${enable_uverse} true
194 Should Be Equal As Strings ${uplink_speed} 1000000011
195 Should Be Equal As Strings ${downlink_speed} 1000000011
196 Should Be Equal As Strings ${status} "enabled"
197 Should Be Equal As Strings ${is_demo_user} false
198 Should Be Equal As Strings ${service_specific_id} "${ss_id}"
199 Set Suite Variable ${service_specific_id}
200 Set Suite Variable ${subscriber_root_id}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700201
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700202Create New Volt Tenant for New Cord Subscriber
203 [Documentation] Creates a new volt tenant for the newly created cord root subscriber
204 [Tags] vsg
205 ${blacklist_tags}= Get Tags in Use
206 Log ${blacklist_tags}
207 ${s_tag}= Generate Random Number from Blacklist ${blacklist_tags} 1 4096 True
208 Append To List ${blacklist_tags} ${s_tag}
209 ${c_tag}= Generate Random Number from Blacklist ${blacklist_tags} 1 4096 True
210 Append To List ${blacklist_tags} ${c_tag}
211 Log ${blacklist_tags}
212 ${updatedvtList}= utils.setFieldValueInDict ${vtList[0]} provider_service_id ${volt_service_id}
213 ${updatedvtList}= utils.setFieldValueInDict ${updatedvtList} subscriber_root_id ${subscriber_root_id}
214 ${updatedvtList}= utils.setFieldValueInDict ${updatedvtList} s_tag ${s_tag}
215 ${updatedvtList}= utils.setFieldValueInDict ${updatedvtList} c_tag ${c_tag}
216 Log ${updatedvtList}
217 ${resp}= Cord POST ${SERVER_IP} ${VOLT_TENANT} ${vtList[0]}
218 Should Be Equal As Strings ${resp.status_code} 200
219 ${volt_tenant_id}= Get Json Value ${resp.content} /id
220 ${stag}= Get Json Value ${resp.content} /s_tag
221 ${ctag}= Get Json Value ${resp.content} /c_tag
222 ${kind}= Get Json Value ${resp.content} /kind
223 ${prov_service_id}= Get Json Value ${resp.content} /provider_service_id
224 Should Be Equal As Strings ${stag} ${s_tag}
225 Should Be Equal As Strings ${ctag} ${c_tag}
226 Should Be Equal As Strings ${kind} "vOLT"
227 Should Be Equal As Strings ${prov_service_id} ${volt_service_id}
228 Set Suite Variable ${volt_tenant_id}
229
230Validate Creation of New Subscriber Instance
231 [Documentation] Validates instance (vm) for new subscriber is created in the vsg slice
232 [Tags] openstack
233 Wait Until Keyword Succeeds 300s 5s Validate Openstack Nova Instance mysite_vsg-* mysite_vsg-access
234
235Delete Volt Tenant
236 [Documentation] Deletes new volt tenant
237 [Tags] delete
238 ${resp}= Cord DELETE ${SERVER_IP} ${VOLT_TENANT} ${volt_tenant_id}
239 Should Be Equal As Strings ${resp.status_code} 200
240
241Delete Cord Subscriber
242 [Documentation] Deletes new cord subscriber
243 [Tags] deletes
244 ${resp}= Cord DELETE ${SERVER_IP} ${VOLT_SUBSCRIBER} ${subscriber_root_id}
245 Should Be Equal As Strings ${resp.status_code} 200
246
247Delete Test Instance
248 [Documentation] Deletes the test instance created previously
249 [Tags] delete
250 ${resp}= Cord DELETE ${SERVER_IP} ${CH_CORE_INSTANCES} ${new_instance_id}
251 Should Be Equal As Strings ${resp.status_code} 200
252
253Delete Test Slice
254 [Documentation] Deletes the test slice created previously
255 [Tags] delete
256 ${resp}= Cord DELETE ${SERVER_IP} ${CH_CORE_SLICES} ${new_slice_id}
257 Should Be Equal As Strings ${resp.status_code} 200
258
259Delete VTN Test Network
260 [Documentation] Deletes the test network created previously
261 [Tags] delete
262 ${resp}= Cord DELETE ${SERVER_IP} ${CH_CORE_NETWORKS} ${network_id}
263 Should Be Equal As Strings ${resp.status_code} 200
264
265Validate New OVS Flow Count
266 [Documentation] Logs into the compute-node where OVS is running and validates the new flow count (new flow rules for new volt tenant instance)
267 [Tags] ovsflows
268 Wait Until Keyword Succeeds 60s 5s Validate Flow Count 42
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700269
270Validate New Flows Removed From OVS
271 [Documentation] Validates that the flow rules added by ONOS from the network creation has been removed
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700272 [Tags] ovsflows
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700273 ${ovs_flow_count}= 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
274 ${ovs_flow_count}= Get Line ${ovs_flow_count} 0
275 Should Be Equal As Integers ${ovs_flow_count} 0
276 ${flows_added}= Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int
277 ${flows_added}= Get Lines Containing String ${flows_added} cookie=
278 Log ${flows_added}
279 ## Validate flow rules arent in the flows table
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700280 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 -0700281
282*** Keywords ***
283Suite Setup
284 ${auth} = Create List ${USER} ${PASSWD}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700285 ${HEADERS} Create Dictionary Content-Type=application/json
286 Create Session ${SERVER_IP} http://${SERVER_IP}:${SERVER_PORT} auth=${AUTH} headers=${HEADERS}
287 Read InputFile
288 ${vsg_service_id}= Get ID ${CH_CORE_SERVICES} name vsg
289 Set Suite Variable ${vsg_service_id}
290 ${vsg_network_template_id}= Get ID ${CH_CORE_NETWORK_TEMPLATES} name vsg
291 Set Suite Variable ${vsg_network_template_id}
292 ${mgmt_network_id}= Get ID ${CH_CORE_NETWORKS} name management
293 Set Suite Variable ${mgmt_network_id}
294 ${vsg_slice_id}= Get ID ${CH_CORE_SLICES} name mysite_vsg
295 Set Suite Variable ${vsg_slice_id}
296 ${volt_service_id}= Get ID ${CH_CORE_SERVICES} name volt
297 Set Suite Variable ${volt_service_id}
298 ${image_id}= Get ID ${CH_CORE_IMAGES} name trusty-server-multi-nic
299 Set Suite Variable ${image_id}
300 ##Get compute node information
301 ${compute_node_hostname}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod cord prov list | grep node | awk '{print $2}'
302 ${compute_node_ip}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod cord prov list | grep node | awk '{print $4}'
303 Set Suite Variable ${compute_node_hostname}
304 set suite variable ${compute_node_ip}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700305
306Suite Teardown
307 Delete All Sessions
308 Close All Connections
309
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700310Read InputFile
311 ${coreServiceList} = utils.jsonToList ${CORE_SERVICE_PATHFILE} ServiceInfo
312 Set Suite Variable ${cservlist} ${coreServiceList}
313 ${coreNetworkList} = utils.jsonToList ${CORE_NETWORK_PATHFILE} NetworkInfo
314 Set Suite Variable ${cnlist} ${coreNetworkList}
315 ${coreSliceList} = utils.jsonToList ${CORE_SLICE_PATHFILE} SliceInfo
316 Set Suite Variable ${cslist} ${coreSliceList}
317 ${coreNetworkSliceList} = utils.jsonToList ${CORE_NETWORK_SLICE_PATHFILE} NetworkSliceInfo
318 Set Suite Variable ${cnslist} ${coreNetworkSliceList}
319 ${coreInstanceList} = utils.jsonToList ${CORE_INSTANCE_PATHFILE} InstanceInfo
320 Set Suite Variable ${cilist} ${coreInstanceList}
321 ${cordSubscriberList} = utils.jsonToList ${CORD_SUBSCRIBER_PATHFILE} CordSubscriberInfo
322 Set Suite Variable ${csubList} ${cordSubscriberList}
323 ${voltTenantList} = utils.jsonToList ${VOLT_TENANT_PATHFILE} VoltTenantInfo
324 Set Suite Variable ${vtList} ${voltTenantList}
325
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700326CORD Get
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700327 [Documentation] Make a GET call to the CORD controller
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700328 [Arguments] ${session} ${service}
329 ${resp}= Get Request ${session} ${service}
330 Log ${resp.content}
331 [Return] ${resp}
332
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700333CORD Post
334 [Documentation] Make a POST call to the CORD controller
335 [Arguments] ${session} ${service} ${data}
336 ${data}= Evaluate json.dumps(${data}) json
337 ${resp}= Post Request ${session} uri=${service} data=${data}
338 Log ${resp.content}
339 [Return] ${resp}
340
341CORD Delete
342 [Documentation] Make a DELETE call to the CORD controller
343 [Arguments] ${session} ${service} ${id}
344 ${resp}= Delete Request ${session} uri=${service}/${id}
345 Log ${resp.content}
346 [Return] ${resp}
347
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700348Validate Default CIAB Service Networks and Ports via XOS
349 [Documentation] Using XOS API, this validates the default VTN Service Networks + Ports for a CIAB Environment
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700350 @{expected_network_names}= Create List public management exampleservice_network mysite_vsg-access
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700351 @{names}= Create List
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700352 @{network_names}= Create List
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700353 ${resp}= CORD GET ${SERVER_IP} ${CH_CORE_NETWORKS}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700354 Should Be Equal As Strings ${resp.status_code} 200
355 ${jsondata}= To Json ${resp.content}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700356 Log ${jsondata}
357 ${length}= Get Length ${jsondata['items']}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700358 Should Be Equal As Integers ${length} 4
359 : FOR ${INDEX} IN RANGE 0 ${length}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700360 \ ${item}= Get From List ${jsondata['items']} ${INDEX}
361 \ ${name}= Get From Dictionary ${item} name
362 \ Append To List ${names} ${name}
363 : FOR ${value} IN @{expected_network_names}
364 \ List Should Contain Value ${names} ${value}
365 ${resp}= CORD GET ${SERVER_IP} ${CH_CORE_PORTS}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700366 Should Be Equal As Strings ${resp.status_code} 200
367 ${jsondata}= To Json ${resp.content}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700368 ${length}= Get Length ${jsondata['items']}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700369 Should Be Equal As Integers ${length} 5
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700370
371Validate Default CIAB Service Networks via ONOSCORD
372 [Documentation] Validates the default VTN Service Network via ONOSCORD for a CIAB Environment
373 [Arguments] ${jsondata}
374 @{network_ids}= Create List
375 @{expected_types}= Create List PUBLIC PRIVATE MANAGEMENT_LOCAL VSG
376 @{expected_names}= Create List public exampleservice_network management mysite_vsg-access
377 @{types}= Create List
378 @{names}= Create List
379 ${jsondata}= To Json ${jsondata}
380 ${length}= Get Length ${jsondata['ServiceNetworks']}
381 Should Be Equal As Integers ${length} 4
382 : FOR ${INDEX} IN RANGE 0 ${length}
383 \ ${item}= Get From List ${jsondata['ServiceNetworks']} ${INDEX}
384 \ ${network_id}= Get From Dictionary ${item} id
385 \ ${type}= Get From Dictionary ${item} type
386 \ ${name}= Get From Dictionary ${item} name
387 \ Append To List ${network_ids} ${network_id}
388 \ Append To List ${types} ${type}
389 \ Append To List ${names} ${name}
390 \ Run Keyword If "${name}" == "management" Set Suite Variable ${management_network_id} ${network_id}
391 \ Run Keyword If "${name}" == "public" Set Suite Variable ${public_network_id} ${network_id}
392 : FOR ${value} IN @{expected_types}
393 \ List Should Contain Value ${types} ${value}
394 : FOR ${value} IN @{expected_names}
395 \ List Should Contain Value ${names} ${value}
396 Set Suite Variable ${network_ids}
397
398Validate Default CIAB Service Ports via ONOSCORD
399 [Documentation] Validates the default VTN Service Ports via ONOSCORD for a CIAB Environment
400 [Arguments] ${jsondata}
401 ${net_ids}= Create List
402 ${jsondata}= To Json ${jsondata}
403 ${length}= Get Length ${jsondata['ServicePorts']}
404 Should Be Equal As Integers ${length} 5
405 : FOR ${INDEX} IN RANGE 0 ${length}
406 \ ${item}= Get From List ${jsondata['ServicePorts']} ${INDEX}
407 \ ${net_id}= Get From Dictionary ${item} network_id
408 \ Append To List ${net_ids} ${net_id}
409 : FOR ${value} IN @{net_ids}
410 \ List Should Contain Value ${network_ids} ${value}
411 ${management_len}= Count Values in List ${net_ids} ${management_network_id}
412 Should Be Equal As Integers ${management_len} 2
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700413
414Get ID
415 [Documentation] Retreives the id of any specific component
416 [Arguments] ${endpoint} ${item} ${match}
417 ${resp}= CORD GET ${SERVER_IP} ${endpoint}
418 Should Be Equal As Strings ${resp.status_code} 200
419 ${jsondata}= To Json ${resp.content}
420 Log ${jsondata}
421 ${length}= Get Length ${jsondata['items']}
422 : FOR ${INDEX} IN RANGE 0 ${length}
423 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
424 \ ${name}= Get From Dictionary ${value} ${item}
425 \ ${id}= Get From Dictionary ${value} id
426 \ Run Keyword If '${name}' == '${match}' Exit For Loop
427 [Return] ${id}
428
429Validate Flow Count
430 [Documentation] Gets the count of the flows pushed to an ovs switch and validates that against expected count
431 [Arguments] ${count}
432 ${ovs_flow_count}= Execute Command on Compute Node in CIAB ${SERVER_IP} ${compute_node_hostname} ovs-ofctl dump-flows br-int | wc -l
433 ${ovs_flow_count}= Get Line ${ovs_flow_count} 0
434 Should Be Equal As Integers ${ovs_flow_count} ${count}
435
436Get Subscriber Root IDs in Use
437 [Documentation] Retrieves information for current subscribers and "blacklists" their subscriber root ids
438 @{sr_id_blacklist}= Create List
439 ${resp}= CORD GET ${SERVER_IP} ${VOLT_SUBSCRIBER}
440 ${jsondata}= To Json ${resp.content}
441 ${length}= Get Length ${jsondata['items']}
442 : FOR ${INDEX} IN RANGE 0 ${length}
443 \ ${item}= Get From List ${jsondata['items']} ${INDEX}
444 \ ${id}= Get From Dictionary ${item} service_specific_id
445 \ Append To List ${sr_id_blacklist} ${id}
446 [Return] @{sr_id_blacklist}
447
448Get Tags in Use
449 [Documentation] Retrieves information for current active volt tenants and "blacklists" their s/c tags
450 @{tag_blacklist}= Create List
451 ${resp}= CORD GET ${SERVER_IP} ${VOLT_TENANT}
452 ${jsondata}= To Json ${resp.content}
453 ${length}= Get Length ${jsondata['items']}
454 : FOR ${INDEX} IN RANGE 0 ${length}
455 \ ${item}= Get From List ${jsondata['items']} ${INDEX}
456 \ ${s_tag}= Get From Dictionary ${item} s_tag
457 \ ${c_tag}= Get From Dictionary ${item} c_tag
458 \ Append To List ${tag_blacklist} ${s_tag}
459 \ Append To List ${tag_blacklist} ${c_tag}
460 [Return] @{tag_blacklist}
461
462Get Openstack Info
463 [Documentation] Executes a command in the prod vm in a CIAB environment where openstack is running
464 [Arguments] ${cmd}
465 ${output}= Execute Command on CIAB Server in Specific VM ${SERVER_IP} prod source admin-openrc.sh; ${cmd} strip_line=False
466 Log ${output}
467 [Return] ${output}
468
469Validate Openstack Network
470 [Documentation] Validates that a particular network/subnet exists
471 [Arguments] ${network_name} ${subnet}
472 ${netlist}= Get Openstack Info neutron net-list
473 Log ${netlist}
474 ${NET_DICT}= openstackUtils.Get Neutron Lists ${netlist}
475 Log ${NET_DICT}
476 ${test-net}= Get From Dictionary ${NET_DICT} ${network_name}
477 Should Contain ${test-net} ${subnet}
478
479Validate Openstack Nova Instance
480 [Documentation] Validates that a particular nova instance/tenant exists
481 [Arguments] ${instance_name} ${network} ${destroyed}=False
482 ${novalist}= Get Openstack Info nova list --all-tenants
483 Log ${novalist}
484 ${NOVA_DICT}= openstackUtils.Get Nova Lists ${novalist} ${instance_name}
485 Log ${NOVA_DICT}
486 Should Contain ${NOVA_DICT} ${network}