blob: 2d01d047d8ab72336be125367e3d779d1820c311 [file] [log] [blame]
TorstenThieme1619db22020-04-03 12:01:15 +00001*** Settings ***
2Documentation Test states of ONU Go adapter
3Suite Setup Setup Suite
4Suite Teardown Teardown Suite
5Test Setup Setup
6Test Teardown Teardown
7Library Collections
8Library String
9Library OperatingSystem
10Library XML
11Library RequestsLibrary
12Library ../../libraries/DependencyLibrary.py
13Resource ../../libraries/onos.robot
14Resource ../../libraries/voltctl.robot
15Resource ../../libraries/voltha.robot
16Resource ../../libraries/utils.robot
17Resource ../../libraries/k8s.robot
18Resource ../../variables/variables.robot
19
20*** Variables ***
21${POD_NAME} flex-ocp-cord
22${KUBERNETES_CONF} ${KUBERNETES_CONFIGS_DIR}/${POD_NAME}.conf
23${KUBERNETES_CONFIGS_DIR} ~/pod-configs/kubernetes-configs
24#${KUBERNETES_CONFIGS_DIR} ${KUBERNETES_CONFIGS_DIR}/${POD_NAME}.conf
25${KUBERNETES_YAML} ${KUBERNETES_CONFIGS_DIR}/${POD_NAME}.yml
26${HELM_CHARTS_DIR} ~/helm-charts
27${VOLTHA_POD_NUM} 8
28${NAMESPACE} voltha
29# For below variable value, using deployment name as using grep for
30# parsing radius pod name, we can also use full radius pod name
31${RESTART_POD_NAME} radius
TorstenThieme94e4ae42020-05-18 13:01:42 +000032${timeout} 180s
TorstenThieme1619db22020-04-03 12:01:15 +000033${of_id} 0
34${logical_id} 0
35${has_dataplane} True
36${external_libs} True
37${teardown_device} True
38${scripts} ../../scripts
39# Per-test logging on failure is turned off by default; set this variable to enable
40${container_log_dir} ${None}
TorstenThiemee0e5bba2020-08-05 11:20:13 +000041# state to test variable, can be passed via the command line too, valid values: 1-6
42# 1 -> activating-onu
43# 2 -> starting-openomci
44# 3 -> discovery-mibsync-complete
45# 4 -> initial-mib-downloaded
46# 5 -> tech-profile-config-download-success
47# 6 -> omci-flows-pushed
TorstenThieme87cd6202020-09-09 10:01:28 +000048# example: -v state2test:5
TorstenThieme1619db22020-04-03 12:01:15 +000049${state2test} 6
TorstenThiemee0e5bba2020-08-05 11:20:13 +000050# test mode variable, can be passed via the command line too, valid values: SingleState, Up2State, SingleStateTime
TorstenThieme87cd6202020-09-09 10:01:28 +000051# example: -v testmode:SingleStateTime
TorstenThieme1619db22020-04-03 12:01:15 +000052${testmode} SingleState
TorstenThiemee0e5bba2020-08-05 11:20:13 +000053# flag for execute Tech Profile check, can be passed via the command line too
TorstenThieme87cd6202020-09-09 10:01:28 +000054# example: -v profiletest:False
TorstenThiemee0e5bba2020-08-05 11:20:13 +000055${profiletest} True
TorstenThieme87cd6202020-09-09 10:01:28 +000056# used tech profile, can be passed via the command line too, valid values: default (=1T1GEM), 1T4GEM, 1T8GEM
57# example: -v techprofile:1T4GEM
TorstenThiemee0e5bba2020-08-05 11:20:13 +000058${techprofile} default
59# flag for execute port test, can be passed via the command line too
TorstenThieme87cd6202020-09-09 10:01:28 +000060# example: -v porttest:False
TorstenThieme1619db22020-04-03 12:01:15 +000061${porttest} True
TorstenThieme87cd6202020-09-09 10:01:28 +000062# flag for execute flow test, can be passed via the command line too
63# example: -v flowtest:False
64${flowtest} True
65# flag for execute reconcile onu device test, can be passed via the command line too
66# example: -v reconciletest:True
67${reconciletest} False
68# flag for execute onu device state test after reconcile, can be passed via the command line too
69# example: -v reconcilestatetest:True
70${reconcilestatetest} False
TorstenThiemee0e5bba2020-08-05 11:20:13 +000071# flag debugmode is used, if true timeout calculation various, can be passed via the command line too
TorstenThieme87cd6202020-09-09 10:01:28 +000072# example: -v debugmode:True
TorstenThieme401af432020-06-11 15:53:53 +000073${debugmode} False
TorstenThiemee0e5bba2020-08-05 11:20:13 +000074# logging flag to enable Collect Logs, can be passed via the command line too
TorstenThieme87cd6202020-09-09 10:01:28 +000075# example: -v logging:True
TorstenThieme5e324e42020-07-27 09:36:16 +000076${logging} False
TorstenThiemee0e5bba2020-08-05 11:20:13 +000077# if True execution will be paused before clean up
TorstenThieme87cd6202020-09-09 10:01:28 +000078# example: -v pausebeforecleanup:True
TorstenThiemeb41007d2020-06-22 12:14:12 +000079${pausebeforecleanup} False
TorstenThiemee0e5bba2020-08-05 11:20:13 +000080${data_dir} ../data
81
TorstenThieme1619db22020-04-03 12:01:15 +000082
83*** Test Cases ***
84ONU State Test
85 [Documentation] Validates the ONU Go adapter states
TorstenThieme401af432020-06-11 15:53:53 +000086 [Tags] statetest onutest
TorstenThieme1619db22020-04-03 12:01:15 +000087 [Setup] Run Keywords Start Logging ONUStateTest
88 ... AND Setup Test
89 Run Keyword If ${has_dataplane} Clean Up Linux
90 Enable Device ${olt_device_id}
TorstenThieme94e4ae42020-05-18 13:01:42 +000091 ${timeStart} = Get Current Date
92 Set Global Variable ${timeStart}
TorstenThieme1619db22020-04-03 12:01:15 +000093 Run Keyword If "${testmode}"=="SingleState" Do ONU Single State Test
94 ... ELSE IF "${testmode}"=="Up2State" Do ONU Up To State Test
TorstenThieme94e4ae42020-05-18 13:01:42 +000095 ... ELSE IF "${testmode}"=="SingleStateTime" Do ONU Single State Test Time
TorstenThieme1619db22020-04-03 12:01:15 +000096 ... ELSE Fail The testmode (${testmode}) is not valid!
TorstenThieme5e324e42020-07-27 09:36:16 +000097 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
TorstenThieme1619db22020-04-03 12:01:15 +000098 ... AND Stop Logging ONUStateTest
99
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000100Check Loaded Tech Profile
101 [Documentation] Validates the loaded Tech Profile
102 ... Assuming that ONU State Test was executed where all the ONUs are reached the expected state!
103 ... Check will be executed only the reached ONU state is 5 (tech-profile-config-download-success) or higher
104 [Tags] onutest
105 [Setup] Start Logging ONUCheckTechProfile
106 Run Keyword If ${state2test}>=5 and ${profiletest} Do Check Tech Profile
107 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
108 ... AND Stop Logging ONUCheckTechProfile
109
TorstenThieme401af432020-06-11 15:53:53 +0000110Onu Port Check
TorstenThieme87cd6202020-09-09 10:01:28 +0000111 [Documentation] Validates that all the UNI ports show up in ONOS
TorstenThieme00958682020-06-19 11:29:31 +0000112 ... Assuming that ONU State Test was executed where all the ONUs are reached the expected state!
TorstenThieme401af432020-06-11 15:53:53 +0000113 [Tags] onutest
114 [Setup] Start Logging ONUPortTest
115 Run Keyword If ${porttest} Do Onu Port Check
TorstenThieme5e324e42020-07-27 09:36:16 +0000116 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
TorstenThieme401af432020-06-11 15:53:53 +0000117 ... AND Stop Logging ONUPortTest
118
TorstenThieme1619db22020-04-03 12:01:15 +0000119*** Keywords ***
120Setup Suite
121 [Documentation] Set up the test suite
TorstenThieme87cd6202020-09-09 10:01:28 +0000122 ${LogInfo}= Catenate
123 ... \r\nPassed arguments:
124 ... state2test:${state2test}, testmode:${testmode}, profiletest:${profiletest}, techprofile:${techprofile},
125 ... porttest:${porttest}, flowtest:${flowtest}, reconciletest:${reconciletest},
126 ... reconcilestatetest:${reconcilestatetest}, debugmode:${debugmode}, logging:${logging},
127 ... pausebeforecleanup:${pausebeforecleanup}
128 Log ${LogInfo} console=yes
TorstenThieme1619db22020-04-03 12:01:15 +0000129 Common Test Suite Setup
130 Run Keyword If ${num_onus}>4 Calculate Timeout
TorstenThieme87cd6202020-09-09 10:01:28 +0000131 Run Keyword If "${techprofile}"=="1T1GEM" ${techprofile}= Set Variable default
132 Run Keyword If "${techprofile}"=="default" Log To Console \nTechProfile:default (1T1GEM)
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000133 ... ELSE IF "${techprofile}"=="1T4GEM" Set Tech Profile 1T4GEM
134 ... ELSE IF "${techprofile}"=="1T8GEM" Set Tech Profile 1T8GEM
135 ... ELSE Fail The TechProfile (${techprofile}) is not valid!
136 ${onos_ssh_connection} Open ONOS SSH Connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
137 Set Suite Variable ${onos_ssh_connection}
TorstenThieme1619db22020-04-03 12:01:15 +0000138
TorstenThiemeb41007d2020-06-22 12:14:12 +0000139Teardown Suite
140 [Documentation] Replaces the Suite Teardown in utils.robot.
141 ... Cleans up and checks all ONU ports disabled in ONOS.
142 ... Furthermore gives the possibility to pause the execution.
143 Run Keyword If ${pausebeforecleanup} Import Library Dialogs
144 Run Keyword If ${pausebeforecleanup} Pause Execution Press OK to continue with clean up!
TorstenThieme87cd6202020-09-09 10:01:28 +0000145 Run Keyword If ${pausebeforecleanup} Log Teardown will be continued... console=yes
TorstenThiemeb41007d2020-06-22 12:14:12 +0000146 Run Keyword If ${teardown_device} Delete All Devices and Verify
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000147 # Wait for Ports in ONOS ${ONOS_SSH_IP} ${ONOS_SSH_PORT} 0 BBSM
148 Wait for Ports in ONOS ${onos_ssh_connection} 0 BBSM
149 Close ONOS SSH Connection ${onos_ssh_connection}
TorstenThieme87cd6202020-09-09 10:01:28 +0000150 Remove Tech Profile
TorstenThiemeb41007d2020-06-22 12:14:12 +0000151
TorstenThieme1619db22020-04-03 12:01:15 +0000152Setup Test
153 [Documentation] Pre-test Setup
154 #test for empty device list
155 Test Empty Device List
156 Run Keyword If ${has_dataplane} Wait Until Keyword Succeeds 120s 10s Openolt is Up
Suchitra Vemurib7253a52020-07-14 22:35:17 -0700157 ... ${olt_ssh_ip} ${olt_user} ${olt_pass}
TorstenThieme1619db22020-04-03 12:01:15 +0000158 Run Keyword If ${has_dataplane} Sleep 60s
159 #create/preprovision device
160 ${olt_device_id}= Create Device ${olt_ip} ${OLT_PORT}
161 Set Suite Variable ${olt_device_id}
162 #validate olt states
163 Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device PREPROVISIONED UNKNOWN UNKNOWN
164 ... ${olt_device_id}
165 Sleep 5s
166
167Calculate Timeout
168 [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus
169 ${timeout} Fetch From Left ${timeout} s
170 ${timeout}= evaluate ${timeout}+((${num_onus}-4)*30)
TorstenThieme401af432020-06-11 15:53:53 +0000171 ${timeout}= Set Variable If (not ${debugmode}) and (${timeout}>600) 600 ${timeout}
TorstenThieme1619db22020-04-03 12:01:15 +0000172 ${timeout}= Catenate SEPARATOR= ${timeout} s
173 Set Suite Variable ${timeout}
TorstenThieme1619db22020-04-03 12:01:15 +0000174
175Do ONU Up To State Test
176 [Documentation] This keyword performs Up2State Test
177 ... All states up to the passed have to be checked
178 FOR ${I} IN RANGE 0 ${num_onus}
179 ${src}= Set Variable ${hosts.src[${I}]}
180 ${dst}= Set Variable ${hosts.dst[${I}]}
181 Run Keyword If ${state2test}>=1
182 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
183 ... Validate Device ENABLED ACTIVATING REACHABLE
184 ... ${src['onu']} onu=True onu_reason=activating-onu
185 Run Keyword If ${state2test}>=2
186 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
187 ... Validate Device ENABLED ACTIVATING REACHABLE
188 ... ${src['onu']} onu=True onu_reason=starting-openomci
189 Run Keyword If ${state2test}>=3
190 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
191 ... Validate Device ENABLED ACTIVATING REACHABLE
192 ... ${src['onu']} onu=True onu_reason=discovery-mibsync-complete
193 Run Keyword If ${state2test}>=4
194 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
195 ... Validate Device ENABLED ACTIVE REACHABLE
196 ... ${src['onu']} onu=True onu_reason=initial-mib-downloaded
197 Run Keyword If ${state2test}>=5
198 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
199 ... Validate Device ENABLED ACTIVE REACHABLE
200 ... ${src['onu']} onu=True onu_reason=tech-profile-config-download-success
201 Run Keyword If ${state2test}>=6
202 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
203 ... Validate Device ENABLED ACTIVE REACHABLE
204 ... ${src['onu']} onu=True onu_reason=omci-flows-pushed
205 END
206
207Do ONU Single State Test
208 [Documentation] This keyword performs SingleState Test
209 ... Only the passed state has to be checked
210 FOR ${I} IN RANGE 0 ${num_onus}
211 ${src}= Set Variable ${hosts.src[${I}]}
212 ${dst}= Set Variable ${hosts.dst[${I}]}
213 Run Keyword If ${state2test}==1
214 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
215 ... Validate Device ENABLED ACTIVATING REACHABLE
216 ... ${src['onu']} onu=True onu_reason=activating-onu
217 ... ELSE IF ${state2test}==2
218 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
219 ... Validate Device ENABLED ACTIVATING REACHABLE
220 ... ${src['onu']} onu=True onu_reason=starting-openomci
221 ... ELSE IF ${state2test}==3
222 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
223 ... Validate Device ENABLED ACTIVATING REACHABLE
224 ... ${src['onu']} onu=True onu_reason=discovery-mibsync-complete
225 ... ELSE IF ${state2test}==4
226 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
227 ... Validate Device ENABLED ACTIVE REACHABLE
228 ... ${src['onu']} onu=True onu_reason=initial-mib-downloaded
229 ... ELSE IF ${state2test}==5
230 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
231 ... Validate Device ENABLED ACTIVE REACHABLE
232 ... ${src['onu']} onu=True onu_reason=tech-profile-config-download-success
233 ... ELSE IF ${state2test}==6
234 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
235 ... Validate Device ENABLED ACTIVE REACHABLE
236 ... ${src['onu']} onu=True onu_reason=omci-flows-pushed
237 ... ELSE Fail The state to test (${state2test}) is not valid!
238 END
239
TorstenThieme94e4ae42020-05-18 13:01:42 +0000240Do ONU Single State Test Time
241 [Documentation] This keyword performs SingleState Test with calculate running time
242 ... Only the passed state has to be checked and the duration each single onu adapter needed
243 ... will be calculated and printed out
244 ${ListfinishedONUs} Create List
245 Set Global Variable ${ListfinishedONUs}
246 Create File ONU_Startup_Time.txt This file contains the startup times of all ONUs.
247 ${list_onus} Create List
TorstenThieme401af432020-06-11 15:53:53 +0000248 Build ONU SN List ${list_onus}
TorstenThieme94e4ae42020-05-18 13:01:42 +0000249 Run Keyword If ${state2test}==1
250 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
TorstenThieme9949b172020-06-16 10:00:15 +0000251 ... Validate ONU Devices MIB State With Duration
TorstenThieme401af432020-06-11 15:53:53 +0000252 ... activating-onu ${list_onus} ${timeStart} print2console=True
253 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000254 ... ELSE IF ${state2test}==2
255 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
TorstenThieme9949b172020-06-16 10:00:15 +0000256 ... Validate ONU Devices MIB State With Duration
TorstenThieme401af432020-06-11 15:53:53 +0000257 ... starting-openomci ${list_onus} ${timeStart} print2console=True
258 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000259 ... ELSE IF ${state2test}==3
260 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
TorstenThieme9949b172020-06-16 10:00:15 +0000261 ... Validate ONU Devices MIB State With Duration
TorstenThieme401af432020-06-11 15:53:53 +0000262 ... discovery-mibsync-complete ${list_onus} ${timeStart} print2console=True
263 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000264 ... ELSE IF ${state2test}==4
265 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
TorstenThieme9949b172020-06-16 10:00:15 +0000266 ... Validate ONU Devices MIB State With Duration
TorstenThieme401af432020-06-11 15:53:53 +0000267 ... initial-mib-downloaded ${list_onus} ${timeStart} print2console=True
268 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000269 ... ELSE IF ${state2test}==5
270 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
TorstenThieme9949b172020-06-16 10:00:15 +0000271 ... Validate ONU Devices MIB State With Duration
TorstenThieme401af432020-06-11 15:53:53 +0000272 ... tech-profile-config-download-success ${list_onus} ${timeStart} print2console=True
273 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000274 ... ELSE IF ${state2test}==6
275 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
TorstenThieme9949b172020-06-16 10:00:15 +0000276 ... Validate ONU Devices MIB State With Duration
TorstenThieme401af432020-06-11 15:53:53 +0000277 ... omci-flows-pushed ${list_onus} ${timeStart} print2console=True
278 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000279 ... ELSE Fail The state to test (${state2test}) is not valid!
280
TorstenThieme1619db22020-04-03 12:01:15 +0000281Do Onu Port Check
TorstenThieme00958682020-06-19 11:29:31 +0000282 [Documentation] Check that all the UNI ports show up in ONOS
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000283 Wait for Ports in ONOS ${onos_ssh_connection} ${num_onus} BBSM
TorstenThieme9949b172020-06-16 10:00:15 +0000284
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000285Set Tech Profile
286 [Documentation] This keyword set the passed TechProfile for the test
287 [Arguments] ${TechProfile}
TorstenThieme87cd6202020-09-09 10:01:28 +0000288 Log To Console \nTechProfile:${TechProfile}
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000289 ${namespace}= Set Variable default
Andrea Campanella60dde302020-09-09 18:42:56 +0200290 ${podname}= Set Variable etcd
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000291 ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
292 ${dest}= Set Variable /tmp/flexpod.json
293 ${command} Catenate
294 ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
295 Copy File To Pod ${namespace} ${podname} ${src} ${dest}
296 Exec Pod ${namespace} ${podname} ${command}
297 ${commandget} Catenate
298 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
299 Exec Pod ${namespace} ${podname} ${commandget}
300
301Remove Tech Profile
302 [Documentation] This keyword removes TechProfile
303 Log To Console \nTechProfile:${TechProfile}
304 ${namespace}= Set Variable default
Andrea Campanella60dde302020-09-09 18:42:56 +0200305 ${podname}= Set Variable etcd
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000306 ${command} Catenate
307 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64'
308 Exec Pod ${namespace} ${podname} ${command}
309 ${commandget} Catenate
310 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
311 Exec Pod ${namespace} ${podname} ${commandget}
312
313Do Check Tech Profile
314 [Documentation] This keyword checks the loaded TechProfile
315 ${namespace}= Set Variable default
Andrea Campanella60dde302020-09-09 18:42:56 +0200316 ${podname}= Set Variable etcd
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000317 ${commandget} Catenate
318 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
319 ${result}= Exec Pod ${namespace} ${podname} ${commandget}
320 ${num_gem_ports}= Set Variable 1
321 ${num_gem_ports}= Set Variable If
322 ... "${techprofile}"=="default" 1
323 ... "${techprofile}"=="1T4GEM" 4
324 ... "${techprofile}"=="1T8GEM" 8
325 @{resultList} Split String ${result} separator=,
326 ${num_of_count_matches}= Get Match Count ${resultList} "num_gem_ports": ${num_gem_ports}
327 ... whitespace_insensitive=True
328 ${num_of_expected_matches}= Run Keyword If "${techprofile}"=="default" Evaluate ${num_onus}
329 ... ELSE Evaluate ${num_onus}+1
330 Run Keyword If ${num_of_expected_matches}!=${num_of_count_matches} Log To Console
331 ... \nTechProfile (${TechProfile}) not loaded correctly:${num_of_count_matches} of ${num_of_expected_matches}