Joey Armstrong | 9fadcbe | 2024-01-17 19:00:37 -0500 | [diff] [blame] | 1 | # Copyright 2021-2024 Open Networking Foundation (ONF) and the ONF Contributors |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 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 *** |
| 17 | Documentation Test of open ONU go adapter Flows |
| 18 | Suite Setup Setup Suite |
| 19 | Test Setup Setup |
| 20 | Test Teardown Teardown |
| 21 | Suite Teardown Teardown Suite |
| 22 | Library Collections |
| 23 | Library String |
| 24 | Library OperatingSystem |
| 25 | Library XML |
| 26 | Library RequestsLibrary |
| 27 | Library ../../libraries/DependencyLibrary.py |
| 28 | Resource ../../libraries/onos.robot |
| 29 | Resource ../../libraries/voltctl.robot |
| 30 | Resource ../../libraries/voltha.robot |
| 31 | Resource ../../libraries/utils.robot |
| 32 | Resource ../../libraries/k8s.robot |
| 33 | Resource ../../variables/variables.robot |
| 34 | Resource ../../libraries/power_switch.robot |
| 35 | Resource ../../libraries/onu_utilities.robot |
| 36 | |
| 37 | *** Variables *** |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 38 | ${NAMESPACE} voltha |
| 39 | ${INFRA_NAMESPACE} default |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 40 | ${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} |
TorstenThieme | 54ba3c6 | 2021-07-29 06:54:08 +0000 | [diff] [blame] | 49 | # KV Store Prefix |
Andrea Campanella | 388cd87 | 2022-02-10 09:11:39 +0100 | [diff] [blame] | 50 | # example: -v kvstoreprefix:voltha/voltha_voltha |
| 51 | ${kvstoreprefix} voltha/voltha_voltha |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 52 | # 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 | |
Hardik Windlass | b1bda36 | 2021-11-24 11:54:36 +0000 | [diff] [blame] | 66 | # flag to choose the subscriber provisioning command type in ONOS |
| 67 | # TT often provision a single services for a subscriber (eg: hsia, voip, ...) one after the other. |
| 68 | # if set to True, command used is "volt-add-subscriber-unitag" |
| 69 | # if set to False, comand used is "volt-add-subscriber-access" |
| 70 | ${unitag_sub} False |
| 71 | |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 72 | *** Test Cases *** |
| 73 | Flows Test |
| 74 | [Documentation] Validates onu vlan rules in etcd: |
| 75 | [Tags] functionalOnuGo FlowsTest |
| 76 | [Setup] Start Logging FlowsTest |
| 77 | ${onu_tags_dict}= Collect Tags Per ONU |
| 78 | # Check and store vlan rules |
| 79 | Wait Until Keyword Succeeds ${timeout} 2s Run Keyword And Continue On Failure |
| 80 | ... Validate Etcd Vlan Rules Added Subscriber ${onu_tags_dict} defaultkvstoreprefix=${kvstoreprefix} |
| 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 | FOR ${J} IN RANGE 0 ${num_olts} |
| 85 | ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn] |
| 86 | ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS |
| 87 | ... ${olt_serial_number} |
| 88 | # Remove subscriber |
| 89 | Do Onu Subscriber Remove Per OLT ${of_id} ${olt_serial_number} |
| 90 | END |
| 91 | #log flows for verification |
| 92 | ${flowsresult}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} flows -s |
| 93 | log ${flowsresult} |
| 94 | Wait Until Keyword Succeeds ${timeout} 2s Run Keyword And Continue On Failure Run Keyword And Continue On Failure |
| 95 | ... Validate Etcd Vlan Rules Removed Subscriber defaultkvstoreprefix=${kvstoreprefix} |
| 96 | FOR ${J} IN RANGE 0 ${num_olts} |
| 97 | ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn] |
| 98 | ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS |
| 99 | ... ${olt_serial_number} |
| 100 | Do Onu Subscriber Add Per OLT ${of_id} ${olt_serial_number} |
| 101 | END |
| 102 | #log flows for verification |
| 103 | ${flowsresult}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} flows -s |
| 104 | log ${flowsresult} |
| 105 | Wait Until Keyword Succeeds ${timeout} 2s Run Keyword And Continue On Failure Run Keyword And Continue On Failure |
| 106 | ... Validate Etcd Vlan Rules Added Subscriber ${onu_tags_dict} defaultkvstoreprefix=${kvstoreprefix} |
TorstenThieme | 373adfe | 2021-12-16 13:03:04 +0000 | [diff] [blame] | 107 | [Teardown] Run Keywords Printout ONU Serial Number and Device Id |
| 108 | ... AND Run Keyword If ${logging} Collect Logs |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 109 | ... AND Stop Logging FlowsTest |
| 110 | |
| 111 | *** Keywords *** |
| 112 | Setup Suite |
| 113 | [Documentation] Set up the test suite inclusive enable device and sanity test of given workflow |
Andrea Campanella | 82add37 | 2021-11-05 12:01:15 +0100 | [diff] [blame] | 114 | Start Logging Setup or Teardown Setup-${SUITE NAME} |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 115 | Common Test Suite Setup |
| 116 | ${techprofile}= Set Variable If "${techprofile}"=="1T1GEM" default ${techprofile} |
| 117 | Set Suite Variable ${techprofile} |
| 118 | Run Keyword If "${techprofile}"=="default" Log To Console \nTechProfile:default (1T1GEM) |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 119 | ... ELSE IF "${techprofile}"=="1T4GEM" Set Tech Profile 1T4GEM ${INFRA_NAMESPACE} |
| 120 | ... ELSE IF "${techprofile}"=="1T8GEM" Set Tech Profile 1T8GEM ${INFRA_NAMESPACE} |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 121 | ... ELSE Fail The TechProfile (${techprofile}) is not valid! |
| 122 | ${switch_type}= Get Variable Value ${web_power_switch.type} |
| 123 | Run Keyword If "${switch_type}"!="" Set Global Variable ${powerswitch_type} ${switch_type} |
| 124 | Setup |
| 125 | Run Keyword If ${has_dataplane} Clean Up Linux |
| 126 | Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT |
| 127 | ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT |
| 128 | ... ELSE Perform Sanity Test |
Andrea Campanella | 82add37 | 2021-11-05 12:01:15 +0100 | [diff] [blame] | 129 | Run Keyword If ${logging} Collect Logs |
| 130 | Stop Logging Setup or Teardown Setup-${SUITE NAME} |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 131 | |
| 132 | Teardown Suite |
| 133 | [Documentation] Replaces the Suite Teardown in utils.robot. |
| 134 | ... Cleans up and checks all ONU ports disabled in ONOS. |
| 135 | ... Furthermore gives the possibility to pause the execution. |
Andrea Campanella | 82add37 | 2021-11-05 12:01:15 +0100 | [diff] [blame] | 136 | Start Logging Setup or Teardown Teardown-${SUITE NAME} |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 137 | Run Keyword If ${pausebeforecleanup} Import Library Dialogs |
| 138 | Run Keyword If ${pausebeforecleanup} Pause Execution Press OK to continue with clean up! |
| 139 | Run Keyword If ${pausebeforecleanup} Log Teardown will be continued... console=yes |
| 140 | Run Keyword If ${teardown_device} Delete All Devices and Verify |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 141 | Wait Until Keyword Succeeds ${timeout} 1s Validate Onu Data In Etcd ${INFRA_NAMESPACE} 0 ${kvstoreprefix} |
| 142 | ... without_pm_data=False |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 143 | Wait for Ports in ONOS for all OLTs ${ONOS_SSH_IP} ${ONOS_SSH_PORT} 0 BBSM ${timeout} |
Andrea Campanella | 82add37 | 2021-11-05 12:01:15 +0100 | [diff] [blame] | 144 | Run Keyword If ${logging} Collect Logs |
| 145 | Stop Logging Setup or Teardown Teardown-${SUITE NAME} |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 146 | Close All ONOS SSH Connections |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 147 | Remove Tech Profile ${INFRA_NAMESPACE} |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 148 | |
| 149 | Validate Etcd Vlan Rules Added Subscriber |
| 150 | [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd. |
| 151 | ... It checks the match_vid (=4096) and set_vid when subscriber are added. |
Andrea Campanella | 388cd87 | 2022-02-10 09:11:39 +0100 | [diff] [blame] | 152 | [Arguments] ${onu_tags_dict} ${reqmatchvid}=4096 ${defaultkvstoreprefix}=voltha/voltha_voltha |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 153 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 154 | ${etcddata}= Get ONU Go Adapter ETCD Data ${INFRA_NAMESPACE} ${kvstoreprefix} True True |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 155 | #prepare result for json convert |
| 156 | ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata} |
| 157 | ${jsondata}= To Json ${result} |
| 158 | ${length}= Get Length ${jsondata} |
Cristina de Francisco | c4cfd7e | 2023-10-09 10:55:08 +0200 | [diff] [blame] | 159 | Log ${jsondata} |
| 160 | Should Not Be Empty ${jsondata} Could not find ONU Go Adapter ETCD data |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 161 | FOR ${INDEX} IN RANGE 0 ${length} |
| 162 | ${value}= Get From List ${jsondata} ${INDEX} |
| 163 | ${flowparams}= Get From Dictionary ${value['uni_config'][0]} flow_params |
| 164 | ${onu}= Get From Dictionary ${value} serial_number |
| 165 | Validate Flow Params Vlan Rules ${flowparams} ${onu_tags_dict} ${onu} ${reqmatchvid} |
| 166 | END |
| 167 | |
| 168 | Validate Flow Params Vlan Rules |
| 169 | [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data iterating over passed flow params. |
| 170 | ... It checks the match_vid (=4096) and set_vid when subscriber are added. |
| 171 | [Arguments] ${flowparams} ${onu_tags_dict} ${onu} ${reqmatchvid}=4096 |
| 172 | ${length}= Get Length ${flowparams} |
| 173 | ${nbofexpectedrules}= Set Variable If |
| 174 | ... "${workflow}"=="TT" and ${has_dataplane} 4 |
| 175 | ... "${workflow}"=="TT" and not ${has_dataplane} 3 |
| 176 | ... "${workflow}"=="DT" or "${workflow}"=="ATT" 1 |
| 177 | Should Be Equal As Numbers ${length} ${nbofexpectedrules} |
| 178 | ... msg=wrong number of vlan rules (${length} != ${nbofexpectedrules})! |
| 179 | FOR ${INDEX} IN RANGE 0 ${length} |
| 180 | ${value}= Get From List ${flowparams} ${INDEX} |
| 181 | ${matchvid}= Get From Dictionary ${value['vlan_rule_params']} |
| 182 | ... match_vid |
| 183 | Should Be Equal As Integers ${matchvid} ${reqmatchvid} |
| 184 | ${setvid}= Get From Dictionary ${value['vlan_rule_params']} |
| 185 | ... set_vid |
| 186 | ${c_tags_list}= Get From Dictionary ${onu_tags_dict['${onu}']} c_tags |
| 187 | ${tagindex}= Get Index From List ${c_tags_list} ${setvid} |
| 188 | Should Not Be Equal As Integers ${tagindex} -1 msg=set_vid out of range (${setvid})! |
| 189 | END |
| 190 | |
| 191 | Validate Etcd Vlan Rules Removed Subscriber |
| 192 | [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd. |
| 193 | ... It checks the match_vid (=4096) and set_vid when subscriber are removed. |
Andrea Campanella | 388cd87 | 2022-02-10 09:11:39 +0100 | [diff] [blame] | 194 | [Arguments] ${reqmatchvid}=4096 ${defaultkvstoreprefix}=voltha/voltha_voltha |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 195 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 196 | ${etcddata}= Get ONU Go Adapter ETCD Data ${INFRA_NAMESPACE} ${kvstoreprefix} True True |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 197 | #prepare result for json convert |
| 198 | ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata} |
| 199 | ${jsondata}= To Json ${result} |
| 200 | ${length}= Get Length ${jsondata} |
| 201 | log ${jsondata} |
Cristina de Francisco | c4cfd7e | 2023-10-09 10:55:08 +0200 | [diff] [blame] | 202 | Should Not Be Empty ${jsondata} Could not find ONU Go Adapter ETCD data |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 203 | FOR ${INDEX} IN RANGE 0 ${length} |
| 204 | ${value}= Get From List ${jsondata} ${INDEX} |
| 205 | @{result_values}= Run Keyword And Ignore Error |
| 206 | ... Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']} match_vid |
| 207 | ${result}= Set Variable @{result_values}[0] |
| 208 | ${matchvid}= Set Variable @{result_values}[1] |
| 209 | Run Keyword If "${workflow}"=="ATT" Should Be Equal As Integers ${matchvid} ${reqmatchvid} |
| 210 | ... ELSE Should Be Equal As Strings ${result} FAIL |
| 211 | @{result_values}= Run Keyword And Ignore Error |
| 212 | ... Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']} set_vid |
| 213 | ${result}= Set Variable @{result_values}[0] |
| 214 | ${setvid}= Set Variable @{result_values}[1] |
| 215 | ${evalresult}= Run Keyword If "${workflow}"=="ATT" Evaluate ${setvid} == 4091 |
| 216 | ... ELSE Evaluate "${result}" == "FAIL" |
| 217 | Should Be True ${evalresult} msg=set_vid out of range (${setvid})! |
| 218 | END |
| 219 | |
| 220 | Collect Tags Per ONU |
| 221 | [Documentation] This keyword collects the s- and c-tags per ONU. |
| 222 | ${onu_tags_dict}= Create Dictionary |
| 223 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 224 | ${src}= Set Variable ${hosts.src[${I}]} |
| 225 | ${onu_tags_dict}= Run Keyword If '${src['onu']}' in ${onu_tags_dict} Update ONU Tags Dict ${onu_tags_dict} |
| 226 | ... ${src['onu']} ${src['c_tag']} ${src['s_tag']} |
| 227 | ... ELSE Append To ONU Tags Dict ${onu_tags_dict} |
| 228 | ... ${src['onu']} ${src['c_tag']} ${src['s_tag']} |
| 229 | END |
| 230 | log ${onu_tags_dict} |
| 231 | [return] ${onu_tags_dict} |
| 232 | |
| 233 | Update ONU Tags Dict |
| 234 | [Documentation] This keyword update passed dictionary with the s- and c-tags for passed ONU. |
| 235 | [Arguments] ${onu_tags_dict} ${onu} ${c_tag} ${s_tag} |
| 236 | ${c_tag}= Convert To Integer ${c_tag} |
| 237 | ${s_tag}= Convert To Integer ${s_tag} |
| 238 | ${c_tags_list}= Get From Dictionary ${onu_tags_dict['${onu}']} c_tags |
| 239 | Append To List ${c_tags_list} ${c_tag} |
| 240 | ${s_tags_list}= Get From Dictionary ${onu_tags_dict['${onu}']} s_tags |
| 241 | Append To List ${s_tags_list} ${s_tag} |
| 242 | Set To Dictionary ${onu_tags_dict['${onu}']} c_tags ${c_tags_list} s_tags ${s_tags_list} |
| 243 | [return] ${onu_tags_dict} |
| 244 | |
| 245 | Append To ONU Tags Dict |
| 246 | [Documentation] This keyword append the s- and c-tags of passed ONU to passed dictionary . |
| 247 | [Arguments] ${onu_tags_dict} ${onu} ${c_tag} ${s_tag} |
| 248 | ${c_tag}= Convert To Integer ${c_tag} |
| 249 | ${s_tag}= Convert To Integer ${s_tag} |
| 250 | ${c_tags_list}= Create List ${c_tag} |
| 251 | ${s_tags_list}= Create List ${s_tag} |
| 252 | ${onu_dict}= Create Dictionary c_tags ${c_tags_list} s_tags ${s_tags_list} |
| 253 | Set To Dictionary ${onu_tags_dict} ${onu} ${onu_dict} |
| 254 | [return] ${onu_tags_dict} |