Improve test tag string parsing
[csit.git] / resources / libraries / robot / honeycomb / bgp.robot
1 # Copyright (c) 2017 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.BGP.BGPKeywords
16 | Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
17
18 *** Keywords ***
19 | Configure BGP module
20 | | [Documentation] | Edit Honeycomb's configuration file for the BGP feature.\
21 | | ... | Honeycomb needs to be restarted for the changes to take effect.
22 | | ...
23 | | ... | *Arguments:*
24 | | ... | - node - information about a DUT node. Type: dictionary
25 | | ... | - ip_address - IP address to bind BGP listener to. Type: string
26 | | ... | - port - Port number to bind BGP listener to. Type: integer
27 | | ... | - as_number - Autonomous System (AS) ID number. Type: integer
28 | | ...
29 | | ... | *Example:*
30 | | ...
31 | | ... | \| Configure BGP module \| ${nodes['DUT1']} \| 192.168.0.1 \| ${179} \
32 | | ... | \| ${65000} \|
33 | | ...
34 | | [Arguments] | ${node} | ${ip_address} | ${port} | ${as_number}
35 | | Configure BGP base | ${node} | ${ip_address} | ${port} | ${as_number}
36
37 | No BGP peers should be configured
38 | | [Documentation] | Uses Honeycomb API to read BGP configuration and checks
39 | | ... | if there ary BGP peers conffigured.
40 | | ...
41 | | ... | *Arguments:*
42 | | ... | - node - information about a DUT node. Type: dictionary
43 | | ...
44 | | ... | *Example:*
45 | | ...
46 | | ... | \| No BGP peers should be configured \| ${nodes['DUT1']} \|
47 | | ...
48 | | [Arguments] | ${node}
49 | | ...
50 | | ${oper_data}= | Get Full BGP Configuration | ${node}
51 | | Should be Empty | ${oper_data['bgp-openconfig-extensions:bgp']}
52
53 | Honeycomb adds BGP peer
54 | | [Documentation] | Uses Honeycomb API to add a BGP peer.
55 | | ...
56 | | ... | *Arguments:*
57 | | ... | - node - Information about a DUT node. Type: dictionary
58 | | ... | - address - IP address of the peer. Type: string
59 | | ... | - data - Peer configuration data. Type: dictionary
60 | | ...
61 | | ... | *Example:*
62 | | ...
63 | | ... | \| Honeycomb adds BGP peer \| ${nodes['DUT1']} \| 192.168.0.1 \
64 | | ... | \| ${data} \|
65 | | ...
66 | | [Arguments] | ${node} | ${address} | ${data}
67 | | ...
68 | | Add BGP Peer | ${node} | ${address} | ${data}
69
70 | BGP Peer From Honeycomb Should be
71 | | [Documentation] | Uses Honeycomb API to verify BGP peer config data.
72 | | ...
73 | | ... | *Arguments:*
74 | | ... | - node - Information about a DUT node. Type: dictionary
75 | | ... | - address - IP address of the peer. Type: string
76 | | ... | - data - Peer configuration data. Type: dictionary
77 | | ...
78 | | ... | *Example:*
79 | | ...
80 | | ... | \| BGP Peer From Honeycomb Should be \
81 | | ... | \| ${nodes['DUT1']} \| 192.168.0.1 \| ${data} \|
82 | | ...
83 | | [Arguments] | ${node} | ${address} | ${data}
84 | | ...
85 | | ${oper_data}= | Get BGP Peer | ${node} | ${address}
86 | | Compare Data Structures | ${oper_data} | ${data}
87
88 | Peer Operational Data From Honeycomb Should be
89 | | [Documentation] | Uses Honeycomb API to verify BGP peer operational data.
90 | | ...
91 | | ... | *Arguments:*
92 | | ... | - node - Information about a DUT node. Type: dictionary
93 | | ... | - address - IP address of the peer. Type: string
94 | | ... | - data - Peer configuration data. Type: dictionary
95 | | ...
96 | | ... | *Example:*
97 | | ...
98 | | ... | \| BGP Peer From Honeycomb Should be \
99 | | ... | \| ${nodes['DUT1']} \| 192.168.0.1 \| ${data} \|
100 | | ...
101 | | [Arguments] | ${node} | ${address}
102 | | ...
103 | | ${oper_data}= | Get BGP Peer | ${node} | ${address} | operational
104 | | Should be Equal | ${oper_data['peer'][0]['peer-id']} | bgp://${address}
105
106 | Honeycomb removes BGP peer
107 | | [Documentation] | Uses Honeycomb API to add a BGP peer.
108 | | ...
109 | | ... | *Arguments:*
110 | | ... | - node - Information about a DUT node. Type: dictionary
111 | | ... | - address - IP address of the peer. Type: string
112 | | ...
113 | | ... | *Example:*
114 | | ...
115 | | ... | \| Honeycomb adds BGP peer \| ${nodes['DUT1']} \| 192.168.0.1 \|
116 | | ...
117 | | [Arguments] | ${node} | ${address}
118 | | ...
119 | | Remove BGP Peer | ${node} | ${address}
120
121 | Honeycomb configures BGP route
122 | | [Documentation] | Uses Honeycomb API to add a BGP route\
123 | | ... | to the specified peer.
124 | | ...
125 | | ... | *Arguments:*
126 | | ... | - node - Information about a DUT node. Type: dictionary
127 | | ... | - peer_address - IP address of the peer. Type: string
128 | | ... | - data - Peer configuration data. Type: dictionary
129 | | ... | - route_address - IP address of the route. Type: string
130 | | ... | - route_index - Numeric index of the route under the peer.\
131 | | ... | Type: integer
132 | | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type: string
133 | | ...
134 | | ... | *Example:*
135 | | ...
136 | | ... | \| Honeycomb adds BGP peer \| ${nodes['DUT1']} \| 192.168.0.1 \
137 | | ... | \| ${data} \| 192.168.0.2 \| ${0} \| ipv4 \|
138 | | ...
139 | | [Arguments] | ${node} | ${peer_address} | ${data}
140 | | ... | ${route_address} | ${route_index} | ${ip_version}
141 | | ...
142 | | Configure BGP Route | ${node} | ${peer_address} | ${data}
143 | | ... | ${route_address} | ${route_index} | ${ip_version}
144
145 | BGP Route From Honeycomb Should be
146 | | [Documentation] | Uses Honeycomb API to verify BGP route operational data.
147 | | ...
148 | | ... | *Arguments:*
149 | | ... | - node - Information about a DUT node. Type: dictionary
150 | | ... | - peer_address - IP address of the peer. Type: string
151 | | ... | - data - Peer configuration data. Type: dictionary
152 | | ... | - route_address - IP address of the route. Type: string
153 | | ... | - route_index - Numeric index of the route under the peer.\
154 | | ... | Type: integer
155 | | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type: string
156 | | ...
157 | | ... | *Example:*
158 | | ...
159 | | ... | \| BGP Peers From Honeycomb Should Include \
160 | | ... | \| ${nodes['DUT1']} \| ${data} \|
161 | | ...
162 | | [Arguments] | ${node} | ${peer_address} | ${data}
163 | | ... | ${route_address} | ${route_index} | ${ip_version}
164 | | ...
165 | | ${oper_data}= | Get BGP Route | ${node} | ${peer_address}
166 | | ... | ${route_address} | ${route_index} | ${ip_version}
167 | | Compare Data Structures | ${oper_data} | ${data}
168
169 | Honeycomb removes BGP route
170 | | [Documentation] | Uses Honeycomb API to remove a BGP route.
171 | | ...
172 | | ... | *Arguments:*
173 | | ... | - node - Information about a DUT node. Type: dictionary
174 | | ... | - peer_address - IP address of the peer. Type: string
175 | | ... | - route_address - IP address of the route. Type: string
176 | | ... | - route_index - Numeric index of the route under the peer.\
177 | | ... | Type: integer
178 | | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type: string
179 | | ...
180 | | ... | *Example:*
181 | | ...
182 | | ... | \| Honeycomb removes BGP route \| ${nodes['DUT1']} \| 192.168.0.1 \
183 | | ... | \| 192.168.0.2 \| ${0} \| ipv4 \|
184 | | ...
185 | | [Arguments] | ${node} | ${peer_address} | ${route_address}
186 | | ... | ${route_index} | ${ip_version}
187 | | ...
188 | | Remove BGP Route | ${node} | ${peer_address} | ${route_address}
189 | | ... | ${route_index} | ${ip_version}
190
191 | No BGP routes should be configured
192 | | [Documentation] | Uses Honeycomb API to verify that no BGP routes\
193 | | ... | are configured under the specified peer.
194 | | ...
195 | | ... | *Arguments:*
196 | | ... | - node - Information about a DUT node. Type: dictionary
197 | | ... | - peer_address - IP address of the peer. Type: string
198 | | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type: string
199 | | ...
200 | | ... | *Example:*
201 | | ...
202 | | ... | \| No BGP routes should be configured \| ${nodes['DUT1']} \
203 | | ... | \| 192.168.0.1 \| ipv4 \|
204 | | ...
205 | | [Arguments] | ${node} | ${peer_address} | ${ip_version}
206 | | ...
207 | | ${oper_data}= | Get All Peer Routes
208 | | ... | ${node} | ${peer_address} | ${ip_version}
209 | | Should be Empty | ${oper_data['bgp-inet:${ip_version}-routes']}
210
211 | No BGP routes should exist
212 | | [Documentation] | Uses Honeycomb API to verify that no BGP routes\
213 | | ... | exist under the specified peer.
214 | | ...
215 | | ... | *Arguments:*
216 | | ... | - node - Information about a DUT node. Type: dictionary
217 | | ... | - peer_address - IP address of the peer. Type: string
218 | | ... | - ip_version - IP protocol version, ipv4 or ipv6. Type: string
219 | | ...
220 | | ... | *Example:*
221 | | ...
222 | | ... | \| No BGP routes should be configured \| ${nodes['DUT1']} \
223 | | ... | \| 192.168.0.1 \| ipv4 \|
224 | | ...
225 | | [Arguments] | ${node} | ${peer_address} | ${ip_version}
226 | | ...
227 | | Run keyword and expect error | *Status code: 404*
228 | | ... | Get All Peer Routes
229 | | ... | ${node} | ${peer_address} | ${ip_version}
230
231 | BGP Loc-RIB table should include
232 | | [Documentation] | Uses Honeycomb API to retrieve local BGP RIB table\
233 | | ... | And verifies that it contains the specified entry.
234 | | ...
235 | | ... | *Arguments:*
236 | | ... | - node - Information about a DUT node. Type: dictionary
237 | | ... | - data - RIB that should be present in operational data.\
238 | | ... | Type: dictionary
239 | | ...
240 | | ... | *Example:*
241 | | ...
242 | | ... | \| BGP Loc-RIB table should include \| ${nodes['DUT1']} \| ${data} \|
243 | | ...
244 | | [Arguments] | ${node} | ${data}
245 | | ...
246 | | ${oper_data}= | Get BGP Local RIB | ${node}
247 | | ${oper_data}= | Set Variable | ${oper_data['loc-rib']['tables']}
248 | | ${data}= | Set Variable | ${data['loc-rib']['tables']}
249 | | Compare RIB Tables | ${oper_data} | ${data}
250
251 | Receive BGP OPEN message
252 | | [Documentation] | Open a TCP listener on BGP port(179) and listen\
253 | | ... | for BGP OPEN message. Verify ID and holdtime fields.
254 | | ...
255 | | ... | *Arguments:*
256 | | ... | - tg_node - Information about the TG node. Type: dictionary
257 | | ... | - rx_ip - IP address to listen on. Type: string
258 | | ... | - src_ip - IP address of the BGP speaker. Also acts as BGP peer ID.\
259 | | ... | Type: string
260 | | ... | - holdtime - Expected value of HOLD_TIME field in received message.\
261 | | ... | Type: integer
262 | | ...
263 | | ... | *Example:*
264 | | ...
265 | | ... | \| Receive BGP OPEN message \| ${node['TG']} \
266 | | ... | \| 192.168.0.1 \| 192.168.0.2 \| ${0}
267 | | ...
268 | | [Arguments] | ${tg_node} | ${rx_ip} | ${src_ip} | ${port} | ${as_number}
269 | | ... | ${holdtime}
270 | | ...
271 | | ${args}= | Catenate | --rx_ip | ${rx_ip}
272 | | ...                 | --src_ip | ${src_ip}
273 | | ...                 | --rx_port | ${port}
274 | | ...                 | --as_number | ${as_number}
275 | | ...                 | --holdtime | ${holdtime}
276 | | Run Traffic Script On Node | honeycomb/bgp_open.py
277 | | ... | ${tg_node} | ${args}