blob: 08fb772a13bfa24b257b9124d3df62463ae52c9e [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
Kailash Khalasif6de2592017-09-13 13:37:14 -070020${head_node} head1
Kailash Khalasi2adbad82017-05-15 14:53:40 -070021${SSH_KEY} id_rsa.pub
22${ONOS_CORDVTN_API} http://onos-cord:8182/onos/cordvtn
23${CORE_SERVICE_PATHFILE} ${CURDIR}/data/Service.json
24${CORE_NETWORK_PATHFILE} ${CURDIR}/data/CoreNetwork.json
25${CORE_SLICE_PATHFILE} ${CURDIR}/data/CoreSlice.json
26${CORE_NETWORK_SLICE_PATHFILE} ${CURDIR}/data/CoreNetworkSlice.json
27${CORE_INSTANCE_PATHFILE} ${CURDIR}/data/CoreInstance.json
28${CORD_SUBSCRIBER_PATHFILE} ${CURDIR}/data/CordSubscriber.json
29${VOLT_TENANT_PATHFILE} ${CURDIR}/data/CordVoltTenant.json
Kailash Khalasi3a4e0f52017-06-01 16:35:59 -070030${ciab_local} True
Kailash Khalasi9d8412d2017-06-09 15:00:33 -070031${physical_pod} True
32${default_flow_count} 42
33${final_flow_count} 49
34${expected_num_networks} 4
35${expected_num_ports} 5
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070036
37*** Test Cases ***
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070038Validate Default OVS Flow Count
39 [Documentation] Logs into the compute-node where OVS is running and validates the default flow count
40 [Tags] ovsflows
Kailash Khalasi9d8412d2017-06-09 15:00:33 -070041 Wait Until Keyword Succeeds 30s 5s Validate Flow Count ${default_flow_count}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070042
43Validate Current VTN Service Networks and Ports
Kailash Khalasi2adbad82017-05-15 14:53:40 -070044 [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 -070045 [Tags] vtn pod
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070046 Validate Default CIAB Service Networks and Ports via XOS
Kailash Khalasi2adbad82017-05-15 14:53:40 -070047
48Validate Default Subscriber
49 [Documentation] Validates the default subscriber set up in CIAB (My House)
50 [Tags] vsg
Kailash Khalasif6de2592017-09-13 13:37:14 -070051 ${resp}= CORD GET ${SERVER_IP} ${VOLT_SUBSCRIBER}/5
Kailash Khalasi2adbad82017-05-15 14:53:40 -070052 Should Be Equal As Strings ${resp.status_code} 200
53 Log ${resp.content}
54 ${name}= Get Json Value ${resp.content} /name
55 ${service_specific_id}= Get Json Value ${resp.content} /service_specific_id
56 ${uplink_speed}= Get Json Value ${resp.content} /uplink_speed
57 Should Be Equal As Strings ${name} "My House"
58 Should Be Equal As Strings ${service_specific_id} "123"
59 Should Be Equal As Strings ${uplink_speed} 1000000000
60
61Create New Test Service
62 [Documentation] Creates a generic service that will be used for the new VTN Network
Kailash Khalasi9d8412d2017-06-09 15:00:33 -070063 [Tags] vtn pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -070064 ${updatedcservList}= utils.setFieldValueInDict ${cservlist[0]} name CordVTN-Test-Service
65 ${updatedcservList}= utils.setFieldValueInDict ${updatedcservList} description Test Service for CordVTN Test Suite
66 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_SERVICES} ${updatedcservList}
67 Should Be Equal As Strings ${resp.status_code} 200
68 ${name}= Get Json Value ${resp.content} /name
69 ${generic_service_id}= Get Json Value ${resp.content} /id
70 ${description}= Get Json Value ${resp.content} /description
71 ${kind}= Get Json Value ${resp.content} /kind
72 Should Be Equal As Strings ${name} "CordVTN-Test-Service"
73 Should Be Equal As Strings ${description} "Test Service for CordVTN Test Suite"
74 Should Be Equal As Strings ${kind} "generic"
75 Set Suite Variable ${generic_service_id}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070076
77Create New VTN Service Network
Kailash Khalasi2adbad82017-05-15 14:53:40 -070078 [Documentation] Makes a POST Request to XOS to create a new core network
Kailash Khalasi9d8412d2017-06-09 15:00:33 -070079 [Tags] vtn pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -070080 ${updatedCnList}= utils.setFieldValueInDict ${cnlist[0]} template_id ${vsg_network_template_id}
81 ${updatedCnList}= utils.setFieldValueInDict ${updatedCnList} owner_id ${vsg_slice_id}
82 Log ${updatedCnList}
83 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_NETWORKS} ${cnlist[0]}
84 Should Be Equal As Strings ${resp.status_code} 200
85 ${name}= Get Json Value ${resp.content} /name
86 ${network_id}= Get Json Value ${resp.content} /id
87 ${subnet}= Get Json Value ${resp.content} /subnet
88 ${start_ip}= Get Json Value ${resp.content} /start_ip
89 ${end_ip}= Get Json Value ${resp.content} /end_ip
90 Should Be Equal As Strings ${name} "test-network"
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070091 Should Be Equal As Strings ${subnet} "2.2.2.0/24"
Kailash Khalasi2adbad82017-05-15 14:53:40 -070092 Should Be Equal As Strings ${start_ip} "2.2.2.2"
93 Should Be Equal As Strings ${end_ip} "2.2.2.254"
94 Set Suite Variable ${network_id}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -070095
Kailash Khalasi2adbad82017-05-15 14:53:40 -070096Create New Slice with New Test Service
97 [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 -070098 [Tags] vtn pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -070099 ${updatedCsList}= utils.setFieldValueInDict ${cslist[0]} service_id ${generic_service_id}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700100 #${updatedCsList}= utils.setFieldValueInDict ${cslist[0]} service_id 12
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700101 Log ${updatedCsList}
102 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_SLICES} ${updatedCsList}
103 Should Be Equal As Strings ${resp.status_code} 200
104 ${name}= Get Json Value ${resp.content} /name
105 ${new_slice_id}= Get Json Value ${resp.content} /id
106 ${max_instances}= Get Json Value ${resp.content} /max_instances
107 ${ser_id}= Get Json Value ${resp.content} /service_id
108 ${default_isolation}= Get Json Value ${resp.content} /default_isolation
109 Should Be Equal As Strings ${name} "mysite_testservice"
110 Should Be Equal As Strings ${max_instances} 10
111 Should Be Equal As Strings ${ser_id} ${generic_service_id}
112 Should Be Equal As Strings ${default_isolation} "vm"
113 Set Suite Variable ${new_slice_id}
114
115Add Networks to New Test Network Slice
116 [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 -0700117 [Tags] vsg pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700118 ${updatedCsList}= utils.setFieldValueInDict ${cnslist[0]} network_id ${network_id}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700119 #${updatedCsList}= utils.setFieldValueInDict ${cnslist[0]} network_id 5
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700120 ${updatedCsList}= utils.setFieldValueInDict ${updatedCsList} slice_id ${new_slice_id}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700121 #${updatedCsList}= utils.setFieldValueInDict ${updatedCsList} slice_id 5
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700122 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
Kailash Khalasif6de2592017-09-13 13:37:14 -0700127 #Should Be Equal As Strings ${s_id} 5
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700128 Should Be Equal As Strings ${s_id} ${new_slice_id}
129 Should Be Equal As Strings ${n_id} ${network_id}
130 ##Add mgmt network to this network slice
131 ${updatedCsList}= utils.setFieldValueInDict ${cnslist[0]} network_id ${mgmt_network_id}
132 ${updatedCsList}= utils.setFieldValueInDict ${updatedCsList} slice_id ${new_slice_id}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700133 #${updatedCsList}= utils.setFieldValueInDict ${updatedCsList} slice_id 5
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700134 Log ${updatedCsList}
135 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_NETWORK_SLICES} ${updatedCsList}
136 Should Be Equal As Strings ${resp.status_code} 200
137 ${s_id}= Get Json Value ${resp.content} /slice_id
138 ${n_id}= Get Json Value ${resp.content} /network_id
139 Should Be Equal As Strings ${s_id} ${new_slice_id}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700140 #Should Be Equal As Strings ${s_id} 5
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700141 Should Be Equal As Strings ${n_id} ${mgmt_network_id}
142
143Create New Test Instance
144 [Documentation] Creates a new instance for the test service
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700145 [Tags] vsg pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700146 ${updatedCiList}= utils.setFieldValueInDict ${cilist[0]} slice_id ${new_slice_id}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700147 #${updatedCiList}= utils.setFieldValueInDict ${cilist[0]} slice_id 5
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700148 ${updatedCiList}= utils.setFieldValueInDict ${updatedCiList} image_id ${image_id}
149 Log ${updatedCiList}
150 ${resp}= Cord POST ${SERVER_IP} ${CH_CORE_INSTANCES} ${updatedCiList}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700151 #${resp}= Cord POST ${SERVER_IP} ${CH_CORE_INSTANCES} ${cilist[0]}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700152 Should Be Equal As Strings ${resp.status_code} 200
153 ${new_instance_id}= Get Json Value ${resp.content} /id
154 ${slice_id}= Get Json Value ${resp.content} /slice_id
155 ${i_id}= Get Json Value ${resp.content} /image_id
156 ${node_id}= Get Json Value ${resp.content} /node_id
157 ${name}= Get Json Value ${resp.content} /name
158 ${instance_name}= Get Json Value ${resp.content} /instance_name
159 Should Be Equal As Strings ${slice_id} ${new_slice_id}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700160 #Should Be Equal As Strings ${slice_id} 5
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700161 Should Be Equal As Strings ${i_id} ${image_id}
162 Should Be Equal As Strings ${node_id} 1
163 Should Be Equal As Strings ${name} "mysite_testservice"
164 Should Be Equal As Strings ${instance_name} "mysite_testservice-1"
165 Set Suite Variable ${new_instance_id}
166
167Validate New OVS Flow Count
168 [Documentation] Logs into the compute-node where OVS is running and validates the new flow count (new flow rules for new volt tenant instance)
169 [Tags] ovsflows
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700170 Wait Until Keyword Succeeds 300s 5s Validate Flow Count ${final_flow_count}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700171
172Validate Creation of Openstack Resources
173 [Documentation] Retrieves openstack compute node state and validates the new network and instance has been created properly
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700174 [Tags] openstack pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700175 Wait Until Keyword Succeeds 300s 5s Validate Openstack Network test-network 2.2.2.0/24
Kailash Khalasif6de2592017-09-13 13:37:14 -0700176 Sleep 300
177 ${test_instance_name}= Get New Instance
178 Wait Until Keyword Succeeds 300s 5s Validate Openstack Nova Instance ${test_instance_name} test-network
179 Set Suite Variable ${test_instance_name}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700180
181Validate New Flows Pushed to OVS
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700182 [Documentation] Logs into the compute-node where OVS is running and validates the new flows added
Kailash Khalasi3a4e0f52017-06-01 16:35:59 -0700183 [Tags] ovsflows
Kailash Khalasif6de2592017-09-13 13:37:14 -0700184 ${ovs_flow_count}= Run Keyword If '${ciab_local}' == 'False' Execute Command on Compute Node in CIAB ${SERVER_IP} ${head_node} ${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 -0700185 ${ovs_flow_count}= Get Line ${ovs_flow_count} 0
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700186 Should Be Equal As Integers ${ovs_flow_count} 2
Kailash Khalasif6de2592017-09-13 13:37:14 -0700187 ${flows_added}= Run Keyword If '${ciab_local}' == 'False' Execute Command on Compute Node in CIAB ${SERVER_IP} ${head_node} ${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 -0700188 ${flows_added}= Get Lines Containing String ${flows_added} cookie=
189 Log ${flows_added}
190 ## Match src/dst (bi-directional) rules on new flows added
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700191 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 -0700192
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700193Create New Cord Subscriber
194 [Documentation] Creates a new cord root subscriber
195 [Tags] vsg
196 ${blacklist_sr_ids}= Get Subscriber Root IDs in Use
197 ${ss_id}= Generate Random Number from Blacklist ${blacklist_sr_ids}
198 Set Suite Variable ${ss_id}
199 ${updatedcsList}= utils.setFieldValueInDict ${csubList[0]} service_specific_id ${ss_id}
200 Log ${updatedcsList}
201 ${resp}= Cord POST ${SERVER_IP} ${VOLT_SUBSCRIBER} ${updatedcsList}
202 Should Be Equal As Strings ${resp.status_code} 200
203 ${subscriber_root_id}= Get Json Value ${resp.content} /id
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700204 ${enable_uverse}= Get Json Value ${resp.content} /enable_uverse
205 ${uplink_speed}= Get Json Value ${resp.content} /uplink_speed
206 ${downlink_speed}= Get Json Value ${resp.content} /downlink_speed
207 ${status}= Get Json Value ${resp.content} /status
208 ${is_demo_user}= Get Json Value ${resp.content} /is_demo_user
209 ${service_specific_id}= Get Json Value ${resp.content} /service_specific_id
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700210 Should Be Equal As Strings ${enable_uverse} true
211 Should Be Equal As Strings ${uplink_speed} 1000000011
212 Should Be Equal As Strings ${downlink_speed} 1000000011
213 Should Be Equal As Strings ${status} "enabled"
214 Should Be Equal As Strings ${is_demo_user} false
215 Should Be Equal As Strings ${service_specific_id} "${ss_id}"
216 Set Suite Variable ${service_specific_id}
217 Set Suite Variable ${subscriber_root_id}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700218
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700219Create New Volt Tenant for New Cord Subscriber
220 [Documentation] Creates a new volt tenant for the newly created cord root subscriber
221 [Tags] vsg
222 ${blacklist_tags}= Get Tags in Use
223 Log ${blacklist_tags}
224 ${s_tag}= Generate Random Number from Blacklist ${blacklist_tags} 1 4096 True
225 Append To List ${blacklist_tags} ${s_tag}
226 ${c_tag}= Generate Random Number from Blacklist ${blacklist_tags} 1 4096 True
227 Append To List ${blacklist_tags} ${c_tag}
228 Log ${blacklist_tags}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700229 ${updatedvtList}= utils.setFieldValueInDict ${vtList[0]} service_specific_id ${subscriber_root_id}
230 #${updatedvtList}= utils.setFieldValueInDict ${vtList[0]} subscriber_root_id ${subscriber_root_id}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700231 ${updatedvtList}= utils.setFieldValueInDict ${updatedvtList} s_tag ${s_tag}
232 ${updatedvtList}= utils.setFieldValueInDict ${updatedvtList} c_tag ${c_tag}
233 Log ${updatedvtList}
234 ${resp}= Cord POST ${SERVER_IP} ${VOLT_TENANT} ${vtList[0]}
235 Should Be Equal As Strings ${resp.status_code} 200
236 ${volt_tenant_id}= Get Json Value ${resp.content} /id
Kailash Khalasif6de2592017-09-13 13:37:14 -0700237 Set Suite Variable ${volt_tenant_id}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700238 ${stag}= Get Json Value ${resp.content} /s_tag
239 ${ctag}= Get Json Value ${resp.content} /c_tag
Kailash Khalasif6de2592017-09-13 13:37:14 -0700240 ${ssid}= Get Json Value ${resp.content} /service_specific_id
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700241 Should Be Equal As Strings ${stag} ${s_tag}
242 Should Be Equal As Strings ${ctag} ${c_tag}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700243 Should Be Equal As Strings ${ssid} "${subscriber_root_id}"
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700244
245Validate Creation of New Subscriber Instance
246 [Documentation] Validates instance (vm) for new subscriber is created in the vsg slice
247 [Tags] openstack
Kailash Khalasif6de2592017-09-13 13:37:14 -0700248 Sleep 300
249 ${new_vsg_instance}= Get New Instance
250 Wait Until Keyword Succeeds 300s 5s Validate Openstack Nova Instance ${new_vsg_instance} mysite_vsg-access
251 Set Suite Variable ${new_vsg_instance}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700252
253Delete Volt Tenant
254 [Documentation] Deletes new volt tenant
255 [Tags] delete
256 ${resp}= Cord DELETE ${SERVER_IP} ${VOLT_TENANT} ${volt_tenant_id}
257 Should Be Equal As Strings ${resp.status_code} 200
Kailash Khalasif6de2592017-09-13 13:37:14 -0700258 Wait Until Keyword Succeeds 300s 5s Validate Openstack Nova Instance ${new_vsg_instance} mysite_vsg-access destroyed=True
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700259
260Delete Cord Subscriber
261 [Documentation] Deletes new cord subscriber
Kailash Khalasid01bec62017-05-30 13:53:01 -0700262 [Tags] delete
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700263 ${resp}= Cord DELETE ${SERVER_IP} ${VOLT_SUBSCRIBER} ${subscriber_root_id}
264 Should Be Equal As Strings ${resp.status_code} 200
265
266Delete Test Instance
267 [Documentation] Deletes the test instance created previously
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700268 [Tags] delete pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700269 ${resp}= Cord DELETE ${SERVER_IP} ${CH_CORE_INSTANCES} ${new_instance_id}
270 Should Be Equal As Strings ${resp.status_code} 200
Kailash Khalasif6de2592017-09-13 13:37:14 -0700271 Wait Until Keyword Succeeds 300s 5s Validate Openstack Nova Instance ${test_instance_name} test-network destroyed=True
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700272
273Delete Test Slice
274 [Documentation] Deletes the test slice created previously
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700275 [Tags] delete pod
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700276 ${resp}= Cord DELETE ${SERVER_IP} ${CH_CORE_SLICES} ${new_slice_id}
277 Should Be Equal As Strings ${resp.status_code} 200
278
279Delete VTN Test Network
280 [Documentation] Deletes the test network created previously
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700281 [Tags] delete pod
Kailash Khalasi3a4e0f52017-06-01 16:35:59 -0700282 ## Wait for test network to be destroyed via get neutron lists
283 ##TODO: Find someting to poll on rather than wait 5 mins
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700284 #Sleep 300
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700285 ${resp}= Cord DELETE ${SERVER_IP} ${CH_CORE_NETWORKS} ${network_id}
286 Should Be Equal As Strings ${resp.status_code} 200
287
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700288Delete Test Service
289 [Documentation] Deletes the test service created
290 [Tags] delete pod
291 ${resp}= Cord DELETE ${SERVER_IP} ${CH_CORE_SERVICES} ${generic_service_id}
292 Should Be Equal As Strings ${resp.status_code} 200
293
Kailash Khalasid01bec62017-05-30 13:53:01 -0700294Validate OVS Flow Count Back to Default
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700295 [Documentation] Logs into the compute-node where OVS is running and validates the new flow count (new flow rules for new volt tenant instance)
296 [Tags] ovsflows
Kailash Khalasif6de2592017-09-13 13:37:14 -0700297 Wait Until Keyword Succeeds 60s 5s Validate Flow Count ${default_flow_count}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700298
299Validate New Flows Removed From OVS
300 [Documentation] Validates that the flow rules added by ONOS from the network creation has been removed
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700301 [Tags] ovsflows
Kailash Khalasif6de2592017-09-13 13:37:14 -0700302 ${ovs_flow_count}= Run Keyword If '${ciab_local}' == 'False' Execute Command on Compute Node in CIAB ${SERVER_IP} ${head_node} ${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 -0700303 ${ovs_flow_count}= Get Line ${ovs_flow_count} 0
304 Should Be Equal As Integers ${ovs_flow_count} 0
Kailash Khalasif6de2592017-09-13 13:37:14 -0700305 ${flows_added}= Run Keyword If '${ciab_local}' == 'False' Execute Command on Compute Node in CIAB ${SERVER_IP} ${head_node} ${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 -0700306 ${flows_added}= Get Lines Containing String ${flows_added} cookie=
307 Log ${flows_added}
308 ## Validate flow rules arent in the flows table
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700309 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 -0700310
311*** Keywords ***
312Suite Setup
Kailash Khalasi68f9f632018-04-11 08:09:19 -0700313 ${auth} = Create List ${XOS_USER} ${XOS_PASSWD}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700314 ${HEADERS} Create Dictionary Content-Type=application/json
315 Create Session ${SERVER_IP} http://${SERVER_IP}:${SERVER_PORT} auth=${AUTH} headers=${HEADERS}
316 Read InputFile
317 ${vsg_service_id}= Get ID ${CH_CORE_SERVICES} name vsg
318 Set Suite Variable ${vsg_service_id}
319 ${vsg_network_template_id}= Get ID ${CH_CORE_NETWORK_TEMPLATES} name vsg
320 Set Suite Variable ${vsg_network_template_id}
321 ${mgmt_network_id}= Get ID ${CH_CORE_NETWORKS} name management
322 Set Suite Variable ${mgmt_network_id}
323 ${vsg_slice_id}= Get ID ${CH_CORE_SLICES} name mysite_vsg
324 Set Suite Variable ${vsg_slice_id}
325 ${volt_service_id}= Get ID ${CH_CORE_SERVICES} name volt
326 Set Suite Variable ${volt_service_id}
327 ${image_id}= Get ID ${CH_CORE_IMAGES} name trusty-server-multi-nic
328 Set Suite Variable ${image_id}
329 ##Get compute node information
Kailash Khalasif6de2592017-09-13 13:37:14 -0700330 ${compute_node_hostname}= Run Keyword If '${ciab_local}' == 'False' Execute Command on CIAB Server in Specific VM ${SERVER_IP} ${head_node} cord prov list | grep node | awk '{print $2}' ELSE Execute Command Locally cord prov list | grep node | awk '{print $2}'
331 ${compute_node_ip}= Run Keyword If '${ciab_local}' == 'False' Execute Command on CIAB Server in Specific VM ${SERVER_IP} ${head_node} 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 -0700332 Set Suite Variable ${compute_node_hostname}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700333 Set Suite Variable ${compute_node_ip}
334 Get List of Instances
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700335
336Suite Teardown
337 Delete All Sessions
338 Close All Connections
339
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700340Read InputFile
341 ${coreServiceList} = utils.jsonToList ${CORE_SERVICE_PATHFILE} ServiceInfo
342 Set Suite Variable ${cservlist} ${coreServiceList}
343 ${coreNetworkList} = utils.jsonToList ${CORE_NETWORK_PATHFILE} NetworkInfo
344 Set Suite Variable ${cnlist} ${coreNetworkList}
345 ${coreSliceList} = utils.jsonToList ${CORE_SLICE_PATHFILE} SliceInfo
346 Set Suite Variable ${cslist} ${coreSliceList}
347 ${coreNetworkSliceList} = utils.jsonToList ${CORE_NETWORK_SLICE_PATHFILE} NetworkSliceInfo
348 Set Suite Variable ${cnslist} ${coreNetworkSliceList}
349 ${coreInstanceList} = utils.jsonToList ${CORE_INSTANCE_PATHFILE} InstanceInfo
350 Set Suite Variable ${cilist} ${coreInstanceList}
351 ${cordSubscriberList} = utils.jsonToList ${CORD_SUBSCRIBER_PATHFILE} CordSubscriberInfo
352 Set Suite Variable ${csubList} ${cordSubscriberList}
353 ${voltTenantList} = utils.jsonToList ${VOLT_TENANT_PATHFILE} VoltTenantInfo
354 Set Suite Variable ${vtList} ${voltTenantList}
355
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700356CORD Get
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700357 [Documentation] Make a GET call to the CORD controller
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700358 [Arguments] ${session} ${service}
359 ${resp}= Get Request ${session} ${service}
360 Log ${resp.content}
361 [Return] ${resp}
362
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700363CORD Post
364 [Documentation] Make a POST call to the CORD controller
365 [Arguments] ${session} ${service} ${data}
366 ${data}= Evaluate json.dumps(${data}) json
367 ${resp}= Post Request ${session} uri=${service} data=${data}
368 Log ${resp.content}
369 [Return] ${resp}
370
371CORD Delete
372 [Documentation] Make a DELETE call to the CORD controller
373 [Arguments] ${session} ${service} ${id}
374 ${resp}= Delete Request ${session} uri=${service}/${id}
375 Log ${resp.content}
376 [Return] ${resp}
377
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700378Validate Default CIAB Service Networks and Ports via XOS
379 [Documentation] Using XOS API, this validates the default VTN Service Networks + Ports for a CIAB Environment
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700380 @{expected_network_names}= Create List public management exampleservice_network mysite_vsg-access
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700381 Run Keyword If '${physical_pod}' == 'True' Remove Values From List ${expected_network_names} exampleservice_network
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700382 @{names}= Create List
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700383 @{network_names}= Create List
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700384 ${resp}= CORD GET ${SERVER_IP} ${CH_CORE_NETWORKS}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700385 Should Be Equal As Strings ${resp.status_code} 200
386 ${jsondata}= To Json ${resp.content}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700387 Log ${jsondata}
388 ${length}= Get Length ${jsondata['items']}
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700389 Should Be Equal As Integers ${length} ${expected_num_networks}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700390 : FOR ${INDEX} IN RANGE 0 ${length}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700391 \ ${item}= Get From List ${jsondata['items']} ${INDEX}
392 \ ${name}= Get From Dictionary ${item} name
393 \ Append To List ${names} ${name}
394 : FOR ${value} IN @{expected_network_names}
395 \ List Should Contain Value ${names} ${value}
396 ${resp}= CORD GET ${SERVER_IP} ${CH_CORE_PORTS}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700397 Should Be Equal As Strings ${resp.status_code} 200
398 ${jsondata}= To Json ${resp.content}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700399 ${length}= Get Length ${jsondata['items']}
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700400 Should Be Equal As Integers ${length} ${expected_num_ports}
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700401
402Validate Default CIAB Service Networks via ONOSCORD
403 [Documentation] Validates the default VTN Service Network via ONOSCORD for a CIAB Environment
404 [Arguments] ${jsondata}
405 @{network_ids}= Create List
406 @{expected_types}= Create List PUBLIC PRIVATE MANAGEMENT_LOCAL VSG
407 @{expected_names}= Create List public exampleservice_network management mysite_vsg-access
Kailash Khalasi9d8412d2017-06-09 15:00:33 -0700408 Run Keyword If '${physical_pod}' == 'True' Remove From List ${expected_types} VSG
409 Run Keyword If '${physical_pod}' == 'True' Remove From List ${expected_names} exampleservice_network
Kailash Khalasib6e87fc2017-04-18 15:08:19 -0700410 @{types}= Create List
411 @{names}= Create List
412 ${jsondata}= To Json ${jsondata}
413 ${length}= Get Length ${jsondata['ServiceNetworks']}
414 Should Be Equal As Integers ${length} 4
415 : FOR ${INDEX} IN RANGE 0 ${length}
416 \ ${item}= Get From List ${jsondata['ServiceNetworks']} ${INDEX}
417 \ ${network_id}= Get From Dictionary ${item} id
418 \ ${type}= Get From Dictionary ${item} type
419 \ ${name}= Get From Dictionary ${item} name
420 \ Append To List ${network_ids} ${network_id}
421 \ Append To List ${types} ${type}
422 \ Append To List ${names} ${name}
423 \ Run Keyword If "${name}" == "management" Set Suite Variable ${management_network_id} ${network_id}
424 \ Run Keyword If "${name}" == "public" Set Suite Variable ${public_network_id} ${network_id}
425 : FOR ${value} IN @{expected_types}
426 \ List Should Contain Value ${types} ${value}
427 : FOR ${value} IN @{expected_names}
428 \ List Should Contain Value ${names} ${value}
429 Set Suite Variable ${network_ids}
430
431Validate Default CIAB Service Ports via ONOSCORD
432 [Documentation] Validates the default VTN Service Ports via ONOSCORD for a CIAB Environment
433 [Arguments] ${jsondata}
434 ${net_ids}= Create List
435 ${jsondata}= To Json ${jsondata}
436 ${length}= Get Length ${jsondata['ServicePorts']}
437 Should Be Equal As Integers ${length} 5
438 : FOR ${INDEX} IN RANGE 0 ${length}
439 \ ${item}= Get From List ${jsondata['ServicePorts']} ${INDEX}
440 \ ${net_id}= Get From Dictionary ${item} network_id
441 \ Append To List ${net_ids} ${net_id}
442 : FOR ${value} IN @{net_ids}
443 \ List Should Contain Value ${network_ids} ${value}
444 ${management_len}= Count Values in List ${net_ids} ${management_network_id}
445 Should Be Equal As Integers ${management_len} 2
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700446
447Get ID
448 [Documentation] Retreives the id of any specific component
449 [Arguments] ${endpoint} ${item} ${match}
450 ${resp}= CORD GET ${SERVER_IP} ${endpoint}
451 Should Be Equal As Strings ${resp.status_code} 200
452 ${jsondata}= To Json ${resp.content}
453 Log ${jsondata}
454 ${length}= Get Length ${jsondata['items']}
455 : FOR ${INDEX} IN RANGE 0 ${length}
456 \ ${value}= Get From List ${jsondata['items']} ${INDEX}
457 \ ${name}= Get From Dictionary ${value} ${item}
458 \ ${id}= Get From Dictionary ${value} id
459 \ Run Keyword If '${name}' == '${match}' Exit For Loop
460 [Return] ${id}
461
462Validate Flow Count
463 [Documentation] Gets the count of the flows pushed to an ovs switch and validates that against expected count
464 [Arguments] ${count}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700465 ${ovs_flow_count}= Run Keyword If '${ciab_local}' == 'False' Execute Command on Compute Node in CIAB ${SERVER_IP} ${head_node} ${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 -0700466 ${ovs_flow_count}= Get Line ${ovs_flow_count} 0
467 Should Be Equal As Integers ${ovs_flow_count} ${count}
468
469Get Subscriber Root IDs in Use
470 [Documentation] Retrieves information for current subscribers and "blacklists" their subscriber root ids
471 @{sr_id_blacklist}= Create List
472 ${resp}= CORD GET ${SERVER_IP} ${VOLT_SUBSCRIBER}
473 ${jsondata}= To Json ${resp.content}
474 ${length}= Get Length ${jsondata['items']}
475 : FOR ${INDEX} IN RANGE 0 ${length}
476 \ ${item}= Get From List ${jsondata['items']} ${INDEX}
477 \ ${id}= Get From Dictionary ${item} service_specific_id
478 \ Append To List ${sr_id_blacklist} ${id}
479 [Return] @{sr_id_blacklist}
480
481Get Tags in Use
482 [Documentation] Retrieves information for current active volt tenants and "blacklists" their s/c tags
483 @{tag_blacklist}= Create List
484 ${resp}= CORD GET ${SERVER_IP} ${VOLT_TENANT}
485 ${jsondata}= To Json ${resp.content}
486 ${length}= Get Length ${jsondata['items']}
487 : FOR ${INDEX} IN RANGE 0 ${length}
488 \ ${item}= Get From List ${jsondata['items']} ${INDEX}
489 \ ${s_tag}= Get From Dictionary ${item} s_tag
490 \ ${c_tag}= Get From Dictionary ${item} c_tag
491 \ Append To List ${tag_blacklist} ${s_tag}
492 \ Append To List ${tag_blacklist} ${c_tag}
493 [Return] @{tag_blacklist}
494
495Get Openstack Info
Kailash Khalasif6de2592017-09-13 13:37:14 -0700496 [Documentation] Executes a command in the headnode vm in a CIAB environment where openstack is running
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700497 [Arguments] ${cmd}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700498 ${output}= Run Keyword If '${ciab_local}' == 'False' Execute Command on CIAB Server in Specific VM ${SERVER_IP} ${head_node} source /opt/cord_profile/admin-openrc.sh; ${cmd} strip_line=False ELSE Execute Command Locally . /opt/cord_profile/admin-openrc.sh; ${cmd}
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700499 Log ${output}
500 [Return] ${output}
501
502Validate Openstack Network
503 [Documentation] Validates that a particular network/subnet exists
Kailash Khalasif6de2592017-09-13 13:37:14 -0700504 [Arguments] ${network_name} ${subnet} ${destroyed}=False
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700505 ${netlist}= Get Openstack Info neutron net-list
506 Log ${netlist}
507 ${NET_DICT}= openstackUtils.Get Neutron Lists ${netlist}
508 Log ${NET_DICT}
509 ${test-net}= Get From Dictionary ${NET_DICT} ${network_name}
510 Should Contain ${test-net} ${subnet}
511
Kailash Khalasif6de2592017-09-13 13:37:14 -0700512
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700513Validate Openstack Nova Instance
514 [Documentation] Validates that a particular nova instance/tenant exists
515 [Arguments] ${instance_name} ${network} ${destroyed}=False
516 ${novalist}= Get Openstack Info nova list --all-tenants
517 Log ${novalist}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700518 Run Keyword If '${destroyed}' == 'True' Should Not Contain ${novalist} ${instance_name}
519 ${INSTANCE_STATUS}= openstackUtils.Get Instance Status ${novalist} ${instance_name}
520 Run Keyword If '${destroyed}' == 'False' Should Contain ${INSTANCE_STATUS} ACTIVE
Kailash Khalasi2adbad82017-05-15 14:53:40 -0700521 ${NOVA_DICT}= openstackUtils.Get Nova Lists ${novalist} ${instance_name}
Kailash Khalasif6de2592017-09-13 13:37:14 -0700522 Run Keyword If '${destroyed}' == 'False' Should Contain ${NOVA_DICT} ${network}
523
524Get List of Instances
525 ${instances}= Create List
526 Set Suite Variable ${instances}
527 ${resp}= Cord GET ${SERVER_IP} ${CH_CORE_INSTANCES}
528 Should Be Equal As Strings ${resp.status_code} 200
529 ${jsondata}= To Json ${resp.content}
530 Log ${jsondata}
531 ${instance_length}= Get Length ${jsondata['items']}
532 : FOR ${INDEX} IN RANGE 0 ${instance_length}
533 \ ${item}= Get From List ${jsondata['items']} ${INDEX}
534 \ ${name}= Get From Dictionary ${item} instance_name
535 \ Append To List ${instances} ${name}
536 Log ${instances}
537 Set Suite Variable ${instance_length}
538
539Get New Instance
540 ${new_instance}= Set Variable null
541 ${resp}= Cord GET ${SERVER_IP} ${CH_CORE_INSTANCES}
542 Should Be Equal As Strings ${resp.status_code} 200
543 ${jsondata}= To Json ${resp.content}
544 Log ${jsondata}
545 ${length}= Get Length ${jsondata['items']}
546 : FOR ${INDEX} IN RANGE 0 ${length}
547 \ ${item}= Get From List ${jsondata['items']} ${INDEX}
548 \ ${name}= Get From Dictionary ${item} instance_name
549 \ ${passed}= Run Keyword And Return Status List Should Contain Value ${instances} ${name}
550 \ ${new_instance}= Set Variable If '${passed}' == 'False' ${name} ${new_instance}
551 Log ${new_instance}
552 Append To List ${instances} ${new_instance}
553 [Return] ${new_instance}