blob: e2c4ff4943bbc55a6272629fa2533cf6e7707507 [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}
41# state to test variable, can be passed via the command line too
42${state2test} 6
43${testmode} SingleState
44${porttest} True
45
46*** Test Cases ***
47ONU State Test
48 [Documentation] Validates the ONU Go adapter states
49 [Tags] statetest
50 [Setup] Run Keywords Start Logging ONUStateTest
51 ... AND Setup Test
52 Run Keyword If ${has_dataplane} Clean Up Linux
53 Enable Device ${olt_device_id}
TorstenThieme94e4ae42020-05-18 13:01:42 +000054 ${timeStart} = Get Current Date
55 Set Global Variable ${timeStart}
TorstenThieme1619db22020-04-03 12:01:15 +000056 Run Keyword If "${testmode}"=="SingleState" Do ONU Single State Test
57 ... ELSE IF "${testmode}"=="Up2State" Do ONU Up To State Test
TorstenThieme94e4ae42020-05-18 13:01:42 +000058 ... ELSE IF "${testmode}"=="SingleStateTime" Do ONU Single State Test Time
TorstenThieme1619db22020-04-03 12:01:15 +000059 ... ELSE Fail The testmode (${testmode}) is not valid!
60 Run Keyword If ${porttest} Do Onu Port Check
61 [Teardown] Run Keywords Collect Logs
62 ... AND Stop Logging ONUStateTest
63
64*** Keywords ***
65Setup Suite
66 [Documentation] Set up the test suite
67 Common Test Suite Setup
68 Run Keyword If ${num_onus}>4 Calculate Timeout
69
70Setup Test
71 [Documentation] Pre-test Setup
72 #test for empty device list
73 Test Empty Device List
74 Run Keyword If ${has_dataplane} Wait Until Keyword Succeeds 120s 10s Openolt is Up
75 ... ${olt_ip} ${olt_user} ${olt_pass}
76 Run Keyword If ${has_dataplane} Sleep 60s
77 #create/preprovision device
78 ${olt_device_id}= Create Device ${olt_ip} ${OLT_PORT}
79 Set Suite Variable ${olt_device_id}
80 #validate olt states
81 Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device PREPROVISIONED UNKNOWN UNKNOWN
82 ... ${olt_device_id}
83 Sleep 5s
84
85Calculate Timeout
86 [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus
87 ${timeout} Fetch From Left ${timeout} s
88 ${timeout}= evaluate ${timeout}+((${num_onus}-4)*30)
89 ${timeout}= Catenate SEPARATOR= ${timeout} s
90 Set Suite Variable ${timeout}
91 #Log \r\nTimeout: ${timeout} INFO console=True
92
93Do ONU Up To State Test
94 [Documentation] This keyword performs Up2State Test
95 ... All states up to the passed have to be checked
96 FOR ${I} IN RANGE 0 ${num_onus}
97 ${src}= Set Variable ${hosts.src[${I}]}
98 ${dst}= Set Variable ${hosts.dst[${I}]}
99 Run Keyword If ${state2test}>=1
100 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
101 ... Validate Device ENABLED ACTIVATING REACHABLE
102 ... ${src['onu']} onu=True onu_reason=activating-onu
103 Run Keyword If ${state2test}>=2
104 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
105 ... Validate Device ENABLED ACTIVATING REACHABLE
106 ... ${src['onu']} onu=True onu_reason=starting-openomci
107 Run Keyword If ${state2test}>=3
108 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
109 ... Validate Device ENABLED ACTIVATING REACHABLE
110 ... ${src['onu']} onu=True onu_reason=discovery-mibsync-complete
111 Run Keyword If ${state2test}>=4
112 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
113 ... Validate Device ENABLED ACTIVE REACHABLE
114 ... ${src['onu']} onu=True onu_reason=initial-mib-downloaded
115 Run Keyword If ${state2test}>=5
116 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
117 ... Validate Device ENABLED ACTIVE REACHABLE
118 ... ${src['onu']} onu=True onu_reason=tech-profile-config-download-success
119 Run Keyword If ${state2test}>=6
120 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
121 ... Validate Device ENABLED ACTIVE REACHABLE
122 ... ${src['onu']} onu=True onu_reason=omci-flows-pushed
123 END
124
125Do ONU Single State Test
126 [Documentation] This keyword performs SingleState Test
127 ... Only the passed state has to be checked
128 FOR ${I} IN RANGE 0 ${num_onus}
129 ${src}= Set Variable ${hosts.src[${I}]}
130 ${dst}= Set Variable ${hosts.dst[${I}]}
131 Run Keyword If ${state2test}==1
132 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
133 ... Validate Device ENABLED ACTIVATING REACHABLE
134 ... ${src['onu']} onu=True onu_reason=activating-onu
135 ... ELSE IF ${state2test}==2
136 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
137 ... Validate Device ENABLED ACTIVATING REACHABLE
138 ... ${src['onu']} onu=True onu_reason=starting-openomci
139 ... ELSE IF ${state2test}==3
140 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
141 ... Validate Device ENABLED ACTIVATING REACHABLE
142 ... ${src['onu']} onu=True onu_reason=discovery-mibsync-complete
143 ... ELSE IF ${state2test}==4
144 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
145 ... Validate Device ENABLED ACTIVE REACHABLE
146 ... ${src['onu']} onu=True onu_reason=initial-mib-downloaded
147 ... ELSE IF ${state2test}==5
148 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
149 ... Validate Device ENABLED ACTIVE REACHABLE
150 ... ${src['onu']} onu=True onu_reason=tech-profile-config-download-success
151 ... ELSE IF ${state2test}==6
152 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
153 ... Validate Device ENABLED ACTIVE REACHABLE
154 ... ${src['onu']} onu=True onu_reason=omci-flows-pushed
155 ... ELSE Fail The state to test (${state2test}) is not valid!
156 END
157
TorstenThieme94e4ae42020-05-18 13:01:42 +0000158Do ONU Single State Test Time
159 [Documentation] This keyword performs SingleState Test with calculate running time
160 ... Only the passed state has to be checked and the duration each single onu adapter needed
161 ... will be calculated and printed out
162 ${ListfinishedONUs} Create List
163 Set Global Variable ${ListfinishedONUs}
164 Create File ONU_Startup_Time.txt This file contains the startup times of all ONUs.
165 ${list_onus} Create List
166 FOR ${I} IN RANGE 0 ${num_onus}
167 ${src}= Set Variable ${hosts.src[${I}]}
168 ${dst}= Set Variable ${hosts.dst[${I}]}
169 ${onu} Evaluate ${hosts.src}[${I}].get("onu")
170 Append To List ${list_onus} ${onu}
171 END
172 Run Keyword If ${state2test}==1
173 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
174 ... Validate ONU Devices With Duration ENABLED ACTIVATING REACHABLE
175 ... ${list_onus} onu_reason=activating-onu
176 ... ELSE IF ${state2test}==2
177 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
178 ... Validate ONU Devices With Duration ENABLED ACTIVATING REACHABLE
179 ... ${list_onus} onu_reason=starting-openomci
180 ... ELSE IF ${state2test}==3
181 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
182 ... Validate ONU Devices With Duration ENABLED ACTIVATING REACHABLE
183 ... ${list_onus} onu_reason=discovery-mibsync-complete
184 ... ELSE IF ${state2test}==4
185 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
186 ... Validate ONU Devices With Duration ENABLED ACTIVE REACHABLE
187 ... ${list_onus} onu_reason=initial-mib-downloaded
188 ... ELSE IF ${state2test}==5
189 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
190 ... Validate ONU Devices With Duration ENABLED ACTIVE REACHABLE
191 ... ${list_onus} onu_reason=tech-profile-config-download-success
192 ... ELSE IF ${state2test}==6
193 ... Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
194 ... Validate ONU Devices With Duration ENABLED ACTIVE REACHABLE
195 ... ${list_onus} onu_reason=omci-flows-pushed
196 ... ELSE Fail The state to test (${state2test}) is not valid!
197
TorstenThieme1619db22020-04-03 12:01:15 +0000198Do Onu Port Check
199 [Documentation] This keyword performs Onu Port Check
200 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS ${olt_serial_number}
201 Set Global Variable ${of_id}
202 FOR ${I} IN RANGE 0 ${num_onus}
203 ${src}= Set Variable ${hosts.src[${I}]}
204 ${dst}= Set Variable ${hosts.dst[${I}]}
205 ${onu_device_id}= Get Device ID From SN ${src['onu']}
206 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
207 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
208 Run Keyword And Continue On Failure Wait Until Keyword Succeeds 120s 2s
209 ... Verify ONU Port Is Enabled ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${onu_port}
210 END
TorstenThieme94e4ae42020-05-18 13:01:42 +0000211
212Validate ONU Devices With Duration
213 [Documentation]
214 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
215 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
216 ... states including MIB state.
217 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
218 ... ${onu_reason}=${EMPTY}
219 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
220 Should Be Equal As Integers ${rc} 0
221 ${timeCurrent} = Get Current Date
222 ${jsondata}= To Json ${output}
223 ${length}= Get Length ${jsondata}
224 FOR ${INDEX} IN RANGE 0 ${length}
225 ${matched}= Set Variable False
226 ${value}= Get From List ${jsondata} ${INDEX}
227 ${astate}= Get From Dictionary ${value} adminstate
228 ${opstatus}= Get From Dictionary ${value} operstatus
229 ${cstatus}= Get From Dictionary ${value} connectstatus
230 ${sn}= Get From Dictionary ${value} serialnumber
231 ${mib_state}= Get From Dictionary ${value} reason
232 ${finished_id}= Get Index From List ${ListfinishedONUs} ${sn}
233 ${onu_id}= Get Index From List ${List_ONU_Serial} ${sn}
234 ${matched}= Set Variable If -1 == ${finished_id} True False
235 ${matched}= Set Variable If -1 != ${onu_id} ${matched} False
236 ${matched}= Set Variable If '${astate}' == '${admin_state}' ${matched} False
237 ${matched}= Set Variable If '${opstatus}' == '${oper_status}' ${matched} False
238 ${matched}= Set Variable If '${cstatus}' == '${connect_status}' ${matched} False
239 ${matched}= Set Variable If '${mib_state}' == '${onu_reason}' ${matched} False
240 Run Keyword If ${matched} Log And Store Finished ONU ${sn} ${timeCurrent} ${onu_reason}
241 Run Keyword If ${matched} or -1 != ${finished_id} Remove Values From List ${List_ONU_Serial} ${sn}
242 END
243 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
244
245Log And Store Finished ONU
246 [Documentation]
247 ... Log and stores the finished ONU
248 [Arguments] ${onu_sn} ${finish_time} ${onu_reason}
249 ${timeTotalMs} = Subtract Date From Date ${finish_time} ${timeStart} result_format=number
250 Log \r\nONU ${onu_sn} reached the state ${onu_reason} after ${timeTotalMs} sec. INFO console=True
251 Append To File ONU_Startup_Time.txt
252 ... \r\nONU ${onu_sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
253 Append To List ${ListfinishedONUs} ${onu_sn}
254 Set Global Variable ${ListfinishedONUs}