blob: 3858c75cb86dd7d3ec5116f901ad420f92e9e927 [file] [log] [blame]
TorstenThiemea7315f12021-07-23 11:56:34 +00001# Copyright 2021 - 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 of open ONU go adapter Flows
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
34Resource ../../libraries/power_switch.robot
35Resource ../../libraries/onu_utilities.robot
36
37*** Variables ***
Hardik Windlass4288c6a2021-09-28 07:22:06 +000038${NAMESPACE} voltha
39${INFRA_NAMESPACE} default
TorstenThiemea7315f12021-07-23 11:56:34 +000040${timeout} 60s
41${of_id} 0
42${logical_id} 0
43${has_dataplane} True
44${external_libs} True
45${teardown_device} True
46${scripts} ../../scripts
47# Per-test logging on failure is turned off by default; set this variable to enable
48${container_log_dir} ${None}
TorstenThieme54ba3c62021-07-29 06:54:08 +000049# KV Store Prefix
50# example: -v kvstoreprefix:voltha_voltha
51${kvstoreprefix} voltha_voltha
TorstenThiemea7315f12021-07-23 11:56:34 +000052# determines the environment workflow: DT, TT or ATT (default)
53# example: -v workflow:DT
54${workflow} ATT
55# logging flag to enable Collect Logs, can be passed via the command line too
56# example: -v logging:True
57${logging} False
58# used tech profile, can be passed via the command line too, valid values: default (=1T1GEM), 1T4GEM, 1T8GEM
59# example: -v techprofile:1T4GEM
60${techprofile} default
61# if True execution will be paused before clean up, only use in case of manual testing, do not use in ci pipeline!
62# example: -v pausebeforecleanup:True
63${pausebeforecleanup} False
64${data_dir} ../data
65
66*** Test Cases ***
67Flows Test
68 [Documentation] Validates onu vlan rules in etcd:
69 [Tags] functionalOnuGo FlowsTest
70 [Setup] Start Logging FlowsTest
71 ${onu_tags_dict}= Collect Tags Per ONU
72 # Check and store vlan rules
73 Wait Until Keyword Succeeds ${timeout} 2s Run Keyword And Continue On Failure
74 ... Validate Etcd Vlan Rules Added Subscriber ${onu_tags_dict} defaultkvstoreprefix=${kvstoreprefix}
75 #log flows for verification
76 ${flowsresult}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} flows -s
77 log ${flowsresult}
78 FOR ${J} IN RANGE 0 ${num_olts}
79 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
80 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
81 ... ${olt_serial_number}
82 # Remove subscriber
83 Do Onu Subscriber Remove Per OLT ${of_id} ${olt_serial_number}
84 END
85 #log flows for verification
86 ${flowsresult}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} flows -s
87 log ${flowsresult}
88 Wait Until Keyword Succeeds ${timeout} 2s Run Keyword And Continue On Failure Run Keyword And Continue On Failure
89 ... Validate Etcd Vlan Rules Removed Subscriber defaultkvstoreprefix=${kvstoreprefix}
90 FOR ${J} IN RANGE 0 ${num_olts}
91 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
92 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
93 ... ${olt_serial_number}
94 Do Onu Subscriber Add Per OLT ${of_id} ${olt_serial_number}
95 END
96 #log flows for verification
97 ${flowsresult}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} flows -s
98 log ${flowsresult}
99 Wait Until Keyword Succeeds ${timeout} 2s Run Keyword And Continue On Failure Run Keyword And Continue On Failure
100 ... Validate Etcd Vlan Rules Added Subscriber ${onu_tags_dict} defaultkvstoreprefix=${kvstoreprefix}
101 [Teardown] Run Keywords Run Keyword If ${logging} Collect Logs
102 ... AND Stop Logging FlowsTest
103
104*** Keywords ***
105Setup Suite
106 [Documentation] Set up the test suite inclusive enable device and sanity test of given workflow
Andrea Campanella82add372021-11-05 12:01:15 +0100107 Start Logging Setup or Teardown Setup-${SUITE NAME}
TorstenThiemea7315f12021-07-23 11:56:34 +0000108 Common Test Suite Setup
109 ${techprofile}= Set Variable If "${techprofile}"=="1T1GEM" default ${techprofile}
110 Set Suite Variable ${techprofile}
111 Run Keyword If "${techprofile}"=="default" Log To Console \nTechProfile:default (1T1GEM)
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000112 ... ELSE IF "${techprofile}"=="1T4GEM" Set Tech Profile 1T4GEM ${INFRA_NAMESPACE}
113 ... ELSE IF "${techprofile}"=="1T8GEM" Set Tech Profile 1T8GEM ${INFRA_NAMESPACE}
TorstenThiemea7315f12021-07-23 11:56:34 +0000114 ... ELSE Fail The TechProfile (${techprofile}) is not valid!
115 ${switch_type}= Get Variable Value ${web_power_switch.type}
116 Run Keyword If "${switch_type}"!="" Set Global Variable ${powerswitch_type} ${switch_type}
117 Setup
118 Run Keyword If ${has_dataplane} Clean Up Linux
119 Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT
120 ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT
121 ... ELSE Perform Sanity Test
Andrea Campanella82add372021-11-05 12:01:15 +0100122 Run Keyword If ${logging} Collect Logs
123 Stop Logging Setup or Teardown Setup-${SUITE NAME}
TorstenThiemea7315f12021-07-23 11:56:34 +0000124
125Teardown Suite
126 [Documentation] Replaces the Suite Teardown in utils.robot.
127 ... Cleans up and checks all ONU ports disabled in ONOS.
128 ... Furthermore gives the possibility to pause the execution.
Andrea Campanella82add372021-11-05 12:01:15 +0100129 Start Logging Setup or Teardown Teardown-${SUITE NAME}
TorstenThiemea7315f12021-07-23 11:56:34 +0000130 Run Keyword If ${pausebeforecleanup} Import Library Dialogs
131 Run Keyword If ${pausebeforecleanup} Pause Execution Press OK to continue with clean up!
132 Run Keyword If ${pausebeforecleanup} Log Teardown will be continued... console=yes
133 Run Keyword If ${teardown_device} Delete All Devices and Verify
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000134 Wait Until Keyword Succeeds ${timeout} 1s Validate Onu Data In Etcd ${INFRA_NAMESPACE} 0 ${kvstoreprefix}
135 ... without_pm_data=False
TorstenThiemea7315f12021-07-23 11:56:34 +0000136 Wait for Ports in ONOS for all OLTs ${ONOS_SSH_IP} ${ONOS_SSH_PORT} 0 BBSM ${timeout}
Andrea Campanella82add372021-11-05 12:01:15 +0100137 Run Keyword If ${logging} Collect Logs
138 Stop Logging Setup or Teardown Teardown-${SUITE NAME}
TorstenThiemea7315f12021-07-23 11:56:34 +0000139 Close All ONOS SSH Connections
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000140 Remove Tech Profile ${INFRA_NAMESPACE}
TorstenThiemea7315f12021-07-23 11:56:34 +0000141
142Validate Etcd Vlan Rules Added Subscriber
143 [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
144 ... It checks the match_vid (=4096) and set_vid when subscriber are added.
145 [Arguments] ${onu_tags_dict} ${reqmatchvid}=4096 ${defaultkvstoreprefix}=voltha_voltha
146 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000147 ${etcddata}= Get ONU Go Adapter ETCD Data ${INFRA_NAMESPACE} ${kvstoreprefix} True True
TorstenThiemea7315f12021-07-23 11:56:34 +0000148 #prepare result for json convert
149 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
150 ${jsondata}= To Json ${result}
151 ${length}= Get Length ${jsondata}
152 log ${jsondata}
TorstenThieme54ba3c62021-07-29 06:54:08 +0000153 Should Not Be Empty ${jsondata}
TorstenThiemea7315f12021-07-23 11:56:34 +0000154 FOR ${INDEX} IN RANGE 0 ${length}
155 ${value}= Get From List ${jsondata} ${INDEX}
156 ${flowparams}= Get From Dictionary ${value['uni_config'][0]} flow_params
157 ${onu}= Get From Dictionary ${value} serial_number
158 Validate Flow Params Vlan Rules ${flowparams} ${onu_tags_dict} ${onu} ${reqmatchvid}
159 END
160
161Validate Flow Params Vlan Rules
162 [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data iterating over passed flow params.
163 ... It checks the match_vid (=4096) and set_vid when subscriber are added.
164 [Arguments] ${flowparams} ${onu_tags_dict} ${onu} ${reqmatchvid}=4096
165 ${length}= Get Length ${flowparams}
166 ${nbofexpectedrules}= Set Variable If
167 ... "${workflow}"=="TT" and ${has_dataplane} 4
168 ... "${workflow}"=="TT" and not ${has_dataplane} 3
169 ... "${workflow}"=="DT" or "${workflow}"=="ATT" 1
170 Should Be Equal As Numbers ${length} ${nbofexpectedrules}
171 ... msg=wrong number of vlan rules (${length} != ${nbofexpectedrules})!
172 FOR ${INDEX} IN RANGE 0 ${length}
173 ${value}= Get From List ${flowparams} ${INDEX}
174 ${matchvid}= Get From Dictionary ${value['vlan_rule_params']}
175 ... match_vid
176 Should Be Equal As Integers ${matchvid} ${reqmatchvid}
177 ${setvid}= Get From Dictionary ${value['vlan_rule_params']}
178 ... set_vid
179 ${c_tags_list}= Get From Dictionary ${onu_tags_dict['${onu}']} c_tags
180 ${tagindex}= Get Index From List ${c_tags_list} ${setvid}
181 Should Not Be Equal As Integers ${tagindex} -1 msg=set_vid out of range (${setvid})!
182 END
183
184Validate Etcd Vlan Rules Removed Subscriber
185 [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
186 ... It checks the match_vid (=4096) and set_vid when subscriber are removed.
187 [Arguments] ${reqmatchvid}=4096 ${defaultkvstoreprefix}=voltha_voltha
188 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000189 ${etcddata}= Get ONU Go Adapter ETCD Data ${INFRA_NAMESPACE} ${kvstoreprefix} True True
TorstenThiemea7315f12021-07-23 11:56:34 +0000190 #prepare result for json convert
191 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
192 ${jsondata}= To Json ${result}
193 ${length}= Get Length ${jsondata}
194 log ${jsondata}
TorstenThieme54ba3c62021-07-29 06:54:08 +0000195 Should Not Be Empty ${jsondata}
TorstenThiemea7315f12021-07-23 11:56:34 +0000196 FOR ${INDEX} IN RANGE 0 ${length}
197 ${value}= Get From List ${jsondata} ${INDEX}
198 @{result_values}= Run Keyword And Ignore Error
199 ... Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']} match_vid
200 ${result}= Set Variable @{result_values}[0]
201 ${matchvid}= Set Variable @{result_values}[1]
202 Run Keyword If "${workflow}"=="ATT" Should Be Equal As Integers ${matchvid} ${reqmatchvid}
203 ... ELSE Should Be Equal As Strings ${result} FAIL
204 @{result_values}= Run Keyword And Ignore Error
205 ... Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']} set_vid
206 ${result}= Set Variable @{result_values}[0]
207 ${setvid}= Set Variable @{result_values}[1]
208 ${evalresult}= Run Keyword If "${workflow}"=="ATT" Evaluate ${setvid} == 4091
209 ... ELSE Evaluate "${result}" == "FAIL"
210 Should Be True ${evalresult} msg=set_vid out of range (${setvid})!
211 END
212
213Collect Tags Per ONU
214 [Documentation] This keyword collects the s- and c-tags per ONU.
215 ${onu_tags_dict}= Create Dictionary
216 FOR ${I} IN RANGE 0 ${num_all_onus}
217 ${src}= Set Variable ${hosts.src[${I}]}
218 ${onu_tags_dict}= Run Keyword If '${src['onu']}' in ${onu_tags_dict} Update ONU Tags Dict ${onu_tags_dict}
219 ... ${src['onu']} ${src['c_tag']} ${src['s_tag']}
220 ... ELSE Append To ONU Tags Dict ${onu_tags_dict}
221 ... ${src['onu']} ${src['c_tag']} ${src['s_tag']}
222 END
223 log ${onu_tags_dict}
224 [return] ${onu_tags_dict}
225
226Update ONU Tags Dict
227 [Documentation] This keyword update passed dictionary with the s- and c-tags for passed ONU.
228 [Arguments] ${onu_tags_dict} ${onu} ${c_tag} ${s_tag}
229 ${c_tag}= Convert To Integer ${c_tag}
230 ${s_tag}= Convert To Integer ${s_tag}
231 ${c_tags_list}= Get From Dictionary ${onu_tags_dict['${onu}']} c_tags
232 Append To List ${c_tags_list} ${c_tag}
233 ${s_tags_list}= Get From Dictionary ${onu_tags_dict['${onu}']} s_tags
234 Append To List ${s_tags_list} ${s_tag}
235 Set To Dictionary ${onu_tags_dict['${onu}']} c_tags ${c_tags_list} s_tags ${s_tags_list}
236 [return] ${onu_tags_dict}
237
238Append To ONU Tags Dict
239 [Documentation] This keyword append the s- and c-tags of passed ONU to passed dictionary .
240 [Arguments] ${onu_tags_dict} ${onu} ${c_tag} ${s_tag}
241 ${c_tag}= Convert To Integer ${c_tag}
242 ${s_tag}= Convert To Integer ${s_tag}
243 ${c_tags_list}= Create List ${c_tag}
244 ${s_tags_list}= Create List ${s_tag}
245 ${onu_dict}= Create Dictionary c_tags ${c_tags_list} s_tags ${s_tags_list}
246 Set To Dictionary ${onu_tags_dict} ${onu} ${onu_dict}
247 [return] ${onu_tags_dict}