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