blob: c5a0d84b8ea7514faf57a7b0ba83baefb299077e [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
TorstenThieme1619db22020-04-03 12:01:15 +000048${state2test} 6
TorstenThiemee0e5bba2020-08-05 11:20:13 +000049# test mode variable, can be passed via the command line too, valid values: SingleState, Up2State, SingleStateTime
TorstenThieme1619db22020-04-03 12:01:15 +000050${testmode} SingleState
TorstenThiemee0e5bba2020-08-05 11:20:13 +000051# flag for execute Tech Profile check, can be passed via the command line too
52${profiletest} True
53# used tech profile, can be passed via the command line too, valid values: default, 1T4GEM, 1T8GEM
54${techprofile} default
55# flag for execute port test, can be passed via the command line too
TorstenThieme1619db22020-04-03 12:01:15 +000056${porttest} True
TorstenThiemee0e5bba2020-08-05 11:20:13 +000057# flag debugmode is used, if true timeout calculation various, can be passed via the command line too
TorstenThieme401af432020-06-11 15:53:53 +000058${debugmode} False
TorstenThiemee0e5bba2020-08-05 11:20:13 +000059# logging flag to enable Collect Logs, can be passed via the command line too
TorstenThieme5e324e42020-07-27 09:36:16 +000060${logging} False
TorstenThiemee0e5bba2020-08-05 11:20:13 +000061# if True execution will be paused before clean up
TorstenThiemeb41007d2020-06-22 12:14:12 +000062${pausebeforecleanup} False
TorstenThiemee0e5bba2020-08-05 11:20:13 +000063${data_dir} ../data
64
TorstenThieme1619db22020-04-03 12:01:15 +000065
66*** Test Cases ***
67ONU State Test
68 [Documentation] Validates the ONU Go adapter states
TorstenThieme401af432020-06-11 15:53:53 +000069 [Tags] statetest onutest
TorstenThieme1619db22020-04-03 12:01:15 +000070 [Setup] Run Keywords Start Logging ONUStateTest
71 ... AND Setup Test
72 Run Keyword If ${has_dataplane} Clean Up Linux
73 Enable Device ${olt_device_id}
TorstenThieme94e4ae42020-05-18 13:01:42 +000074 ${timeStart} = Get Current Date
75 Set Global Variable ${timeStart}
TorstenThieme1619db22020-04-03 12:01:15 +000076 Run Keyword If "${testmode}"=="SingleState" Do ONU Single State Test
77 ... ELSE IF "${testmode}"=="Up2State" Do ONU Up To State Test
TorstenThieme94e4ae42020-05-18 13:01:42 +000078 ... ELSE IF "${testmode}"=="SingleStateTime" Do ONU Single State Test Time
TorstenThieme1619db22020-04-03 12:01:15 +000079 ... ELSE Fail The testmode (${testmode}) is not valid!
TorstenThieme5e324e42020-07-27 09:36:16 +000080 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
TorstenThieme1619db22020-04-03 12:01:15 +000081 ... AND Stop Logging ONUStateTest
82
TorstenThiemee0e5bba2020-08-05 11:20:13 +000083Check Loaded Tech Profile
84 [Documentation] Validates the loaded Tech Profile
85 ... Assuming that ONU State Test was executed where all the ONUs are reached the expected state!
86 ... Check will be executed only the reached ONU state is 5 (tech-profile-config-download-success) or higher
87 [Tags] onutest
88 [Setup] Start Logging ONUCheckTechProfile
89 Run Keyword If ${state2test}>=5 and ${profiletest} Do Check Tech Profile
90 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
91 ... AND Stop Logging ONUCheckTechProfile
92
TorstenThieme401af432020-06-11 15:53:53 +000093Onu Port Check
94 [Documentation] Validates the ONU Go adapter states
TorstenThieme00958682020-06-19 11:29:31 +000095 ... Assuming that ONU State Test was executed where all the ONUs are reached the expected state!
TorstenThieme401af432020-06-11 15:53:53 +000096 [Tags] onutest
97 [Setup] Start Logging ONUPortTest
98 Run Keyword If ${porttest} Do Onu Port Check
TorstenThieme5e324e42020-07-27 09:36:16 +000099 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
TorstenThieme401af432020-06-11 15:53:53 +0000100 ... AND Stop Logging ONUPortTest
101
TorstenThieme1619db22020-04-03 12:01:15 +0000102*** Keywords ***
103Setup Suite
104 [Documentation] Set up the test suite
105 Common Test Suite Setup
106 Run Keyword If ${num_onus}>4 Calculate Timeout
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000107 Run Keyword If "${techprofile}"=="default" Log To Console \nTechProfile:default
108 ... ELSE IF "${techprofile}"=="1T4GEM" Set Tech Profile 1T4GEM
109 ... ELSE IF "${techprofile}"=="1T8GEM" Set Tech Profile 1T8GEM
110 ... ELSE Fail The TechProfile (${techprofile}) is not valid!
111 ${onos_ssh_connection} Open ONOS SSH Connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
112 Set Suite Variable ${onos_ssh_connection}
TorstenThieme1619db22020-04-03 12:01:15 +0000113
TorstenThiemeb41007d2020-06-22 12:14:12 +0000114Teardown Suite
115 [Documentation] Replaces the Suite Teardown in utils.robot.
116 ... Cleans up and checks all ONU ports disabled in ONOS.
117 ... Furthermore gives the possibility to pause the execution.
118 Run Keyword If ${pausebeforecleanup} Import Library Dialogs
119 Run Keyword If ${pausebeforecleanup} Pause Execution Press OK to continue with clean up!
120 Run Keyword If ${teardown_device} Delete All Devices and Verify
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000121 # Wait for Ports in ONOS ${ONOS_SSH_IP} ${ONOS_SSH_PORT} 0 BBSM
122 Wait for Ports in ONOS ${onos_ssh_connection} 0 BBSM
123 Close ONOS SSH Connection ${onos_ssh_connection}
124 Remove Tech Profile
TorstenThiemeb41007d2020-06-22 12:14:12 +0000125
TorstenThieme1619db22020-04-03 12:01:15 +0000126Setup Test
127 [Documentation] Pre-test Setup
128 #test for empty device list
129 Test Empty Device List
130 Run Keyword If ${has_dataplane} Wait Until Keyword Succeeds 120s 10s Openolt is Up
Suchitra Vemurib7253a52020-07-14 22:35:17 -0700131 ... ${olt_ssh_ip} ${olt_user} ${olt_pass}
TorstenThieme1619db22020-04-03 12:01:15 +0000132 Run Keyword If ${has_dataplane} Sleep 60s
133 #create/preprovision device
134 ${olt_device_id}= Create Device ${olt_ip} ${OLT_PORT}
135 Set Suite Variable ${olt_device_id}
136 #validate olt states
137 Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device PREPROVISIONED UNKNOWN UNKNOWN
138 ... ${olt_device_id}
139 Sleep 5s
140
141Calculate Timeout
142 [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus
143 ${timeout} Fetch From Left ${timeout} s
144 ${timeout}= evaluate ${timeout}+((${num_onus}-4)*30)
TorstenThieme401af432020-06-11 15:53:53 +0000145 ${timeout}= Set Variable If (not ${debugmode}) and (${timeout}>600) 600 ${timeout}
TorstenThieme1619db22020-04-03 12:01:15 +0000146 ${timeout}= Catenate SEPARATOR= ${timeout} s
147 Set Suite Variable ${timeout}
148 #Log \r\nTimeout: ${timeout} INFO console=True
149
150Do ONU Up To State Test
151 [Documentation] This keyword performs Up2State Test
152 ... All states up to the passed have to be checked
153 FOR ${I} IN RANGE 0 ${num_onus}
154 ${src}= Set Variable ${hosts.src[${I}]}
155 ${dst}= Set Variable ${hosts.dst[${I}]}
156 Run Keyword If ${state2test}>=1
157 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
158 ... Validate Device ENABLED ACTIVATING REACHABLE
159 ... ${src['onu']} onu=True onu_reason=activating-onu
160 Run Keyword If ${state2test}>=2
161 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
162 ... Validate Device ENABLED ACTIVATING REACHABLE
163 ... ${src['onu']} onu=True onu_reason=starting-openomci
164 Run Keyword If ${state2test}>=3
165 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
166 ... Validate Device ENABLED ACTIVATING REACHABLE
167 ... ${src['onu']} onu=True onu_reason=discovery-mibsync-complete
168 Run Keyword If ${state2test}>=4
169 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
170 ... Validate Device ENABLED ACTIVE REACHABLE
171 ... ${src['onu']} onu=True onu_reason=initial-mib-downloaded
172 Run Keyword If ${state2test}>=5
173 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
174 ... Validate Device ENABLED ACTIVE REACHABLE
175 ... ${src['onu']} onu=True onu_reason=tech-profile-config-download-success
176 Run Keyword If ${state2test}>=6
177 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
178 ... Validate Device ENABLED ACTIVE REACHABLE
179 ... ${src['onu']} onu=True onu_reason=omci-flows-pushed
180 END
181
182Do ONU Single State Test
183 [Documentation] This keyword performs SingleState Test
184 ... Only the passed state has to be checked
185 FOR ${I} IN RANGE 0 ${num_onus}
186 ${src}= Set Variable ${hosts.src[${I}]}
187 ${dst}= Set Variable ${hosts.dst[${I}]}
188 Run Keyword If ${state2test}==1
189 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
190 ... Validate Device ENABLED ACTIVATING REACHABLE
191 ... ${src['onu']} onu=True onu_reason=activating-onu
192 ... ELSE IF ${state2test}==2
193 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
194 ... Validate Device ENABLED ACTIVATING REACHABLE
195 ... ${src['onu']} onu=True onu_reason=starting-openomci
196 ... ELSE IF ${state2test}==3
197 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
198 ... Validate Device ENABLED ACTIVATING REACHABLE
199 ... ${src['onu']} onu=True onu_reason=discovery-mibsync-complete
200 ... ELSE IF ${state2test}==4
201 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
202 ... Validate Device ENABLED ACTIVE REACHABLE
203 ... ${src['onu']} onu=True onu_reason=initial-mib-downloaded
204 ... ELSE IF ${state2test}==5
205 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
206 ... Validate Device ENABLED ACTIVE REACHABLE
207 ... ${src['onu']} onu=True onu_reason=tech-profile-config-download-success
208 ... ELSE IF ${state2test}==6
209 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
210 ... Validate Device ENABLED ACTIVE REACHABLE
211 ... ${src['onu']} onu=True onu_reason=omci-flows-pushed
212 ... ELSE Fail The state to test (${state2test}) is not valid!
213 END
214
TorstenThieme94e4ae42020-05-18 13:01:42 +0000215Do ONU Single State Test Time
216 [Documentation] This keyword performs SingleState Test with calculate running time
217 ... Only the passed state has to be checked and the duration each single onu adapter needed
218 ... will be calculated and printed out
219 ${ListfinishedONUs} Create List
220 Set Global Variable ${ListfinishedONUs}
221 Create File ONU_Startup_Time.txt This file contains the startup times of all ONUs.
222 ${list_onus} Create List
TorstenThieme401af432020-06-11 15:53:53 +0000223 Build ONU SN List ${list_onus}
TorstenThieme94e4ae42020-05-18 13:01:42 +0000224 Run Keyword If ${state2test}==1
225 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
TorstenThieme9949b172020-06-16 10:00:15 +0000226 ... Validate ONU Devices MIB State With Duration
TorstenThieme401af432020-06-11 15:53:53 +0000227 ... activating-onu ${list_onus} ${timeStart} print2console=True
228 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000229 ... ELSE IF ${state2test}==2
230 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
TorstenThieme9949b172020-06-16 10:00:15 +0000231 ... Validate ONU Devices MIB State With Duration
TorstenThieme401af432020-06-11 15:53:53 +0000232 ... starting-openomci ${list_onus} ${timeStart} print2console=True
233 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000234 ... ELSE IF ${state2test}==3
235 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
TorstenThieme9949b172020-06-16 10:00:15 +0000236 ... Validate ONU Devices MIB State With Duration
TorstenThieme401af432020-06-11 15:53:53 +0000237 ... discovery-mibsync-complete ${list_onus} ${timeStart} print2console=True
238 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000239 ... ELSE IF ${state2test}==4
240 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
TorstenThieme9949b172020-06-16 10:00:15 +0000241 ... Validate ONU Devices MIB State With Duration
TorstenThieme401af432020-06-11 15:53:53 +0000242 ... initial-mib-downloaded ${list_onus} ${timeStart} print2console=True
243 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000244 ... ELSE IF ${state2test}==5
245 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
TorstenThieme9949b172020-06-16 10:00:15 +0000246 ... Validate ONU Devices MIB State With Duration
TorstenThieme401af432020-06-11 15:53:53 +0000247 ... tech-profile-config-download-success ${list_onus} ${timeStart} print2console=True
248 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000249 ... ELSE IF ${state2test}==6
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 ... omci-flows-pushed ${list_onus} ${timeStart} print2console=True
253 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000254 ... ELSE Fail The state to test (${state2test}) is not valid!
255
TorstenThieme1619db22020-04-03 12:01:15 +0000256Do Onu Port Check
TorstenThieme00958682020-06-19 11:29:31 +0000257 [Documentation] Check that all the UNI ports show up in ONOS
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000258 # Wait for Ports in ONOS ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${num_onus} BBSM
259 Wait for Ports in ONOS ${onos_ssh_connection} ${num_onus} BBSM
TorstenThieme9949b172020-06-16 10:00:15 +0000260
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000261Set Tech Profile
262 [Documentation] This keyword set the passed TechProfile for the test
263 [Arguments] ${TechProfile}
264 Log To Console \nTechProfile:${TechProfile}
265 ${namespace}= Set Variable default
266 ${podname}= Set Variable etcd-0
267 ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
268 ${dest}= Set Variable /tmp/flexpod.json
269 ${command} Catenate
270 ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
271 Copy File To Pod ${namespace} ${podname} ${src} ${dest}
272 Exec Pod ${namespace} ${podname} ${command}
273 ${commandget} Catenate
274 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
275 Exec Pod ${namespace} ${podname} ${commandget}
276
277Remove Tech Profile
278 [Documentation] This keyword removes TechProfile
279 Log To Console \nTechProfile:${TechProfile}
280 ${namespace}= Set Variable default
281 ${podname}= Set Variable etcd-0
282 ${command} Catenate
283 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64'
284 Exec Pod ${namespace} ${podname} ${command}
285 ${commandget} Catenate
286 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
287 Exec Pod ${namespace} ${podname} ${commandget}
288
289Do Check Tech Profile
290 [Documentation] This keyword checks the loaded TechProfile
291 ${namespace}= Set Variable default
292 ${podname}= Set Variable etcd-0
293 ${commandget} Catenate
294 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
295 ${result}= Exec Pod ${namespace} ${podname} ${commandget}
296 ${num_gem_ports}= Set Variable 1
297 ${num_gem_ports}= Set Variable If
298 ... "${techprofile}"=="default" 1
299 ... "${techprofile}"=="1T4GEM" 4
300 ... "${techprofile}"=="1T8GEM" 8
301 @{resultList} Split String ${result} separator=,
302 ${num_of_count_matches}= Get Match Count ${resultList} "num_gem_ports": ${num_gem_ports}
303 ... whitespace_insensitive=True
304 ${num_of_expected_matches}= Run Keyword If "${techprofile}"=="default" Evaluate ${num_onus}
305 ... ELSE Evaluate ${num_onus}+1
306 Run Keyword If ${num_of_expected_matches}!=${num_of_count_matches} Log To Console
307 ... \nTechProfile (${TechProfile}) not loaded correctly:${num_of_count_matches} of ${num_of_expected_matches}