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