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