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