HC Test: SPAN Port Mirroring Suite
[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 configuration 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 configuration 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 configuration 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 configuration 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 configuration 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 configuration 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 confirugation\
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 configuration 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 configuration from VAT should not exist
140 | | [Documentation] | Attmepts to retrieve SPAN configuration 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 configuration 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