blob: 696041ba26f7838c1c0e47cb7d29afd0253c1b7f [file] [log] [blame]
TorstenThieme1619db22020-04-03 12:01:15 +00001*** Settings ***
TorstenThieme109683b2020-09-24 12:35:41 +00002Documentation Test states of ONU Go adapter with ATT workflows only (not for DT/TT workflow!)
TorstenThieme1619db22020-04-03 12:01:15 +00003Suite 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 ***
TorstenThieme94e4ae42020-05-18 13:01:42 +000021${timeout} 180s
TorstenThieme1619db22020-04-03 12:01:15 +000022${of_id} 0
23${logical_id} 0
24${has_dataplane} True
25${external_libs} True
26${teardown_device} True
27${scripts} ../../scripts
28# Per-test logging on failure is turned off by default; set this variable to enable
29${container_log_dir} ${None}
TorstenThiemee0e5bba2020-08-05 11:20:13 +000030# state to test variable, can be passed via the command line too, valid values: 1-6
31# 1 -> activating-onu
32# 2 -> starting-openomci
33# 3 -> discovery-mibsync-complete
34# 4 -> initial-mib-downloaded
35# 5 -> tech-profile-config-download-success
36# 6 -> omci-flows-pushed
TorstenThieme87cd6202020-09-09 10:01:28 +000037# example: -v state2test:5
TorstenThieme66c91a82020-10-19 13:37:53 +000038# example: -v state2test:omci-flows-pushed
TorstenThieme1619db22020-04-03 12:01:15 +000039${state2test} 6
TorstenThiemee0e5bba2020-08-05 11:20:13 +000040# test mode variable, can be passed via the command line too, valid values: SingleState, Up2State, SingleStateTime
TorstenThieme87cd6202020-09-09 10:01:28 +000041# example: -v testmode:SingleStateTime
TorstenThieme1619db22020-04-03 12:01:15 +000042${testmode} SingleState
TorstenThieme87cd6202020-09-09 10:01:28 +000043# used tech profile, can be passed via the command line too, valid values: default (=1T1GEM), 1T4GEM, 1T8GEM
44# example: -v techprofile:1T4GEM
TorstenThiemee0e5bba2020-08-05 11:20:13 +000045${techprofile} default
TorstenThiemee0e5bba2020-08-05 11:20:13 +000046# flag debugmode is used, if true timeout calculation various, can be passed via the command line too
TorstenThieme87cd6202020-09-09 10:01:28 +000047# example: -v debugmode:True
TorstenThieme401af432020-06-11 15:53:53 +000048${debugmode} False
TorstenThiemee0e5bba2020-08-05 11:20:13 +000049# logging flag to enable Collect Logs, can be passed via the command line too
TorstenThieme87cd6202020-09-09 10:01:28 +000050# example: -v logging:True
TorstenThieme5e324e42020-07-27 09:36:16 +000051${logging} False
TorstenThieme66c91a82020-10-19 13:37:53 +000052# if True execution will be paused before clean up, only use in case of manual testing, do not use in ci pipeline!
TorstenThieme87cd6202020-09-09 10:01:28 +000053# example: -v pausebeforecleanup:True
TorstenThiemeb41007d2020-06-22 12:14:12 +000054${pausebeforecleanup} False
TorstenThiemee0e5bba2020-08-05 11:20:13 +000055${data_dir} ../data
56
TorstenThieme1619db22020-04-03 12:01:15 +000057
58*** Test Cases ***
59ONU State Test
60 [Documentation] Validates the ONU Go adapter states
TorstenThieme66c91a82020-10-19 13:37:53 +000061 [Tags] sanityOnuGo StateTestOnuGo
TorstenThieme1619db22020-04-03 12:01:15 +000062 [Setup] Run Keywords Start Logging ONUStateTest
63 ... AND Setup Test
64 Run Keyword If ${has_dataplane} Clean Up Linux
65 Enable Device ${olt_device_id}
TorstenThieme94e4ae42020-05-18 13:01:42 +000066 ${timeStart} = Get Current Date
67 Set Global Variable ${timeStart}
TorstenThieme1619db22020-04-03 12:01:15 +000068 Run Keyword If "${testmode}"=="SingleState" Do ONU Single State Test
69 ... ELSE IF "${testmode}"=="Up2State" Do ONU Up To State Test
TorstenThieme94e4ae42020-05-18 13:01:42 +000070 ... ELSE IF "${testmode}"=="SingleStateTime" Do ONU Single State Test Time
TorstenThieme1619db22020-04-03 12:01:15 +000071 ... ELSE Fail The testmode (${testmode}) is not valid!
TorstenThieme5e324e42020-07-27 09:36:16 +000072 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
TorstenThieme1619db22020-04-03 12:01:15 +000073 ... AND Stop Logging ONUStateTest
74
TorstenThiemee0e5bba2020-08-05 11:20:13 +000075Check Loaded Tech Profile
76 [Documentation] Validates the loaded Tech Profile
77 ... Assuming that ONU State Test was executed where all the ONUs are reached the expected state!
78 ... Check will be executed only the reached ONU state is 5 (tech-profile-config-download-success) or higher
TorstenThieme66c91a82020-10-19 13:37:53 +000079 [Tags] functionalOnuGo CheckTechProfileOnuGo
TorstenThiemee0e5bba2020-08-05 11:20:13 +000080 [Setup] Start Logging ONUCheckTechProfile
TorstenThieme66c91a82020-10-19 13:37:53 +000081 Run Keyword If '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
82 ... Do Check Tech Profile
TorstenThieme5a205ba2020-09-29 08:08:29 +000083 ... ELSE Pass Execution ${skip_message} skipped
TorstenThiemee0e5bba2020-08-05 11:20:13 +000084 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
85 ... AND Stop Logging ONUCheckTechProfile
86
TorstenThieme401af432020-06-11 15:53:53 +000087Onu Port Check
TorstenThieme87cd6202020-09-09 10:01:28 +000088 [Documentation] Validates that all the UNI ports show up in ONOS
TorstenThieme00958682020-06-19 11:29:31 +000089 ... Assuming that ONU State Test was executed where all the ONUs are reached the expected state!
TorstenThieme66c91a82020-10-19 13:37:53 +000090 [Tags] functionalOnuGo PortTestOnuGo
TorstenThieme401af432020-06-11 15:53:53 +000091 [Setup] Start Logging ONUPortTest
TorstenThieme66c91a82020-10-19 13:37:53 +000092 Run Keyword If '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
93 ... Do Onu Port Check
TorstenThieme5a205ba2020-09-29 08:08:29 +000094 ... ELSE Pass Execution ${skip_message} skipped
TorstenThieme5e324e42020-07-27 09:36:16 +000095 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
TorstenThieme401af432020-06-11 15:53:53 +000096 ... AND Stop Logging ONUPortTest
97
TorstenThieme109683b2020-09-24 12:35:41 +000098Onu Flow Check
99 [Documentation] Validates the onu flows in ONOS and Voltha
100 ... Assuming that ONU State Test was executed where all the ONUs are reached the expected state!
TorstenThieme66c91a82020-10-19 13:37:53 +0000101 [Tags] functionalOnuGo FlowTestOnuGo notreadyOnuGo
TorstenThieme109683b2020-09-24 12:35:41 +0000102 [Setup] Start Logging ONUFlowTest
TorstenThieme66c91a82020-10-19 13:37:53 +0000103 Run Keyword If '${onu_state}'=='omci-flows-pushed' Do Onu Flow Check
TorstenThieme5a205ba2020-09-29 08:08:29 +0000104 ... ELSE Pass Execution ${skip_message} skipped
TorstenThieme109683b2020-09-24 12:35:41 +0000105 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
106 ... AND Stop Logging ONUFlowTest
107
TorstenThiemee3841a02020-09-23 08:20:43 +0000108Disable Enable Onu Device
109 [Documentation] Disables/enables ONU Device and check states
110 ... Assuming that ONU State Test was executed where all the ONUs are reached the expected state!
TorstenThieme66c91a82020-10-19 13:37:53 +0000111 [Tags] functionalOnuGo DisableEnableOnuGo
TorstenThiemee3841a02020-09-23 08:20:43 +0000112 [Setup] Start Logging DisableEnableONUDevice
TorstenThieme66c91a82020-10-19 13:37:53 +0000113 Run Keyword If '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
114 ... Do Disable Enable Onu Test
TorstenThieme5a205ba2020-09-29 08:08:29 +0000115 ... ELSE Pass Execution ${skip_message} skipped
TorstenThiemee3841a02020-09-23 08:20:43 +0000116 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
117 ... AND Stop Logging DisableEnableONUDevice
118
TorstenThieme015d5c02020-09-11 09:53:34 +0000119Reconcile Onu Device
120 [Documentation] Reconciles ONU Device and check state
121 ... Assuming that ONU State Test was executed where all the ONUs are reached the expected state!
TorstenThieme66c91a82020-10-19 13:37:53 +0000122 [Tags] functionalOnuGo ReconcileOnuGo
TorstenThieme015d5c02020-09-11 09:53:34 +0000123 [Setup] Start Logging ReconcileONUDevice
TorstenThieme66c91a82020-10-19 13:37:53 +0000124 Run Keyword If '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
125 ... Do Reconcile Onu Device
TorstenThieme5a205ba2020-09-29 08:08:29 +0000126 ... ELSE Pass Execution ${skip_message} skipped
TorstenThieme015d5c02020-09-11 09:53:34 +0000127 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
128 ... AND Stop Logging ReconcileONUDevice
129
TorstenThieme5ca1dd12020-10-16 08:42:16 +0000130Power Off Power On Onu Device
131 [Documentation] Power off and Power on of all ONU Devices and check state
132 ... Assuming that ONU State Test was executed where all the ONUs are reached the expected state!
TorstenThieme66c91a82020-10-19 13:37:53 +0000133 [Tags] functionalOnuGo PowerOffPowerOnOnuGo
TorstenThieme5ca1dd12020-10-16 08:42:16 +0000134 [Setup] Start Logging PowerOffPowerOnONUDevice
TorstenThieme66c91a82020-10-19 13:37:53 +0000135 Run Keyword If '${onu_state}'=='tech-profile-config-download-success' or '${onu_state}'=='omci-flows-pushed'
136 ... Do Power Off Power On Onu Device
TorstenThieme5ca1dd12020-10-16 08:42:16 +0000137 ... ELSE Pass Execution ${skip_message} skipped
138 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
139 ... AND Stop Logging PowerOffPowerOnONUDevice
140
TorstenThieme1619db22020-04-03 12:01:15 +0000141*** Keywords ***
142Setup Suite
143 [Documentation] Set up the test suite
TorstenThieme87cd6202020-09-09 10:01:28 +0000144 ${LogInfo}= Catenate
145 ... \r\nPassed arguments:
TorstenThieme66c91a82020-10-19 13:37:53 +0000146 ... state2test:${state2test}, testmode:${testmode}, techprofile:${techprofile},
TorstenThieme015d5c02020-09-11 09:53:34 +0000147 ... debugmode:${debugmode}, logging:${logging}, pausebeforecleanup:${pausebeforecleanup},
TorstenThieme87cd6202020-09-09 10:01:28 +0000148 Log ${LogInfo} console=yes
TorstenThieme1619db22020-04-03 12:01:15 +0000149 Common Test Suite Setup
TorstenThieme5a205ba2020-09-29 08:08:29 +0000150 # prepare skip message in yellow for console log
151 ${skip}= Evaluate "\\033[33mSKIP\\033[0m"
152 ${skipped}= Evaluate "\\033[33m${SPACE*14} ===> Test case above was skipped! <=== ${SPACE*15}\\033[0m"
153 ${skip_message} Catenate ${skipped} | ${skip} |
154 Set Suite Variable ${skip_message}
TorstenThieme1619db22020-04-03 12:01:15 +0000155 Run Keyword If ${num_onus}>4 Calculate Timeout
TorstenThieme1488d772020-09-28 10:52:43 +0000156 ${techprofile}= Set Variable If "${techprofile}"=="1T1GEM" default ${techprofile}
TorstenThieme87cd6202020-09-09 10:01:28 +0000157 Run Keyword If "${techprofile}"=="default" Log To Console \nTechProfile:default (1T1GEM)
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000158 ... ELSE IF "${techprofile}"=="1T4GEM" Set Tech Profile 1T4GEM
159 ... ELSE IF "${techprofile}"=="1T8GEM" Set Tech Profile 1T8GEM
160 ... ELSE Fail The TechProfile (${techprofile}) is not valid!
161 ${onos_ssh_connection} Open ONOS SSH Connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
162 Set Suite Variable ${onos_ssh_connection}
TorstenThieme66c91a82020-10-19 13:37:53 +0000163 # map the passed onu state to reached and make it visible for test suite
164 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}=
165 ... Map State ${state2test}
166 Set Suite Variable ${admin_state}
167 Set Suite Variable ${oper_status}
168 Set Suite Variable ${connect_status}
169 Set Suite Variable ${onu_state_nb}
170 Set Suite Variable ${onu_state}
TorstenThieme5ca1dd12020-10-16 08:42:16 +0000171 # delete etcd MIB Template Data
172 Delete MIB Template Data
TorstenThieme1619db22020-04-03 12:01:15 +0000173
TorstenThiemeb41007d2020-06-22 12:14:12 +0000174Teardown Suite
175 [Documentation] Replaces the Suite Teardown in utils.robot.
176 ... Cleans up and checks all ONU ports disabled in ONOS.
177 ... Furthermore gives the possibility to pause the execution.
178 Run Keyword If ${pausebeforecleanup} Import Library Dialogs
179 Run Keyword If ${pausebeforecleanup} Pause Execution Press OK to continue with clean up!
TorstenThieme87cd6202020-09-09 10:01:28 +0000180 Run Keyword If ${pausebeforecleanup} Log Teardown will be continued... console=yes
TorstenThiemeb41007d2020-06-22 12:14:12 +0000181 Run Keyword If ${teardown_device} Delete All Devices and Verify
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000182 # Wait for Ports in ONOS ${ONOS_SSH_IP} ${ONOS_SSH_PORT} 0 BBSM
183 Wait for Ports in ONOS ${onos_ssh_connection} 0 BBSM
184 Close ONOS SSH Connection ${onos_ssh_connection}
TorstenThieme87cd6202020-09-09 10:01:28 +0000185 Remove Tech Profile
TorstenThiemeb41007d2020-06-22 12:14:12 +0000186
TorstenThieme1619db22020-04-03 12:01:15 +0000187Setup Test
188 [Documentation] Pre-test Setup
189 #test for empty device list
190 Test Empty Device List
191 Run Keyword If ${has_dataplane} Wait Until Keyword Succeeds 120s 10s Openolt is Up
Suchitra Vemurib7253a52020-07-14 22:35:17 -0700192 ... ${olt_ssh_ip} ${olt_user} ${olt_pass}
TorstenThieme1619db22020-04-03 12:01:15 +0000193 Run Keyword If ${has_dataplane} Sleep 60s
194 #create/preprovision device
195 ${olt_device_id}= Create Device ${olt_ip} ${OLT_PORT}
196 Set Suite Variable ${olt_device_id}
197 #validate olt states
198 Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device PREPROVISIONED UNKNOWN UNKNOWN
199 ... ${olt_device_id}
200 Sleep 5s
201
202Calculate Timeout
203 [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus
204 ${timeout} Fetch From Left ${timeout} s
205 ${timeout}= evaluate ${timeout}+((${num_onus}-4)*30)
TorstenThieme401af432020-06-11 15:53:53 +0000206 ${timeout}= Set Variable If (not ${debugmode}) and (${timeout}>600) 600 ${timeout}
TorstenThieme1619db22020-04-03 12:01:15 +0000207 ${timeout}= Catenate SEPARATOR= ${timeout} s
208 Set Suite Variable ${timeout}
TorstenThieme1619db22020-04-03 12:01:15 +0000209
210Do ONU Up To State Test
211 [Documentation] This keyword performs Up2State Test
212 ... All states up to the passed have to be checked
213 FOR ${I} IN RANGE 0 ${num_onus}
214 ${src}= Set Variable ${hosts.src[${I}]}
215 ${dst}= Set Variable ${hosts.dst[${I}]}
TorstenThieme66c91a82020-10-19 13:37:53 +0000216 Run Keyword If ${onu_state_nb}>=1
TorstenThieme1619db22020-04-03 12:01:15 +0000217 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
218 ... Validate Device ENABLED ACTIVATING REACHABLE
219 ... ${src['onu']} onu=True onu_reason=activating-onu
TorstenThieme66c91a82020-10-19 13:37:53 +0000220 Run Keyword If ${onu_state_nb}>=2
TorstenThieme1619db22020-04-03 12:01:15 +0000221 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
222 ... Validate Device ENABLED ACTIVATING REACHABLE
223 ... ${src['onu']} onu=True onu_reason=starting-openomci
TorstenThieme66c91a82020-10-19 13:37:53 +0000224 Run Keyword If ${onu_state_nb}>=3
TorstenThieme1619db22020-04-03 12:01:15 +0000225 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
226 ... Validate Device ENABLED ACTIVATING REACHABLE
227 ... ${src['onu']} onu=True onu_reason=discovery-mibsync-complete
TorstenThieme66c91a82020-10-19 13:37:53 +0000228 Run Keyword If ${onu_state_nb}>=4
TorstenThieme1619db22020-04-03 12:01:15 +0000229 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
230 ... Validate Device ENABLED ACTIVE REACHABLE
231 ... ${src['onu']} onu=True onu_reason=initial-mib-downloaded
TorstenThieme66c91a82020-10-19 13:37:53 +0000232 Run Keyword If ${onu_state_nb}>=5
TorstenThieme1619db22020-04-03 12:01:15 +0000233 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
234 ... Validate Device ENABLED ACTIVE REACHABLE
235 ... ${src['onu']} onu=True onu_reason=tech-profile-config-download-success
TorstenThieme66c91a82020-10-19 13:37:53 +0000236 Run Keyword If ${onu_state_nb}>=6
TorstenThieme1619db22020-04-03 12:01:15 +0000237 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
238 ... Validate Device ENABLED ACTIVE REACHABLE
239 ... ${src['onu']} onu=True onu_reason=omci-flows-pushed
240 END
241
242Do ONU Single State Test
243 [Documentation] This keyword performs SingleState Test
244 ... Only the passed state has to be checked
245 FOR ${I} IN RANGE 0 ${num_onus}
246 ${src}= Set Variable ${hosts.src[${I}]}
247 ${dst}= Set Variable ${hosts.dst[${I}]}
TorstenThieme015d5c02020-09-11 09:53:34 +0000248 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
249 ... Validate Device ${admin_state} ${oper_status} ${connect_status}
250 ... ${src['onu']} onu=True onu_reason=${onu_state}
TorstenThieme1619db22020-04-03 12:01:15 +0000251 END
252
TorstenThieme94e4ae42020-05-18 13:01:42 +0000253Do ONU Single State Test Time
254 [Documentation] This keyword performs SingleState Test with calculate running time
255 ... Only the passed state has to be checked and the duration each single onu adapter needed
256 ... will be calculated and printed out
TorstenThieme17becfc2020-10-08 09:46:27 +0000257 #${ListfinishedONUs} Create List
258 #Set Global Variable ${ListfinishedONUs}
TorstenThieme94e4ae42020-05-18 13:01:42 +0000259 Create File ONU_Startup_Time.txt This file contains the startup times of all ONUs.
260 ${list_onus} Create List
TorstenThieme401af432020-06-11 15:53:53 +0000261 Build ONU SN List ${list_onus}
TorstenThieme015d5c02020-09-11 09:53:34 +0000262 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
TorstenThieme9949b172020-06-16 10:00:15 +0000263 ... Validate ONU Devices MIB State With Duration
TorstenThieme015d5c02020-09-11 09:53:34 +0000264 ... ${onu_state} ${list_onus} ${timeStart} print2console=True
TorstenThieme401af432020-06-11 15:53:53 +0000265 ... output_file=ONU_Startup_Time.txt
TorstenThieme94e4ae42020-05-18 13:01:42 +0000266
TorstenThieme1619db22020-04-03 12:01:15 +0000267Do Onu Port Check
TorstenThieme00958682020-06-19 11:29:31 +0000268 [Documentation] Check that all the UNI ports show up in ONOS
TorstenThieme17becfc2020-10-08 09:46:27 +0000269 Wait for Ports in ONOS ${onos_ssh_connection} ${num_onus} BBSM
TorstenThieme9949b172020-06-16 10:00:15 +0000270
TorstenThieme109683b2020-09-24 12:35:41 +0000271Do Onu Flow Check
272 [Documentation] Check that all ONU flows show up in ONOS and Voltha
273 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS ${olt_serial_number}
274 ${nni_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
275 ... Get NNI Port in ONOS ${of_id}
276 FOR ${I} IN RANGE 0 ${num_onus}
277 ${src}= Set Variable ${hosts.src[${I}]}
278 ${dst}= Set Variable ${hosts.dst[${I}]}
279 ${onu_device_id}= Get Device ID From SN ${src['onu']}
280 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
281 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
282 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
283 ... Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
284 ... volt-add-subscriber-access ${of_id} ${onu_port}
285 # Verify subscriber access flows are added for the ONU port
286 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
287 ... Verify Subscriber Access Flows Added For ONU ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
288 ... ${onu_port} ${nni_port} ${src['c_tag']} ${src['s_tag']}
TorstenThieme109683b2020-09-24 12:35:41 +0000289 END
TorstenThieme66c91a82020-10-19 13:37:53 +0000290 #check for previous state is kept (normally omci-flows-pushed)
291 Do Current State Test All Onus ${state2test}
TorstenThieme109683b2020-09-24 12:35:41 +0000292
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000293Set Tech Profile
294 [Documentation] This keyword set the passed TechProfile for the test
295 [Arguments] ${TechProfile}
TorstenThieme87cd6202020-09-09 10:01:28 +0000296 Log To Console \nTechProfile:${TechProfile}
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000297 ${namespace}= Set Variable default
Andrea Campanella60dde302020-09-09 18:42:56 +0200298 ${podname}= Set Variable etcd
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000299 ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
300 ${dest}= Set Variable /tmp/flexpod.json
301 ${command} Catenate
302 ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
303 Copy File To Pod ${namespace} ${podname} ${src} ${dest}
304 Exec Pod ${namespace} ${podname} ${command}
305 ${commandget} Catenate
306 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
307 Exec Pod ${namespace} ${podname} ${commandget}
308
309Remove Tech Profile
310 [Documentation] This keyword removes TechProfile
TorstenThieme015d5c02020-09-11 09:53:34 +0000311 Log To Console \nTechProfile:${TechProfile}
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000312 ${namespace}= Set Variable default
Andrea Campanella60dde302020-09-09 18:42:56 +0200313 ${podname}= Set Variable etcd
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000314 ${command} Catenate
315 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64'
316 Exec Pod ${namespace} ${podname} ${command}
317 ${commandget} Catenate
318 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
319 Exec Pod ${namespace} ${podname} ${commandget}
320
321Do Check Tech Profile
322 [Documentation] This keyword checks the loaded TechProfile
323 ${namespace}= Set Variable default
Andrea Campanella60dde302020-09-09 18:42:56 +0200324 ${podname}= Set Variable etcd
TorstenThiemee0e5bba2020-08-05 11:20:13 +0000325 ${commandget} Catenate
326 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
327 ${result}= Exec Pod ${namespace} ${podname} ${commandget}
328 ${num_gem_ports}= Set Variable 1
329 ${num_gem_ports}= Set Variable If
330 ... "${techprofile}"=="default" 1
331 ... "${techprofile}"=="1T4GEM" 4
332 ... "${techprofile}"=="1T8GEM" 8
333 @{resultList} Split String ${result} separator=,
334 ${num_of_count_matches}= Get Match Count ${resultList} "num_gem_ports": ${num_gem_ports}
335 ... whitespace_insensitive=True
336 ${num_of_expected_matches}= Run Keyword If "${techprofile}"=="default" Evaluate ${num_onus}
337 ... ELSE Evaluate ${num_onus}+1
338 Run Keyword If ${num_of_expected_matches}!=${num_of_count_matches} Log To Console
339 ... \nTechProfile (${TechProfile}) not loaded correctly:${num_of_count_matches} of ${num_of_expected_matches}
TorstenThieme015d5c02020-09-11 09:53:34 +0000340
341Do Disable Enable Onu Test
342 [Documentation] This keyword disables/enables all onus and checks the states.
TorstenThieme17becfc2020-10-08 09:46:27 +0000343 [Arguments] ${state2check}=${state2test}
344 Do Current State Test All Onus ${state2check}
TorstenThieme5ca1dd12020-10-16 08:42:16 +0000345 Do Disable Onu Device
TorstenThieme17becfc2020-10-08 09:46:27 +0000346 Do Current State Test All Onus omci-admin-lock
347 Log Ports
348 #check no port is enabled in ONOS
349 Wait for Ports in ONOS ${onos_ssh_connection} 0 BBSM
TorstenThieme5ca1dd12020-10-16 08:42:16 +0000350 Do Enable Onu Device
TorstenThieme17becfc2020-10-08 09:46:27 +0000351 Do Current State Test All Onus ${state2check}
352 Log Ports onlyenabled=True
353 #check that all the UNI ports show up in ONOS again
354 Wait for Ports in ONOS ${onos_ssh_connection} ${num_onus} BBSM
TorstenThieme015d5c02020-09-11 09:53:34 +0000355
356Do Reconcile Onu Device
357 [Documentation] This keyword reconciles ONU device and check the state afterwards.
358 ... Following steps will be executed:
359 ... - restart openonu adaptor
360 ... - check openonu adaptor is ready again
361 ... - check previous state is kept
362 ... - ONU-Disable
363 ... - wait some seconds
364 ... - check for state omci-admin-lock
365 ... - ONU-Enable
366 ... - wait some seconds
367 ... - check for state onu-reenabled
368 ... - port check
TorstenThieme015d5c02020-09-11 09:53:34 +0000369 ${list_openonu_apps} Create List adapter-open-onu
370 ${namespace}= Set Variable voltha
371 ${adaptorname}= Set Variable open-onu
TorstenThieme015d5c02020-09-11 09:53:34 +0000372 Kill Adaptor ${namespace} ${adaptorname}
373 Sleep 5s
374 Wait For Pods Ready ${namespace} ${list_openonu_apps}
375 Do Disable Enable Onu Test
TorstenThieme66c91a82020-10-19 13:37:53 +0000376 Do Onu Port Check
TorstenThieme015d5c02020-09-11 09:53:34 +0000377
TorstenThieme5ca1dd12020-10-16 08:42:16 +0000378Do Power Off Power On Onu Device
379 [Documentation] This keyword power off/on all onus and checks the states.
380 Do Power Off ONU Device
381 Sleep 5s
382 Do Current State Test All Onus stopping-openomci
383 Do Power On ONU Device
384 Do Current State Test All Onus ${state2test}
385
386Do Disable Onu Device
387 [Documentation] This keyword disables all onus.
TorstenThieme17becfc2020-10-08 09:46:27 +0000388 FOR ${I} IN RANGE 0 ${num_onus}
389 ${src}= Set Variable ${hosts.src[${I}]}
390 ${onu_device_id}= Get Device ID From SN ${src['onu']}
391 Disable Device ${onu_device_id}
392 Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id}
393 END
394
TorstenThieme5ca1dd12020-10-16 08:42:16 +0000395Do Enable Onu Device
396 [Documentation] This keyword enables all onus.
TorstenThieme17becfc2020-10-08 09:46:27 +0000397 FOR ${I} IN RANGE 0 ${num_onus}
398 ${src}= Set Variable ${hosts.src[${I}]}
399 ${onu_device_id}= Get Device ID From SN ${src['onu']}
400 Enable Device ${onu_device_id}
401 END
402
TorstenThieme5ca1dd12020-10-16 08:42:16 +0000403Do Power Off ONU Device
404 [Documentation] This keyword power off all onus.
405 ${namespace}= Set Variable voltha
406 FOR ${I} IN RANGE 0 ${num_onus}
407 ${src}= Set Variable ${hosts.src[${I}]}
408 ${result}= Exec Pod ${namespace} bbsim bbsimctl onu shutdown ${src['onu']}
409 Should Contain ${result} successfully msg=Can not shutdown ${src['onu']} values=False
410 END
411
412Do Power On ONU Device
413 [Documentation] This keyword power on all onus.
414 ${namespace}= Set Variable voltha
415 FOR ${I} IN RANGE 0 ${num_onus}
416 ${src}= Set Variable ${hosts.src[${I}]}
417 ${result}= Exec Pod ${namespace} bbsim bbsimctl onu poweron ${src['onu']}
418 Should Contain ${result} successfully msg=Can not poweron ${src['onu']} values=False
419 END
420
TorstenThieme015d5c02020-09-11 09:53:34 +0000421Do Current State Test
422 [Documentation] This keyword checks the passed state of the given onu.
423 [Arguments] ${state} ${onu}
TorstenThieme66c91a82020-10-19 13:37:53 +0000424 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
TorstenThieme015d5c02020-09-11 09:53:34 +0000425 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
426 ... Validate Device ${admin_state} ${oper_status} ${connect_status}
427 ... ${onu} onu=True onu_reason=${onu_state}
428
TorstenThieme17becfc2020-10-08 09:46:27 +0000429Do Current State Test All Onus
430 [Documentation] This keyword checks the passed state of all onus.
431 ... Hint: ${timeStart} will be not evaluated here!
432 [Arguments] ${state}
433 ${list_onus} Create List
434 Build ONU SN List ${list_onus}
TorstenThieme66c91a82020-10-19 13:37:53 +0000435 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
TorstenThieme17becfc2020-10-08 09:46:27 +0000436 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
437 ... Validate ONU Devices With Duration
438 ... ${admin_state} ${oper_status} ${connect_status}
439 ... ${onu_state} ${list_onus} ${timeStart}
TorstenThieme5ca1dd12020-10-16 08:42:16 +0000440
TorstenThieme17becfc2020-10-08 09:46:27 +0000441Log Ports
442 [Documentation] This keyword logs all port data available in ONOS of first port per ONU
443 [Arguments] ${onlyenabled}=False
444 ${cmd} Set Variable If ${onlyenabled} ports -e ports
445 ${onu_ports}= Execute ONOS CLI Command on open connection ${onos_ssh_connection} ${cmd}
446 ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1
447 Log ${lines}
448
TorstenThieme015d5c02020-09-11 09:53:34 +0000449Kill Adaptor
450 [Documentation] This keyword kills the passed adaptor.
451 [Arguments] ${namespace} ${name}
452 ${cmd} Catenate
453 ... kubectl exec -it -n voltha $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}')
454 ... -- /bin/sh -c "kill 1"
455 ${rc} ${output}= Run and Return Rc and Output ${cmd}
456 Log ${output}
457
TorstenThieme5ca1dd12020-10-16 08:42:16 +0000458Delete MIB Template Data
459 [Documentation] This keyword deletes MIB Template Data stored in etcd
460 ${namespace}= Set Variable default
461 ${podname}= Set Variable etcd
462 ${commanddel} Catenate
463 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/omci_mibs/go_templates/'
464 ${result}= Exec Pod ${namespace} ${podname} ${commanddel}
465 Sleep 3s
466 ${commandget} Catenate
467 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
468 ${result}= Exec Pod ${namespace} ${podname} ${commandget}
469 Should Be Empty ${result} Could not delete MIB Template Data stored in etcd!
470
TorstenThieme015d5c02020-09-11 09:53:34 +0000471Map State
472 [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values.
473 [Arguments] ${state}
474 # create state lists with corresponding return values
TorstenThieme66c91a82020-10-19 13:37:53 +0000475 # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name)
476 ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu
477 ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci
478 ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete
479 ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded
480 ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success
481 ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed
482 ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock
483 ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled
484 ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci
485 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If
TorstenThieme015d5c02020-09-11 09:53:34 +0000486 ... '${state}'=='1' or '${state}'=='activating-onu' ${state1}
487 ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2}
488 ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3}
489 ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4}
490 ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5}
491 ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6}
492 ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7}
493 ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8}
TorstenThieme5ca1dd12020-10-16 08:42:16 +0000494 ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9}
TorstenThieme66c91a82020-10-19 13:37:53 +0000495 [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}