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