532b5157d85f88ca842b15894cd54b7d63fd58e4
[csit.git] / resources / libraries / robot / honeycomb / port_mirroring.robot
1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
16 | ...     | WITH NAME | InterfaceAPI
17 | Library | resources.libraries.python.telemetry.SPAN
18 | Library  | resources.libraries.python.InterfaceUtil
19 | Library  | resources.libraries.python.IPv4Util
20 | Library  | resources.libraries.python.IPv4Setup
21 | Library  | resources.libraries.python.Trace
22
23 *** Keywords ***
24 | Honeycomb Configures SPAN on interface
25 | | [Documentation] | Uses Honeycomb API to configure SPAN on the specified\
26 | | ... | interface, mirroring one or more interfaces.
27 | | ...
28 | | ... | *Arguments:*
29 | | ... | - node - information about a DUT node. Type: dictionary
30 | | ... | - dst_interface - Mirroring destination interface. Type: string
31 | | ... | - src_interfaces - Mirroring source interfaces. Type: list \
32 | | ... | of dictionaries
33 | | ...
34 | | ... | *Example:*
35 | | ...
36 | | ... | \| Honeycomb Configures SPAN on interface \| ${nodes['DUT1']} \
37 | | ... | \| GigabitEthernet0/8/0 \| [{'iface-ref': 'GigabitEthernet0/10/0', \
38 | | ... | \| 'state': 'transmit'}, \
39 | | ... | \| {'iface-ref': 'local0', 'state': 'both'}] \|
40 | | ...
41 | | [Arguments] | ${node} | ${dst_interface} | @{src_interfaces}
42 | | InterfaceAPI.Configure interface SPAN
43 | | ... | ${node} | ${dst_interface} | ${src_interfaces}
44
45 | Interface SPAN Operational Data From Honeycomb Should Be
46 | | [Documentation] | Retrieves interface operational data and verifies that\
47 | | ... | SPAN mirroring is configured with the provided interfaces.
48 | | ...
49 | | ... | *Arguments:*
50 | | ... | - node - information about a DUT node. Type: dictionary
51 | | ... | - dst_interface - Mirroring destination interface. Type: string
52 | | ... | - src_interfaces - Mirroring source interfaces. Type: Argument list -\
53 | | ... | any number of strings
54 | | ...
55 | | ... | *Example:*
56 | | ...
57 | | ... | \| Interface SPAN Operational Data From Honeycomb Should Be \
58 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| GigabitEthernet0/9/0 \|
59 | | ...
60 | | [Arguments] | ${node} | ${dst_interface} | @{src_interfaces}
61 | | ${data}= | InterfaceAPI.Get interface oper data | ${node} | ${dst_interface}
62 | | ${data}= | Set Variable
63 | | ... | ${data['v3po:span']['mirrored-interfaces']['mirrored-interface']}
64 | | Sort list | ${data}
65 | | Sort list | ${src_interfaces}
66 | | Lists should be equal | ${data} | ${src_interfaces}
67
68 | Interface SPAN Operational Data From Honeycomb Should Be empty
69 | | [Documentation] | Checks whether SPAN configuration from Honeycomb is empty.
70 | | ...
71 | | ... | *Arguments:*
72 | | ... | - node - Information about a DUT node. Type: dictionary
73 | | ... | - dst_interface - Mirroring destination interface. Type: string
74 | | ...
75 | | ... | *Example:*
76 | | ...
77 | | ... | \| Interface SPAN Operational Data From Honeycomb Should Be empty \
78 | | ... | \| ${node} \| GigabitEthernetO/8/0 \|
79 | | ...
80 | | [Arguments] | ${node} | ${dst_interface}
81 | | ${data}= | Get interface oper data | ${node} | ${dst_interface}
82 | | Variable should not exist
83 | | ... | ${data['v3po:span']['mirrored-interfaces']['mirrored-interface']}
84
85 | Interface SPAN Operational Data From VAT Should Be
86 | | [Documentation] | Retrieves SPAN configuration from VAT dump and verifies\
87 | | ... | that SPAN mirroring is configured with the provided interfaces.
88 | | ...
89 | | ... | *Arguments:*
90 | | ... | - node - information about a DUT node. Type: dictionary
91 | | ... | - dst_interface - Mirroring destination interface. Type: string
92 | | ... | - src_interfaces - Mirroring source interfaces. Type: Argument list -\
93 | | ... | any number of strings
94 | | ...
95 | | ... | *Example:*
96 | | ...
97 | | ... | \| Interface SPAN Operational Data From VAT Should Be \
98 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| GigabitEthernet0/9/0 \|
99 | | ...
100 | | [Arguments] | ${node} | ${dst_interface} | @{src_interfaces}
101 | | ${data}= | VPP get SPAN configuration by interface
102 | | ... | ${node} | ${dst_interface} | name
103 | | Sort list | ${data}
104 | | Sort list | ${src_interfaces}
105 | | Lists should be equal | ${data} | ${src_interfaces}
106
107 | Honeycomb removes interface SPAN configuration
108 | | [Documentation] | Uses Honeycomb API to remove SPAN configuration\
109 | | ... | from the specified interface.
110 | | ...
111 | | ... | *Arguments:*
112 | | ... | - node - information about a DUT node. Type: dictionary
113 | | ... | - dst_interface - Mirroring destination interface. Type: string
114 | | ...
115 | | ... | *Example:*
116 | | ...
117 | | ... | \| Honeycomb removes interface SPAN configuration \
118 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \|
119 | | ...
120 | | [Arguments] | ${node} | ${dst_interface}
121 | | InterfaceAPI.Configure interface SPAN | ${node} | ${dst_interface}
122
123 | Interface SPAN Operational Data from Honeycomb should not exist
124 | | [Documentation] | Retrieves interface operational data and verifies that\
125 | | ... | SPAN mirroring is not configured.
126 | | ...
127 | | ... | *Arguments:*
128 | | ... | - node - information about a DUT node. Type: dictionary
129 | | ... | - dst_interface - Mirroring destination interface. Type: string
130 | | ...
131 | | ... | *Example:*
132 | | ...
133 | | ... | \|
134 | | [Arguments] | ${node} | ${dst_interface}
135 | | ${data}= | InterfaceAPI.Get interface oper data | ${node} | ${dst_interface}
136 | | Run keyword and expect error | *KeyError* | Set Variable
137 | | ... | ${data['span']['mirrored-interfaces']['mirrored-interface']}
138
139 | SPAN Operational Data from VAT should not exist
140 | | [Documentation] | Attmepts to retrieve SPAN Operational Data from VAT dump,\
141 | | ... | and expects to fail with no data retrieved.
142 | | ...
143 | | ... | *Arguments:*
144 | | ... | - node - information about a DUT node. Type: dictionary
145 | | ...
146 | | ... | *Example:*
147 | | ...
148 | | ... | \| SPAN Operational Data from VAT should not exist \| ${nodes['DUT1']} \|
149 | | [Arguments] | ${node}
150 | | Run keyword and expect error | ValueError: No JSON object could be decoded
151 | | ... | VPP get SPAN configuration by interface | ${node} | local0
152
153 | Honeycomb Configures SPAN on sub-interface
154 | | [Documentation] | Uses Honeycomb API to configure SPAN on the specified\
155 | | ... | sub-interface, mirroring one or more interfaces.
156 | | ...
157 | | ... | *Arguments:*
158 | | ... | - node - information about a DUT node. Type: dictionary
159 | | ... | - dst_interface - Mirroring destination super-interface. Type: string
160 | | ... | - index - Index of mirroring destination sub-interface. Type: integer
161 | | ... | - src_interfaces - Mirroring source interfaces. Type: list \
162 | | ... | of dictionaries
163 | | ...
164 | | ... | *Example:*
165 | | ...
166 | | ... | \| Honeycomb Configures SPAN on sub-interface \| ${nodes['DUT1']} \
167 | | ... | \| GigabitEthernet0/8/0 \| ${1} \
168 | | ... | \|[{'iface-ref': 'GigabitEthernet0/10/0', 'state': 'transmit'}, \
169 | | ... | \| {'iface-ref': 'local0', 'state': 'both'}] \|
170 | | ...
171 | | [Arguments] | ${node} | ${dst_interface} | ${index} | @{src_interfaces}
172 | | InterfaceAPI.Configure sub interface SPAN
173 | | ... | ${node} | ${dst_interface} | ${index} | ${src_interfaces}
174
175 | Sub-Interface SPAN Operational Data from Honeycomb should be
176 | | [Documentation] | Retrieves sub-interface operational data and verifies\
177 | | ... | that SPAN mirroring is configured with the provided interfaces.
178 | | ...
179 | | ... | *Arguments:*
180 | | ... | - node - information about a DUT node. Type: dictionary
181 | | ... | - dst_interface - Mirroring destination super-interface. Type: string
182 | | ... | - index - Index of mirroring destination sub-interface. Type: integer
183 | | ... | - src_interfaces - Mirroring source interfaces. Type: Argument list -\
184 | | ... | any number of strings
185 | | ...
186 | | ... | *Example:*
187 | | ...
188 | | ... | \| Sub-Interface SPAN Operational Data from Honeycomb should be \
189 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${1} \
190 | | ... | \| GigabitEthernet0/9/0 \|
191 | | ...
192 | | [Arguments] | ${node} | ${dst_interface} | ${index} | @{src_interfaces}
193 | | ${data}= | InterfaceAPI.Get sub interface oper data
194 | | ... | ${node} | ${dst_interface} | ${index}
195 | | ${data}= | Set Variable
196 | | ... | ${data['subinterface-span:span-state']['mirrored-interfaces']['mirrored-interface']}
197 | | Sort list | ${data}
198 | | Sort list | ${src_interfaces}
199 | | Lists should be equal | ${data} | ${src_interfaces}
200
201 | Sub-Interface SPAN Operational Data from Honeycomb should be empty
202 | | [Documentation] | Checks whether SPAN Operational Data from Honeycomb is empty.
203 | | ...
204 | | ... | *Arguments:*
205 | | ... | - node - Information about a DUT node. Type: dictionary
206 | | ... | - dst_interface - Mirroring destination super-interface. Type: string
207 | | ... | - index - Index of mirroring destination sub-interface. Type: integer
208 | | ...
209 | | ... | *Example:*
210 | | ...
211 | | ... | \| Interface SPAN Operational Data from Honeycomb should be empty \
212 | | ... | \| ${node} \| GigabitEthernetO/8/0 \| ${1} \|
213 | | ...
214 | | [Arguments] | ${node} | ${dst_interface} | ${index}
215 | | ${data}= | Get sub interface oper data
216 | | ... | ${node} | ${dst_interface} | ${index}
217 | | Variable should not exist
218 | | ... | ${data['subinterface-span:span-state']['mirrored-interfaces']['mirrored-interface']}
219
220 | Honeycomb removes sub-interface SPAN configuration
221 | | [Documentation] | Uses Honeycomb API to remove SPAN Operational Data\
222 | | ... | from the specified sub-interface.
223 | | ...
224 | | ... | *Arguments:*
225 | | ... | - node - information about a DUT node. Type: dictionary
226 | | ... | - dst_interface - Mirroring destination super-interface. Type: string
227 | | ... | - index - Index of mirroring destination sub-interface. Type: integer
228 | | ...
229 | | ... | *Example:*
230 | | ...
231 | | ... | \| Honeycomb removes sub-interface SPAN configuration \
232 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${1} \|
233 | | ...
234 | | [Arguments] | ${node} | ${dst_interface} | ${index}
235 | | InterfaceAPI.Configure sub interface SPAN
236 | | ... | ${node} | ${dst_interface} | ${index}
237
238 | Sub-Interface SPAN Operational Data from Honeycomb should not exist
239 | | [Documentation] | Retrieves sub-interface operational data and verifies
240 | | ... | that SPAN mirroring is not configured.
241 | | ...
242 | | ... | *Arguments:*
243 | | ... | - node - information about a DUT node. Type: dictionary
244 | | ... | - dst_interface - Mirroring destination super-interface. Type: string
245 | | ... | - index - Index of mirroring destination sub-interface. Type: integer
246 | | ...
247 | | ... | *Example:*
248 | | ...
249 | | ... | \| Sub-Interface SPAN Operational Data from Honeycomb should not exist \
250 | | ... | \| ${nodes['DUT1']} \| GigabitEthernet0/8/0 \| ${1} \|
251 | | ....
252 | | [Arguments] | ${node} | ${dst_interface} | ${index}
253 | | ${data}= | InterfaceAPI.Get sub interface oper data
254 | | ... | ${node} | ${dst_interface} | ${index}
255 | | Run keyword and expect error | *KeyError* | Set Variable
256 | | ... | ${data['subinterface-span:span-state']['mirrored-interfaces']['mirrored-interface']}