blob: d2faa28e75e9570bffcb75f210f9285c81a9ef3f [file] [log] [blame]
Hardik Windlassb9bdd502020-04-17 14:46:21 +05301# Copyright 2017 - present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# FIXME Can we use the same test against BBSim and Hardware?
15
16*** Settings ***
17Documentation Test various end-to-end scenarios
18Suite Setup Setup Suite
19Test Setup Setup
20Test Teardown Teardown
21Suite Teardown Teardown Suite
22Library Collections
23Library String
24Library OperatingSystem
25Library XML
26Library RequestsLibrary
27Library ../../libraries/DependencyLibrary.py
28Resource ../../libraries/onos.robot
29Resource ../../libraries/voltctl.robot
30Resource ../../libraries/voltha.robot
31Resource ../../libraries/utils.robot
32Resource ../../libraries/k8s.robot
33Resource ../../variables/variables.robot
34
35*** Variables ***
36${POD_NAME} flex-ocp-cord
37${KUBERNETES_CONF} ${KUBERNETES_CONFIGS_DIR}/${POD_NAME}.conf
38${KUBERNETES_CONFIGS_DIR} ~/pod-configs/kubernetes-configs
39#${KUBERNETES_CONFIGS_DIR} ${KUBERNETES_CONFIGS_DIR}/${POD_NAME}.conf
40${KUBERNETES_YAML} ${KUBERNETES_CONFIGS_DIR}/${POD_NAME}.yml
41${HELM_CHARTS_DIR} ~/helm-charts
42${VOLTHA_POD_NUM} 8
43${NAMESPACE} voltha
44# For below variable value, using deployment name as using grep for
45# parsing radius pod name, we can also use full radius pod name
46${RESTART_POD_NAME} radius
47${timeout} 60s
48${of_id} 0
49${logical_id} 0
50${has_dataplane} True
51${teardown_device} False
52${scripts} ../../scripts
53
54# Per-test logging on failure is turned off by default; set this variable to enable
55${container_log_dir} ${None}
56
57*** Test Cases ***
58Verify ONU after Rebooting Physically for DT
59 [Documentation] Test the ONU functionality by physically turning on/off ONU.
60 ... Assuming that all the ONUs are DHCP/pingable (i.e. assuming sanityDt test was executed)
61 ... Test case runs only on the PODs that are configured with PowerSwitch that
62 ... controls the power off/on ONUs/OLT remotely (simulating a physical reboot)
63 [Tags] functionalDt PowerSwitchOnuRebootDt VOL-2819 PowerSwitch
Hardik Windlass9df139e2020-04-24 14:54:54 +053064 [Setup] Start Logging RebootOnu_PowerSwitch_Dt
Hardik Windlassb9bdd502020-04-17 14:46:21 +053065 [Teardown] Run Keywords Collect Logs
66 ... AND Stop Logging RebootOnu_PowerSwitch_Dt
67 ... AND Delete Device and Verify
68 # Add OLT device
69 Setup
70 # Performing Sanity Test to make sure subscribers are all DHCP and pingable
71 Run Keyword If ${has_dataplane} Clean Up Linux
72 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test DT
73 Power Switch Connection Suite ${web_power_switch.ip} ${web_power_switch.user} ${web_power_switch.password}
74 FOR ${I} IN RANGE 0 ${num_onus}
75 ${src}= Set Variable ${hosts.src[${I}]}
76 ${dst}= Set Variable ${hosts.dst[${I}]}
77 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
78 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
79 Disable Switch Outlet ${src['power_switch_port']}
80 Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure
81 ... Wait Until Keyword Succeeds 60s 2s
82 ... Check Ping False ${dst['dp_iface_ip_qinq']} ${src['dp_iface_name']}
83 ... ${src['ip']} ${src['user']} ${src['pass']} ${src['container_type']} ${src['container_name']}
84
85 Enable Switch Outlet ${src['power_switch_port']}
86 # Check ONU port is Enabled in ONOS
87 Run Keyword And Continue On Failure Wait Until Keyword Succeeds 120s 2s
88 ... Verify ONU Port Is Enabled ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${onu_port}
89 # Verify ONU state in voltha
90 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s Validate Device
91 ... ENABLED ACTIVE REACHABLE
92 ... ${src['onu']} onu=True onu_reason=omci-flows-pushed
93 # Verify subscriber access flows are added for the ONU port
94 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
95 ... Verify Subscriber Access Flows Added For ONU DT ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
96 ... ${onu_port} ${nni_port} ${src['s_tag']}
97 Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure
98 ... Wait Until Keyword Succeeds 60s 2s
99 ... Check Ping True ${dst['dp_iface_ip_qinq']} ${src['dp_iface_name']}
100 ... ${src['ip']} ${src['user']} ${src['pass']} ${src['container_type']} ${src['container_name']}
101 Run Keyword And Ignore Error Collect Logs
102 END
103 # Verify ONOS Flows
104 # Number of Access Flows on ONOS equals 4 * the Number of Active ONUs (2 for each downstream and upstream)
105 ${onos_flows_count}= Evaluate 4 * ${num_onus}
106 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
107 ... Verify Subscriber Access Flows Added Count DT ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
108 ... ${of_id} ${onos_flows_count}
109 # Verify VOLTHA Flows
110 # Number of per OLT Flows equals Twice the Number of Active ONUs (each for downstream and upstream) + 1 for LLDP
111 ${olt_flows}= Evaluate 2 * ${num_onus} + 1
112 # Number of per ONU Flows equals 2 (one each for downstream and upstream)
113 ${onu_flows}= Set Variable 2
114 Run Keyword Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Flows ${olt_flows}
115 ${List_ONU_Serial} Create List
116 Set Suite Variable ${List_ONU_Serial}
117 Build ONU SN List ${List_ONU_Serial}
118 Log ${List_ONU_Serial}
119 Run Keyword Wait Until Keyword Succeeds ${timeout} 5s Validate ONU Flows
120 ... ${List_ONU_Serial} ${onu_flows}
121
122Verify OLT after Rebooting Physically for DT
123 [Documentation] Test the physical reboot of the OLT
124 ... Assuming that all the ONUs are DHCP/pingable (i.e. assuming sanityDt test was executed)
125 ... Test performs a physical reboot, performs "reboot" from the OLT CLI
126 [Tags] functionalDt PhysicalOltRebootDt VOL-2817
Hardik Windlass9df139e2020-04-24 14:54:54 +0530127 [Setup] Start Logging RebootOlt_Physical_Dt
Hardik Windlassb9bdd502020-04-17 14:46:21 +0530128 [Teardown] Run Keywords Collect Logs
129 ... AND Stop Logging RebootOlt_Physical_Dt
130 ... AND Delete Device and Verify
131 # Add OLT device
132 Setup
133 # Performing Sanity Test to make sure subscribers are all DHCP and pingable
134 Run Keyword If ${has_dataplane} Clean Up Linux
135 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test DT
136 # Reboot the OLT from the OLT CLI
137 Run Keyword If ${has_dataplane} Login And Run Command On Remote System
138 ... sudo reboot ${olt_ip} ${olt_user} ${olt_pass} prompt=#
139 Run Keyword And Ignore Error Collect Logs
140 FOR ${I} IN RANGE 0 ${num_onus}
141 ${src}= Set Variable ${hosts.src[${I}]}
142 ${dst}= Set Variable ${hosts.dst[${I}]}
143 Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure
144 ... Wait Until Keyword Succeeds 60s 2s
145 ... Check Ping False ${dst['dp_iface_ip_qinq']} ${src['dp_iface_name']}
146 ... ${src['ip']} ${src['user']} ${src['pass']} ${src['container_type']} ${src['container_name']}
147 END
148 # Wait for the OLT to come back up
149 Run Keyword If ${has_dataplane} Wait Until Keyword Succeeds 120s 10s
150 ... Check Remote System Reachability True ${olt_ip}
151 # Waiting extra time for the ONUs to come up
152 Sleep 60s
153 Run Keyword And Ignore Error Collect Logs
154 Run Keyword If ${has_dataplane} Clean Up Linux
155 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test DT
156
Hardik Windlass9df139e2020-04-24 14:54:54 +0530157Verify restart openolt-adapter container after subscriber provisioning for DT
158 [Documentation] Restart openolt-adapter container after VOLTHA is operational.
159 ... Prerequisite : ONUs are authenticated and pingable.
160 [Tags] functionalDt Restart-OpenOlt-Dt
161 [Setup] Start Logging Restart-OpenOlt-Dt
162 [Teardown] Run Keywords Collect Logs
163 ... AND Stop Logging Restart-OpenOlt-Dt
164 # Add OLT device
165 setup
166 # Performing Sanity Test to make sure subscribers are all DHCP and pingable
167 Run Keyword If ${has_dataplane} Clean Up Linux
168 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test DT
169 ${waitforRestart} Set Variable 120s
170 ${podStatusOutput}= Run kubectl get pods -n ${NAMESPACE}
171 Log ${podStatusOutput}
172 ${countBforRestart}= Run kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
173 ${podName} Set Variable adapter-open-olt
174 Restart Pod ${NAMESPACE} ${podName}
175 Wait Until Keyword Succeeds ${waitforRestart} 2s Validate Pod Status ${podName} ${NAMESPACE}
176 ... Running
177 # Wait for 1min after openolt adapter is restarted
178 Sleep 60s
179 Run Keyword If ${has_dataplane} Clean Up Linux
180 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test DT
181 Run Keyword and Ignore Error Collect Logs
182 ${podStatusOutput}= Run kubectl get pods -n ${NAMESPACE}
183 Log ${podStatusOutput}
184 ${countAfterRestart}= Run kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
185 Should Be Equal As Strings ${countAfterRestart} ${countBforRestart}
186 Log to console Pod ${podName} restarted and sanity checks passed successfully
187
188Verify openolt adapter restart before subscriber provisioning for DT
189 [Documentation] Deploys an device instance and waits for it to authenticate. After
190 ... authentication is successful the rw-core deployment is scaled to 0 instances to
191 ... simulate a POD crash. The test then scales the rw-core back to a single instance
192 ... and configures ONOS for access. The test succeeds if the device is able to
193 ... complete the DHCP sequence.
194 [Tags] functionalDt olt-adapter-restart-Dt
195 [Setup] Start Logging OltAdapterRestart-Dt
196 #... AND Clear All Devices Then Create New Device
197 [Teardown] Run Keywords Collect Logs
198 ... AND Stop Logging OltAdapterRestart-Dt
199 # Add OLT and perform sanity test
200 #setup
201 Run Keyword If ${has_dataplane} Clean Up Linux
202 #Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test
203 Set Global Variable ${of_id}
204
205 FOR ${I} IN RANGE 0 ${num_onus}
206 ${src}= Set Variable ${hosts.src[${I}]}
207 ${dst}= Set Variable ${hosts.dst[${I}]}
208 ${onu_device_id}= Get Device ID From SN ${src['onu']}
209 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']}
210 ... ${of_id}
211 # Bring up the device and verify it authenticates
212 Wait Until Keyword Succeeds ${timeout} 5s Validate Device ENABLED ACTIVE REACHABLE
213 ... ${onu_device_id} onu=True onu_reason=omci-flows-pushed
214 END
215 # Scale down the open OLT adapter deployment to 0 PODs and once confirmed, scale it back to 1
216 Scale K8s Deployment voltha adapter-open-olt 0
217 Wait Until Keyword Succeeds ${timeout} 2s Pod Does Not Exist voltha adapter-open-olt
218 # Scale up the open OLT adapter deployment and make sure both it and the ofagent deployment are back
219 Scale K8s Deployment voltha adapter-open-olt 1
220 Wait Until Keyword Succeeds ${timeout} 2s
221 ... Check Expected Available Deployment Replicas voltha adapter-open-olt 1
222
223 # Ensure the device is available in ONOS, this represents system connectivity being restored
224 Wait Until Keyword Succeeds ${timeout} 2s Device Is Available In ONOS
225 ... http://karaf:karaf@${ONOS_REST_IP}:${ONOS_REST_PORT} ${of_id}
226
227 FOR ${I} IN RANGE 0 ${num_onus}
228 # Add subscriber access and verify that DHCP completes to ensure system is still functioning properly
229 Wait Until Keyword Succeeds ${timeout} 2s Execute ONOS CLI Command ${ONOS_SSH_IP}
230 ... ${ONOS_SSH_PORT} volt-add-subscriber-access ${of_id} ${onu_port}
231 # Verify subscriber access flows are added for the ONU port
232 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
233 ... Verify Subscriber Access Flows Added For ONU DT ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
234 ... ${onu_port} ${nni_port} ${src['s_tag']}
235 Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure Validate DHCP and Ping True
236 ... True ${src['dp_iface_name']} ${src['s_tag']} ${src['c_tag']} ${dst['dp_iface_ip_qinq']}
237 ... ${src['ip']} ${src['user']} ${src['pass']} ${src['container_type']} ${src['container_name']}
238 ... ${dst['dp_iface_name']} ${dst['ip']} ${dst['user']} ${dst['pass']} ${dst['container_type']}
239 ... ${dst['container_name']}
240 END
241
242Verify restart ofagent container after subscriber is provisioned for DT
243 [Documentation] Restart ofagent container after VOLTHA is operational.
244 ... Prerequisite : ONUs are authenticated and pingable.
245 [Tags] functionalDt ofagentRestart-Dt
246 [Setup] Start Logging ofagentRestart-Dt
247 [Teardown] Run Keywords Collect Logs
248 ... AND Stop Logging ofagentRestart-Dt
249 ... AND Scale K8s Deployment ${NAMESPACE} voltha-ofagent 1
250 # set timeout value
251 ${waitforRestart} Set Variable 120s
252 ${podStatusOutput}= Run kubectl get pods -n ${NAMESPACE}
253 Log ${podStatusOutput}
254 ${countBforRestart}= Run kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
255 ${podName} Set Variable ofagent
256 Restart Pod ${NAMESPACE} ${podName}
257 Sleep 60s
258 Wait Until Keyword Succeeds ${waitforRestart} 2s Validate Pod Status ofagent ${NAMESPACE}
259 ... Running
260 # Performing Sanity Test to make sure subscribers are all DHCP and pingable
261 Run Keyword If ${has_dataplane} Clean Up Linux
262 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test DT
263 ${podStatusOutput}= Run kubectl get pods -n ${NAMESPACE}
264 Log ${podStatusOutput}
265 ${countAfterRestart}= Run kubectl get pods -n ${NAMESPACE} | grep Running | wc -l
266 Should Be Equal As Strings ${countAfterRestart} ${countBforRestart}
267 # Scale Down the Of-Agent Deployment
268 Scale K8s Deployment ${NAMESPACE} voltha-ofagent 0
269 Sleep 30s
270 FOR ${I} IN RANGE 0 ${num_onus}
271 ${src}= Set Variable ${hosts.src[${I}]}
272 ${dst}= Set Variable ${hosts.dst[${I}]}
273 Run Keyword and Ignore Error Collect Logs
274 ${onu_device_id}= Get Device ID From SN ${src['onu']}
275 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
276 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
277 # Verify ONU state in voltha
278 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s Validate Device
279 ... ENABLED ACTIVE REACHABLE
280 ... ${src['onu']} onu=True onu_reason=omci-flows-pushed
281 # Check ONU port is Disabled in ONOS
282 Run Keyword And Continue On Failure Wait Until Keyword Succeeds 120s 2s
283 ... Verify ONU Port Is Disabled ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${onu_port}
284 # Verify subscriber access flows are added for the ONU port
285 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
286 ... Verify Subscriber Access Flows Added For ONU DT ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
287 ... ${onu_port} ${nni_port} ${src['s_tag']}
288 # Verify Ping
289 Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure Check Ping True
290 ... ${dst['dp_iface_ip_qinq']} ${src['dp_iface_name']} ${src['ip']}
291 ... ${src['user']} ${src['pass']} ${src['container_type']} ${src['container_name']}
292 Run Keyword and Ignore Error Get Device Output from Voltha ${onu_device_id}
293 Run Keyword and Ignore Error Collect Logs
294 END
295 # Scale Up the Of-Agent Deployment
296 Scale K8s Deployment ${NAMESPACE} voltha-ofagent 1
297 Wait Until Keyword Succeeds ${waitforRestart} 2s Validate Pod Status ofagent ${NAMESPACE}
298 ... Running
299 # Performing Sanity Test to make sure subscribers are all DHCP and pingable
300 Run Keyword If ${has_dataplane} Clean Up Linux
301 Wait Until Keyword Succeeds ${timeout} 2s Perform Sanity Test DT
302 Log to console Pod ${podName} restarted and sanity checks passed successfully
303
304Sanity E2E Test for OLT/ONU on POD With Core Fail and Restart for DT
305 [Documentation] Deploys an device instance and waits for it to authenticate. After
306 ... authentication is successful the rw-core deployment is scaled to 0 instances to
307 ... simulate a POD crash. The test then scales the rw-core back to a single instance
308 ... and configures ONOS for access. The test succeeds if the device is able to
309 ... complete the DHCP sequence.
310 [Tags] functionalDt rwcore-restart-Dt
311 [Setup] Run Keywords Start Logging RwCoreFailAndRestart-Dt
312 ... AND Clear All Devices Then Create New Device
313 [Teardown] Run Keywords Collect Logs
314 ... AND Stop Logging RwCoreFailAndRestart-Dt
315 #... AND Delete Device and Verify
316 Run Keyword and Ignore Error Collect Logs
317 Run Keyword If ${has_dataplane} Clean Up Linux
318 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS ${olt_serial_number}
319 Set Global Variable ${of_id}
320 ${nni_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
321 ... Get NNI Port in ONOS ${of_id}
322 Set Global Variable ${nni_port}
323 FOR ${I} IN RANGE 0 ${num_onus}
324 ${src}= Set Variable ${hosts.src[${I}]}
325 ${dst}= Set Variable ${hosts.dst[${I}]}
326 ${onu_device_id}= Get Device ID From SN ${src['onu']}
327 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']}
328 ... ${of_id}
329 # Bring up the device and verify it authenticates
330 Wait Until Keyword Succeeds ${timeout} 5s Validate Device ENABLED ACTIVE REACHABLE
331 ... ${onu_device_id} onu=True onu_reason=initial-mib-downloaded
332 END
333
334 # Scale down the rw-core deployment to 0 PODs and once confirmed, scale it back to 1
335 Scale K8s Deployment voltha voltha-rw-core 0
336 Wait Until Keyword Succeeds ${timeout} 2s Pod Does Not Exist voltha voltha-rw-core
337 # Ensure the ofagent POD goes "not-ready" as expected
338 Wait Until keyword Succeeds ${timeout} 2s
339 ... Check Expected Available Deployment Replicas voltha voltha-ofagent 0
340 # Scale up the core deployment and make sure both it and the ofagent deployment are back
341 Scale K8s Deployment voltha voltha-rw-core 1
342 Wait Until Keyword Succeeds ${timeout} 2s
343 ... Check Expected Available Deployment Replicas voltha voltha-rw-core 1
344 Wait Until Keyword Succeeds ${timeout} 2s
345 ... Check Expected Available Deployment Replicas voltha voltha-ofagent 1
346 # For some reason scaling down and up the POD behind a service causes the port forward to stop working,
347 # so restart the port forwarding for the API service
348 Restart VOLTHA Port Foward voltha-api-minimal
349 # Ensure that the ofagent pod is up and ready and the device is available in ONOS, this
350 # represents system connectivity being restored
351 Wait Until Keyword Succeeds ${timeout} 2s Device Is Available In ONOS
352 ... http://karaf:karaf@${ONOS_REST_IP}:${ONOS_REST_PORT} ${of_id}
353
354 FOR ${I} IN RANGE 0 ${num_onus}
355 # Add subscriber access and verify that DHCP completes to ensure system is still functioning properly
356 Wait Until Keyword Succeeds ${timeout} 2s Execute ONOS CLI Command ${ONOS_SSH_IP}
357 ... ${ONOS_SSH_PORT} volt-add-subscriber-access ${of_id} ${onu_port}
358 # Verify subscriber access flows are added for the ONU port
359 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
360 ... Verify Subscriber Access Flows Added For ONU DT ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
361 ... ${onu_port} ${nni_port} ${src['s_tag']}
362 Run Keyword If ${has_dataplane} Run Keyword And Continue On Failure Validate DHCP and Ping True
363 ... True ${src['dp_iface_name']} ${src['s_tag']} ${src['c_tag']} ${dst['dp_iface_ip_qinq']}
364 ... ${src['ip']} ${src['user']} ${src['pass']} ${src['container_type']} ${src['container_name']}
365 ... ${dst['dp_iface_name']} ${dst['ip']} ${dst['user']} ${dst['pass']} ${dst['container_type']}
366 ... ${dst['container_name']}
367 END
368
Hardik Windlassb9bdd502020-04-17 14:46:21 +0530369*** Keywords ***
370Setup Suite
371 [Documentation] Set up the test suite
372 Common Test Suite Setup
373
374Clear All Devices Then Create New Device
375 [Documentation] Remove any devices from VOLTHA and ONOS
376 # Remove all devices from voltha and nos
377 Delete All Devices and Verify
378 # Execute normal test Setup Keyword
379 Setup
380