Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 1 | # Copyright 2017-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. |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 14 | # voltctl common functions |
| 15 | |
| 16 | *** Settings *** |
| 17 | Documentation Library for various utilities |
| 18 | Library SSHLibrary |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 19 | Library String |
| 20 | Library DateTime |
| 21 | Library Process |
| 22 | Library Collections |
| 23 | Library RequestsLibrary |
| 24 | Library OperatingSystem |
Matteo Scandolo | 142e627 | 2020-04-29 17:36:59 -0700 | [diff] [blame^] | 25 | Resource ./utils.robot |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 26 | |
| 27 | *** Keywords *** |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 28 | Test Empty Device List |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 29 | [Documentation] Verify that there are no devices in the system |
| 30 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 31 | Should Be Equal As Integers ${rc} 0 |
| 32 | ${jsondata}= To Json ${output} |
| 33 | Log ${jsondata} |
| 34 | ${length}= Get Length ${jsondata} |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 35 | Should Be Equal As Integers ${length} 0 |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 36 | |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 37 | Create Device |
Matteo Scandolo | 142e627 | 2020-04-29 17:36:59 -0700 | [diff] [blame^] | 38 | [Arguments] ${ip} ${port} ${type}=openolt |
You Wang | 2b55064 | 2019-10-07 14:39:48 -0700 | [diff] [blame] | 39 | [Documentation] Creates a device in VOLTHA |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 40 | #create/preprovision device |
Gilles Depatie | 675a206 | 2019-10-22 12:44:42 -0400 | [diff] [blame] | 41 | ${rc} ${device_id}= Run and Return Rc and Output |
Matteo Scandolo | 142e627 | 2020-04-29 17:36:59 -0700 | [diff] [blame^] | 42 | ... ${VOLTCTL_CONFIG}; voltctl device create -t ${type} -H ${ip}:${port} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 43 | Should Be Equal As Integers ${rc} 0 |
| 44 | [Return] ${device_id} |
| 45 | |
| 46 | Enable Device |
| 47 | [Arguments] ${device_id} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 48 | [Documentation] Enables a device in VOLTHA |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 49 | ${rc} ${output}= Run and Return Rc and Output |
| 50 | ... ${VOLTCTL_CONFIG}; voltctl device enable ${device_id} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 51 | Should Be Equal As Integers ${rc} 0 |
| 52 | |
Suchitra Vemuri | 6db8941 | 2019-11-14 14:52:54 -0800 | [diff] [blame] | 53 | Disable Device |
| 54 | [Arguments] ${device_id} |
Hardik Windlass | aaea340 | 2020-03-10 19:45:45 +0530 | [diff] [blame] | 55 | [Documentation] Disables a device in VOLTHA |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 56 | ${rc} ${output}= Run and Return Rc and Output |
| 57 | ... ${VOLTCTL_CONFIG}; voltctl device disable ${device_id} |
Suchitra Vemuri | 6db8941 | 2019-11-14 14:52:54 -0800 | [diff] [blame] | 58 | Should Be Equal As Integers ${rc} 0 |
| 59 | |
Hardik Windlass | aaea340 | 2020-03-10 19:45:45 +0530 | [diff] [blame] | 60 | Delete Device |
| 61 | [Arguments] ${device_id} |
| 62 | [Documentation] Deletes a device in VOLTHA |
| 63 | ${rc} ${output}= Run and Return Rc and Output |
| 64 | ... ${VOLTCTL_CONFIG}; voltctl device delete ${device_id} |
| 65 | Should Be Equal As Integers ${rc} 0 |
| 66 | |
Hema | df00368 | 2020-04-28 21:22:22 +0530 | [diff] [blame] | 67 | Reboot Device |
| 68 | [Arguments] ${device_id} |
| 69 | [Documentation] Reboot the OLT using voltctl command |
| 70 | ${rc} ${output}= Run and Return Rc and Output |
| 71 | ... ${VOLTCTL_CONFIG}; voltctl device reboot ${device_id} |
| 72 | Should Be Equal As Integers ${rc} 0 |
| 73 | |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 74 | Disable Devices In Voltha |
| 75 | [Documentation] Disables all the known devices in voltha |
| 76 | [Arguments] ${filter} |
| 77 | ${arg}= Set Variable ${EMPTY} |
| 78 | ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 79 | ${rc} ${devices}= Run and Return Rc and Output |
| 80 | ... ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 81 | Should Be Equal As Integers ${rc} 0 |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 82 | ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output |
| 83 | ... ${VOLTCTL_CONFIG}; voltctl device disable ${devices} |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 84 | Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0 |
| 85 | |
| 86 | Test Devices Disabled In Voltha |
| 87 | [Documentation] Tests to verify that all devices in VOLTHA are disabled |
| 88 | [Arguments] ${filter} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 89 | ${rc} ${count}= Run and Return Rc and Output |
| 90 | ... ${VOLTCTL_CONFIG}; voltctl device list --filter '${filter},AdminState!=DISABLED' -q | wc -l |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 91 | Should Be Equal As Integers ${rc} 0 |
| 92 | Should Be Equal As Integers ${count} 0 |
| 93 | |
| 94 | Delete Devices In Voltha |
| 95 | [Documentation] Disables all the known devices in voltha |
| 96 | [Arguments] ${filter} |
| 97 | ${arg}= Set Variable ${EMPTY} |
| 98 | ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 99 | ${rc} ${devices}= Run and Return Rc and Output |
| 100 | ... ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 101 | Should Be Equal As Integers ${rc} 0 |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 102 | ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output |
| 103 | ... ${VOLTCTL_CONFIG}; voltctl device delete ${devices} |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 104 | Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0 |
| 105 | |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 106 | Get Device Flows from Voltha |
| 107 | [Arguments] ${device_id} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 108 | [Documentation] Gets device flows from VOLTHA |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 109 | ${rc} ${output}= Run and Return Rc and Output |
| 110 | ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 111 | Should Be Equal As Integers ${rc} 0 |
| 112 | [Return] ${output} |
| 113 | |
| 114 | Get Logical Device Output from Voltha |
| 115 | [Arguments] ${device_id} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 116 | [Documentation] Gets logicaldevice flows and ports from VOLTHA |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 117 | ${rc1} ${flows}= Run and Return Rc and Output |
| 118 | ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${device_id} |
| 119 | ${rc2} ${ports}= Run and Return Rc and Output |
David K. Bainbridge | bd5ebd2 | 2020-02-04 10:01:18 -0800 | [diff] [blame] | 120 | ... ${VOLTCTL_CONFIG}; voltctl logicaldevice port list ${device_id} |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 121 | Log ${flows} |
| 122 | Log ${ports} |
| 123 | Should Be Equal As Integers ${rc1} 0 |
| 124 | Should Be Equal As Integers ${rc2} 0 |
| 125 | |
| 126 | Get Device Output from Voltha |
| 127 | [Arguments] ${device_id} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 128 | [Documentation] Gets device flows and ports from VOLTHA |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 129 | ${rc1} ${flows}= Run and Return Rc and Output |
| 130 | ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} |
| 131 | ${rc2} ${ports}= Run and Return Rc and Output |
David K. Bainbridge | bd5ebd2 | 2020-02-04 10:01:18 -0800 | [diff] [blame] | 132 | ... ${VOLTCTL_CONFIG}; voltctl device port list ${device_id} |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 133 | Log ${flows} |
| 134 | Log ${ports} |
| 135 | Should Be Equal As Integers ${rc1} 0 |
| 136 | Should Be Equal As Integers ${rc2} 0 |
| 137 | |
Suchitra Vemuri | 1a970a6 | 2019-11-26 12:52:16 -0800 | [diff] [blame] | 138 | Get Device List from Voltha |
| 139 | [Documentation] Gets Device List Output from Voltha |
| 140 | ${rc1} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list |
| 141 | Log ${devices} |
| 142 | Should Be Equal As Integers ${rc1} 0 |
| 143 | |
Matteo Scandolo | 142e627 | 2020-04-29 17:36:59 -0700 | [diff] [blame^] | 144 | Get Logical Device List from Voltha |
| 145 | [Documentation] Gets Logical Device List Output from Voltha (in json format) |
| 146 | ${rc1} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl logicaldevice list -o json |
| 147 | Log ${devices} |
| 148 | Should Be Equal As Integers ${rc1} 0 |
| 149 | Return From Keyword ${devices} |
| 150 | |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 151 | Validate Device |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 152 | [Documentation] |
ubuntu | 6b6e7d4 | 2020-03-02 12:35:42 -0800 | [diff] [blame] | 153 | ... Parses the output of "voltctl device list" and inspects a device ${id}, specified as either |
| 154 | ... the serial number or device ID. Arguments are matched for device states of: "admin_state", |
| 155 | ... "oper_status", and "connect_status" |
| 156 | [Arguments] ${admin_state} ${oper_status} ${connect_status} |
| 157 | ... ${id}=${EMPTY} ${onu_reason}=${EMPTY} ${onu}=False |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 158 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json |
| 159 | Should Be Equal As Integers ${rc} 0 |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 160 | ${jsondata}= To Json ${output} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 161 | ${length}= Get Length ${jsondata} |
ubuntu | 6b6e7d4 | 2020-03-02 12:35:42 -0800 | [diff] [blame] | 162 | ${matched}= Set Variable False |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 163 | FOR ${INDEX} IN RANGE 0 ${length} |
| 164 | ${value}= Get From List ${jsondata} ${INDEX} |
| 165 | ${astate}= Get From Dictionary ${value} adminstate |
| 166 | ${opstatus}= Get From Dictionary ${value} operstatus |
| 167 | ${cstatus}= Get From Dictionary ${value} connectstatus |
| 168 | ${sn}= Get From Dictionary ${value} serialnumber |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 169 | ${devId}= Get From Dictionary ${value} id |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 170 | ${mib_state}= Get From Dictionary ${value} reason |
ubuntu | 6b6e7d4 | 2020-03-02 12:35:42 -0800 | [diff] [blame] | 171 | ${matched}= Set Variable If '${sn}' == '${id}' or '${devId}' == '${id}' True False |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 172 | Exit For Loop If ${matched} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 173 | END |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 174 | Should Be True ${matched} No match found for ${id} to validate device |
Matteo Scandolo | 5e10b28 | 2019-11-25 10:54:32 -0700 | [diff] [blame] | 175 | Log ${value} |
ubuntu | 6b6e7d4 | 2020-03-02 12:35:42 -0800 | [diff] [blame] | 176 | Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state} |
Gilles Depatie | 675a206 | 2019-10-22 12:44:42 -0400 | [diff] [blame] | 177 | ... values=False |
ubuntu | 6b6e7d4 | 2020-03-02 12:35:42 -0800 | [diff] [blame] | 178 | Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 179 | ... values=False |
ubuntu | 6b6e7d4 | 2020-03-02 12:35:42 -0800 | [diff] [blame] | 180 | Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 181 | ... values=False |
| 182 | Run Keyword If '${onu}' == 'True' Should Be Equal '${mib_state}' '${onu_reason}' |
ubuntu | 6b6e7d4 | 2020-03-02 12:35:42 -0800 | [diff] [blame] | 183 | ... Device ${sn} mib_state incorrect (${mib_state}) values=False |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 184 | |
| 185 | Validate OLT Device |
ubuntu | 6b6e7d4 | 2020-03-02 12:35:42 -0800 | [diff] [blame] | 186 | [Arguments] ${admin_state} ${oper_status} ${connect_status} ${id}=${EMPTY} |
| 187 | [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified |
| 188 | ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states |
| 189 | Validate Device ${admin_state} ${oper_status} ${connect_status} ${id} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 190 | |
| 191 | Validate ONU Devices |
| 192 | [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial} |
Andy Bavier | f1f26ed | 2020-03-18 10:59:07 -0700 | [diff] [blame] | 193 | ... ${onu_reason}=omci-flows-pushed |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 194 | [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 195 | ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect |
| 196 | ... states including MIB state |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 197 | FOR ${serial_number} IN @{List_ONU_Serial} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 198 | Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number} |
Andy Bavier | f1f26ed | 2020-03-18 10:59:07 -0700 | [diff] [blame] | 199 | ... onu_reason=${onu_reason} onu=True |
Debasish | 28130d0 | 2020-03-16 11:05:26 +0000 | [diff] [blame] | 200 | END |
| 201 | |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 202 | Validate Device Port Types |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 203 | [Documentation] |
David K. Bainbridge | bd5ebd2 | 2020-02-04 10:01:18 -0800 | [diff] [blame] | 204 | ... Parses the output of voltctl device port list <device_id> and matches the port types listed |
Andy Bavier | 90eb1a1 | 2020-03-26 11:54:35 -0700 | [diff] [blame] | 205 | [Arguments] ${device_id} ${pon_type} ${ethernet_type} ${all_active}=True |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 206 | ${rc} ${output}= Run and Return Rc and Output |
David K. Bainbridge | bd5ebd2 | 2020-02-04 10:01:18 -0800 | [diff] [blame] | 207 | ... ${VOLTCTL_CONFIG}; voltctl device port list ${device_id} -o json |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 208 | Should Be Equal As Integers ${rc} 0 |
| 209 | ${jsondata}= To Json ${output} |
| 210 | Log ${jsondata} |
| 211 | ${length}= Get Length ${jsondata} |
| 212 | FOR ${INDEX} IN RANGE 0 ${length} |
| 213 | ${value}= Get From List ${jsondata} ${INDEX} |
| 214 | ${astate}= Get From Dictionary ${value} adminstate |
| 215 | ${opstatus}= Get From Dictionary ${value} operstatus |
| 216 | ${type}= Get From Dictionary ${value} type |
Hema | f64d34c | 2020-03-25 00:40:17 +0530 | [diff] [blame] | 217 | Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False |
Andy Bavier | 90eb1a1 | 2020-03-26 11:54:35 -0700 | [diff] [blame] | 218 | Run Keyword If ${all_active} Should Be Equal '${opstatus}' 'ACTIVE' |
| 219 | ... Device ${device_id} port oper_status != ACTIVE values=False |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 220 | Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}' |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 221 | ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 222 | END |
| 223 | |
| 224 | Validate OLT Port Types |
David K. Bainbridge | bd5ebd2 | 2020-02-04 10:01:18 -0800 | [diff] [blame] | 225 | [Documentation] Parses the output of voltctl device port list ${olt_device_id} and matches the port types listed |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 226 | [Arguments] ${pon_type} ${ethernet_type} |
| 227 | Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 228 | |
| 229 | Validate ONU Port Types |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 230 | [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type} |
David K. Bainbridge | bd5ebd2 | 2020-02-04 10:01:18 -0800 | [diff] [blame] | 231 | [Documentation] Parses the output of voltctl device port list for each ONU SN listed in ${List_ONU_Serial} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 232 | ... and matches the port types listed |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 233 | FOR ${serial_number} IN @{List_ONU_Serial} |
| 234 | ${onu_dev_id}= Get Device ID From SN ${serial_number} |
Andy Bavier | 90eb1a1 | 2020-03-26 11:54:35 -0700 | [diff] [blame] | 235 | # Only first UNI port is ACTIVE; the rest are in DISCOVERED operstatus |
| 236 | Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type} all_active=False |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 237 | END |
| 238 | |
| 239 | Validate Device Flows |
Hardik Windlass | a3d04b9 | 2020-02-17 15:06:05 +0000 | [diff] [blame] | 240 | [Arguments] ${device_id} ${flow_count}=${EMPTY} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 241 | [Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0 |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 242 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} -o json |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 243 | Should Be Equal As Integers ${rc} 0 |
| 244 | ${jsondata}= To Json ${output} |
| 245 | Log ${jsondata} |
| 246 | ${length}= Get Length ${jsondata} |
| 247 | Log 'Number of flows = ' ${length} |
Hardik Windlass | a3d04b9 | 2020-02-17 15:06:05 +0000 | [diff] [blame] | 248 | Run Keyword If '${flow_count}' == '${EMPTY}' Should Be True ${length} > 0 |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 249 | ... Number of flows for ${device_id} was 0 |
Hardik Windlass | a3d04b9 | 2020-02-17 15:06:05 +0000 | [diff] [blame] | 250 | ... ELSE Should Be True ${length} == ${flow_count} |
| 251 | ... Number of flows for ${device_id} was not ${flow_count} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 252 | |
| 253 | Validate OLT Flows |
Hardik Windlass | a3d04b9 | 2020-02-17 15:06:05 +0000 | [diff] [blame] | 254 | [Arguments] ${flow_count}=${EMPTY} |
| 255 | [Documentation] Parses the output of voltctl device flows ${olt_device_id} |
| 256 | ... and expects flow count == ${flow_count} |
| 257 | Validate Device Flows ${olt_device_id} ${flow_count} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 258 | |
| 259 | Validate ONU Flows |
Hardik Windlass | a3d04b9 | 2020-02-17 15:06:05 +0000 | [diff] [blame] | 260 | [Arguments] ${List_ONU_Serial} ${flow_count}=${EMPTY} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 261 | [Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial} |
Hardik Windlass | a3d04b9 | 2020-02-17 15:06:05 +0000 | [diff] [blame] | 262 | ... and expects flow count == ${flow_count} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 263 | FOR ${serial_number} IN @{List_ONU_Serial} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 264 | ${onu_dev_id}= Get Device ID From SN ${serial_number} |
Hardik Windlass | a3d04b9 | 2020-02-17 15:06:05 +0000 | [diff] [blame] | 265 | Validate Device Flows ${onu_dev_id} ${flow_count} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 266 | END |
| 267 | |
| 268 | Validate Logical Device |
| 269 | [Documentation] Validate Logical Device is listed |
| 270 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl logicaldevice list -o json |
| 271 | Should Be Equal As Integers ${rc} 0 |
| 272 | ${jsondata}= To Json ${output} |
| 273 | Log ${jsondata} |
| 274 | ${length}= Get Length ${jsondata} |
| 275 | FOR ${INDEX} IN RANGE 0 ${length} |
| 276 | ${value}= Get From List ${jsondata} ${INDEX} |
| 277 | ${devid}= Get From Dictionary ${value} id |
| 278 | ${rootdev}= Get From Dictionary ${value} rootdeviceid |
| 279 | ${sn}= Get From Dictionary ${value} serialnumber |
| 280 | Exit For Loop |
| 281 | END |
| 282 | Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False |
| 283 | Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN} |
| 284 | ... values=False |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 285 | [Return] ${devid} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 286 | |
| 287 | Validate Logical Device Ports |
| 288 | [Arguments] ${logical_device_id} |
| 289 | [Documentation] Validate Logical Device Ports are listed and are > 0 |
| 290 | ${rc} ${output}= Run and Return Rc and Output |
David K. Bainbridge | bd5ebd2 | 2020-02-04 10:01:18 -0800 | [diff] [blame] | 291 | ... ${VOLTCTL_CONFIG}; voltctl logicaldevice port list ${logical_device_id} -o json |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 292 | Should Be Equal As Integers ${rc} 0 |
| 293 | ${jsondata}= To Json ${output} |
| 294 | Log ${jsondata} |
| 295 | ${length}= Get Length ${jsondata} |
| 296 | Should Be True ${length} > 0 Number of ports for ${logical_device_id} was 0 |
| 297 | |
| 298 | Validate Logical Device Flows |
| 299 | [Arguments] ${logical_device_id} |
| 300 | [Documentation] Validate Logical Device Flows are listed and are > 0 |
| 301 | ${rc} ${output}= Run and Return Rc and Output |
| 302 | ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${logical_device_id} -o json |
| 303 | Should Be Equal As Integers ${rc} 0 |
| 304 | ${jsondata}= To Json ${output} |
| 305 | Log ${jsondata} |
| 306 | ${length}= Get Length ${jsondata} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 307 | Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0 |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 308 | |
| 309 | Retrieve Peer List From OLT |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 310 | [Arguments] ${olt_peer_list} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 311 | [Documentation] Retrieve the list of peer device id list from port list |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 312 | ${rc} ${output}= Run and Return Rc and Output |
David K. Bainbridge | bd5ebd2 | 2020-02-04 10:01:18 -0800 | [diff] [blame] | 313 | ... ${VOLTCTL_CONFIG}; voltctl device port list ${olt_device_id} -o json |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 314 | Should Be Equal As Integers ${rc} 0 |
| 315 | ${jsondata}= To Json ${output} |
| 316 | Log ${jsondata} |
| 317 | ${length}= Get Length ${jsondata} |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 318 | ${matched}= Set Variable False |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 319 | FOR ${INDEX} IN RANGE 0 ${length} |
| 320 | ${value}= Get From List ${jsondata} ${INDEX} |
| 321 | ${type}= Get From Dictionary ${value} type |
| 322 | ${peers}= Get From Dictionary ${value} peers |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 323 | ${matched}= Set Variable If '${type}' == 'PON_OLT' True False |
| 324 | Exit For Loop If ${matched} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 325 | END |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 326 | Should Be True ${matched} No PON port found for OLT ${olt_device_id} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 327 | ${length}= Get Length ${peers} |
| 328 | FOR ${INDEX} IN RANGE 0 ${length} |
| 329 | ${value}= Get From List ${peers} ${INDEX} |
| 330 | ${peer_id}= Get From Dictionary ${value} deviceid |
| 331 | Append To List ${olt_peer_list} ${peer_id} |
| 332 | END |
| 333 | |
| 334 | Validate OLT Peer Id List |
| 335 | [Arguments] ${olt_peer_id_list} |
| 336 | [Documentation] Match each entry in the ${olt_peer_id_list} against ONU device ids. |
| 337 | FOR ${peer_id} IN @{olt_peer_id_list} |
| 338 | Match OLT Peer Id ${peer_id} |
| 339 | END |
| 340 | |
| 341 | Match OLT Peer Id |
| 342 | [Arguments] ${olt_peer_id} |
| 343 | [Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 344 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 345 | Should Be Equal As Integers ${rc} 0 |
| 346 | ${jsondata}= To Json ${output} |
| 347 | Log ${jsondata} |
| 348 | ${length}= Get Length ${jsondata} |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 349 | ${matched}= Set Variable False |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 350 | FOR ${INDEX} IN RANGE 0 ${length} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 351 | ${value}= Get From List ${jsondata} ${INDEX} |
| 352 | ${devid}= Get From Dictionary ${value} id |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 353 | ${matched}= Set Variable If '${devid}' == '${olt_peer_id}' True False |
| 354 | Exit For Loop If ${matched} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 355 | END |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 356 | Should Be True ${matched} Peer id ${olt_peer_id} does not match any ONU device id |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 357 | |
| 358 | Validate ONU Peer Id |
| 359 | [Arguments] ${olt_device_id} ${List_ONU_Serial} |
| 360 | [Documentation] Match each ONU peer to that of the OLT device id |
| 361 | FOR ${onu_serial} IN @{List_ONU_Serial} |
| 362 | ${onu_dev_id}= Get Device ID From SN ${onu_serial} |
| 363 | Match ONU Peer Id ${onu_dev_id} |
| 364 | END |
| 365 | |
| 366 | Match ONU Peer Id |
| 367 | [Arguments] ${onu_dev_id} |
| 368 | [Documentation] Match an ONU peer to that of the OLT device id |
David K. Bainbridge | bd5ebd2 | 2020-02-04 10:01:18 -0800 | [diff] [blame] | 369 | ${rc} ${output}= Run and Return Rc and Output |
| 370 | ... ${VOLTCTL_CONFIG}; voltctl device port list ${onu_dev_id} -o json |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 371 | Should Be Equal As Integers ${rc} 0 |
| 372 | ${jsondata}= To Json ${output} |
| 373 | Log ${jsondata} |
| 374 | ${length}= Get Length ${jsondata} |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 375 | ${matched}= Set Variable False |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 376 | FOR ${INDEX} IN RANGE 0 ${length} |
| 377 | ${value}= Get From List ${jsondata} ${INDEX} |
| 378 | ${type}= Get From Dictionary ${value} type |
| 379 | ${peers}= Get From Dictionary ${value} peers |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 380 | ${matched}= Set Variable If '${type}' == 'PON_ONU' True False |
| 381 | Exit For Loop If ${matched} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 382 | END |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 383 | Should Be True ${matched} No PON port found for ONU ${onu_dev_id} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 384 | ${length}= Get Length ${peers} |
| 385 | FOR ${INDEX} IN RANGE 0 ${length} |
| 386 | ${value}= Get From List ${peers} ${INDEX} |
| 387 | ${peer_id}= Get From Dictionary ${value} deviceid |
| 388 | END |
| 389 | Should Be Equal '${peer_id}' '${olt_device_id}' |
| 390 | ... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 391 | |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 392 | Get Device ID From SN |
| 393 | [Arguments] ${serial_number} |
| 394 | [Documentation] Gets the device id by matching for ${serial_number} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 395 | ${rc} ${id}= Run and Return Rc and Output |
Andy Bavier | 8fca045 | 2019-12-16 15:30:11 -0700 | [diff] [blame] | 396 | ... ${VOLTCTL_CONFIG}; voltctl device list --filter=SerialNumber=${serial_number} --format='{{.Id}}' |
| 397 | Should Be Equal As Integers ${rc} 0 |
| 398 | Log ${id} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 399 | [Return] ${id} |
| 400 | |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 401 | Get Logical Device ID From SN |
| 402 | [Arguments] ${serial_number} |
| 403 | [Documentation] Gets the device id by matching for ${serial_number} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 404 | ${rc} ${id}= Run and Return Rc and Output |
Andy Bavier | 8fca045 | 2019-12-16 15:30:11 -0700 | [diff] [blame] | 405 | ... ${VOLTCTL_CONFIG}; voltctl logicaldevice list --filter=SerialNumber=${serial_number} --format='{{.Id}}' |
| 406 | Should Be Equal As Integers ${rc} 0 |
| 407 | Log ${id} |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 408 | [Return] ${id} |
| 409 | |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 410 | Build ONU SN List |
| 411 | [Arguments] ${serial_numbers} |
| 412 | [Documentation] Appends all ONU SNs to the ${serial_numbers} list |
| 413 | FOR ${INDEX} IN RANGE 0 ${num_onus} |
| 414 | Append To List ${serial_numbers} ${hosts.src[${INDEX}].onu} |
| 415 | END |
| 416 | |
| 417 | Get SN From Device ID |
| 418 | [Arguments] ${device_id} |
| 419 | [Documentation] Gets the device id by matching for ${device_id} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 420 | ${rc} ${sn}= Run and Return Rc and Output |
Andy Bavier | 8fca045 | 2019-12-16 15:30:11 -0700 | [diff] [blame] | 421 | ... ${VOLTCTL_CONFIG}; voltctl device list --filter=Id=${device_id} --format='{{.SerialNumber}}' |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 422 | Should Be Equal As Integers ${rc} 0 |
Andy Bavier | 8fca045 | 2019-12-16 15:30:11 -0700 | [diff] [blame] | 423 | Log ${sn} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 424 | [Return] ${sn} |
| 425 | |
Scott Baker | 60e570d | 2020-02-02 22:10:13 -0800 | [diff] [blame] | 426 | Get Parent ID From Device ID |
| 427 | [Arguments] ${device_id} |
| 428 | [Documentation] Gets the device id by matching for ${device_id} |
| 429 | ${rc} ${pid}= Run and Return Rc and Output |
| 430 | ... ${VOLTCTL_CONFIG}; voltctl device list --filter=Id=${device_id} --format='{{.ParentId}}' |
| 431 | Should Be Equal As Integers ${rc} 0 |
| 432 | Log ${pid} |
| 433 | [Return] ${pid} |
| 434 | |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 435 | Validate Device Removed |
| 436 | [Arguments] ${id} |
| 437 | [Documentation] Verifys that device, ${serial_number}, has been removed |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 438 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json |
Andy Bavier | 8fca045 | 2019-12-16 15:30:11 -0700 | [diff] [blame] | 439 | Should Be Equal As Integers ${rc} 0 |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 440 | ${jsondata}= To Json ${output} |
| 441 | Log ${jsondata} |
| 442 | ${length}= Get Length ${jsondata} |
| 443 | @{ids}= Create List |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 444 | FOR ${INDEX} IN RANGE 0 ${length} |
| 445 | ${value}= Get From List ${jsondata} ${INDEX} |
| 446 | ${device_id}= Get From Dictionary ${value} id |
| 447 | Append To List ${ids} ${device_id} |
| 448 | END |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 449 | List Should Not Contain Value ${ids} ${id} |
Suchitra Vemuri | cd2f64f | 2020-02-18 18:30:27 -0800 | [diff] [blame] | 450 | |
| 451 | Reboot ONU |
| 452 | [Arguments] ${onu_id} ${src} ${dst} |
| 453 | [Documentation] Using voltctl command reboot ONU and verify that ONU comes up to running state |
| 454 | ${rc} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device reboot ${onu_id} |
| 455 | Should Be Equal As Integers ${rc} 0 |
| 456 | Run Keyword and Ignore Error Wait Until Keyword Succeeds 60s 1s Validate Device |
| 457 | ... ENABLED DISCOVERED UNREACHABLE ${onu_id} onu=True |
Matteo Scandolo | 142e627 | 2020-04-29 17:36:59 -0700 | [diff] [blame^] | 458 | |
| 459 | Assert ONUs in Voltha |
| 460 | [Arguments] ${count} |
| 461 | [Documentation] Check that a certain number of devices reached the ACTIVE/ENABLE state |
| 462 | ${rc1} ${devices}= Run and Return Rc and Output |
| 463 | ... ${VOLTCTL_CONFIG}; voltctl device list | grep -v OLT | grep ACTIVE | wc -l |
| 464 | Should Be Equal As Integers ${rc1} 0 |
| 465 | Should Be Equal As Integers ${devices} ${count} |
| 466 | |
| 467 | Wait for ONUs in VOLTHA |
| 468 | [Arguments] ${count} |
| 469 | [Documentation] Waits until a certain number of devices reached the ACTIVE/ENABLE state |
| 470 | Wait Until Keyword Succeeds 10m 5s Assert ONUs In Voltha ${count} |
| 471 | |
| 472 | Count Logical Devices flows |
| 473 | [Documentation] Count the flows across logical devices in VOLTHA |
| 474 | [Arguments] ${targetFlows} |
| 475 | ${output}= Get Logical Device List From Voltha |
| 476 | ${logical_devices}= To Json ${output} |
| 477 | ${total_flows}= Set Variable 0 |
| 478 | FOR ${device} IN @{logical_devices} |
| 479 | ${rc} ${flows}= Run and Return Rc and Output |
| 480 | ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${device['id']} | grep -v ID | wc -l |
| 481 | Should Be Equal As Integers ${rc} 0 |
| 482 | ${total_flows}= Evaluate ${total_flows} + ${flows} |
| 483 | END |
| 484 | Should Be Equal As Integers ${targetFlows} ${total_flows} |
| 485 | |
| 486 | Wait for Logical Devices flows |
| 487 | [Documentation] Waits until the flows have been provisioned in the logical device |
| 488 | [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned} |
| 489 | ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned} |
| 490 | Log ${targetFlows} |
| 491 | # TODO extend Validate Logical Device Flows to check the correct number of flows |
| 492 | Wait Until Keyword Succeeds 10m 5s Count Logical Devices flows ${targetFlows} |
| 493 | |