52513f081358c7b03ce581b627b9bbeebf10cdeb
[csit.git] / resources / test_data / honeycomb / bgp.py
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 from copy import deepcopy
15
16 """Test variables for BGP test suite."""
17
18 # Internal BGP peers for CRUD tests
19 address_internal = "192.168.0.2"
20 address_internal2 = "192.168.0.3"
21 holdtime_internal = 60
22 peer_internal = {
23     "bgp-openconfig-extensions:neighbor": [{
24         "neighbor-address": address_internal,
25         "config": {
26             "peer-type": "INTERNAL"
27         },
28         "timers": {
29             "config": {
30                 "connect-retry": 3,
31                 "hold-time": holdtime_internal
32             }
33         },
34         "transport": {
35             "config": {
36                 "remote-port": 179,
37                 "passive-mode": False
38             }
39         },
40         "afi-safis": {
41             "afi-safi": [{
42                 "afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST"
43                 }]
44             }
45         }]
46     }
47
48 peer_internal_update = {
49     "bgp-openconfig-extensions:neighbor": [{
50         "neighbor-address": address_internal,
51         "config": {
52             "peer-type": "INTERNAL"
53         },
54         "timers": {
55             "config": {
56                 "connect-retry": 5,
57                 "hold-time": holdtime_internal*2
58             }
59         },
60         "transport": {
61             "config": {
62                 "remote-port": 180,
63                 "passive-mode": True
64             }
65         },
66         "afi-safis": {
67             "afi-safi": [{
68                 "afi-safi-name": "openconfig-bgp-types:IPV6-UNICAST"
69                 }]
70             }
71         }]
72     }
73
74 peer_internal2 = deepcopy(peer_internal)
75 peer_internal2["bgp-openconfig-extensions:neighbor"][0]["neighbor-address"] = \
76     address_internal2
77
78 # Application BGP peer for CRUD test
79 address_application = "192.168.0.4"
80 peer_application = {
81     "bgp-openconfig-extensions:neighbor": [{
82         "neighbor-address": address_application,
83         "config": {
84             "peer-group": "application-peers"
85         },
86         "afi-safis": {
87             "afi-safi": [
88                 {
89                     "afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST"
90                 },
91                 {
92                     "afi-safi-name":
93                         "openconfig-bgp-types:IPV4-LABELLED-UNICAST"
94                 }]
95             }
96         }]
97     }
98
99 # IPv4 route for CRUD test
100 route_address_ipv4 = "192.168.0.5/32"
101 route_id_ipv4 = 0
102 route_data_ipv4 = {
103     "bgp-inet:ipv4-route": [{
104         "route-key": route_address_ipv4,
105         "path-id": route_id_ipv4,
106         "prefix": route_address_ipv4,
107         "attributes": {
108             "as-path": {},
109             "origin": {
110                 "value": "igp"
111             },
112             "local-pref": {
113                 "pref": 100
114             },
115             "ipv4-next-hop": {
116                 "global": "192.168.1.1"
117             }
118         }
119     }]
120 }
121
122 # IPv4 route for testing Update operation
123 route_data_ipv4_update = {
124     "bgp-inet:ipv4-route": [{
125         "route-key": route_address_ipv4,
126         "path-id": route_id_ipv4,
127         "prefix": route_address_ipv4,
128         "attributes": {
129             "as-path": {},
130             "origin": {
131                 "value": "egp"
132             },
133             "local-pref": {
134                 "pref": 200
135             },
136             "ipv4-next-hop": {
137                 "global": "192.168.1.2"
138             }
139         }
140     }]
141 }
142
143 # IPv4 route for testing multiple routes
144 route_address_ipv4_2 = "192.168.0.6/32"
145 route_id_ipv4_2 = 1
146 route_data_ipv4_2 = {
147     "bgp-inet:ipv4-route": [{
148         "route-key": route_address_ipv4_2,
149         "path-id": route_id_ipv4_2,
150         "prefix": route_address_ipv4_2,
151         "attributes": {
152             "as-path": {},
153             "origin": {
154                 "value": "igp"
155             },
156             "local-pref": {
157                 "pref": 100
158             },
159             "ipv4-next-hop": {
160                 "global": "192.168.1.2"
161             }
162         }
163     }]
164 }
165
166 # IPv6 route for CRUD test
167 route_address_ipv6 = "3ffe:62::1/64"
168 route_id_ipv6 = 0
169 route_data_ipv6 = {
170     "bgp-inet:ipv6-route": [{
171         "route-key": route_address_ipv6,
172         "path-id": route_id_ipv6,
173         "prefix": route_address_ipv6,
174         "attributes": {
175             "as-path": {},
176             "origin": {
177                 "value": "igp"
178             },
179             "local-pref": {
180                 "pref": 100
181             },
182             "ipv6-next-hop": {
183                 "global": "3ffe:63::1"
184             }
185         }
186     }]
187 }
188
189 # IPv4 route operational data in routing table
190 table1_oper = {
191     "destination-prefix": route_address_ipv4,
192     "next-hop": "192.168.1.1",
193     "vpp-ipv4-unicast-routing:vpp-ipv4-route": {}
194 }
195
196 # Peer configurations for traffic test
197 dut1_peer = {
198     "bgp-openconfig-extensions:neighbor": [{
199         "neighbor-address": "192.168.1.1",
200         "config": {
201             "peer-type": "INTERNAL"
202         },
203         "timers": {
204             "config": {
205                 "connect-retry": 3,
206                 "hold-time": 60
207             }
208         },
209         "transport": {
210             "config": {
211                 "remote-port": 179,
212                 "passive-mode": False
213             }
214         },
215         "afi-safis": {
216             "afi-safi": [
217                 {
218                     "afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST"
219                 },
220                 {
221                     "afi-safi-name": "openconfig-bgp-types:IPV6-UNICAST"
222                 },
223                 {
224                     "afi-safi-name": "LINKSTATE"
225                 }
226             ]
227         }
228     }]
229 }
230
231 dut2_peer = {
232     "bgp-openconfig-extensions:neighbor": [{
233         "neighbor-address": "192.168.1.2",
234         "config": {
235             "peer-type": "INTERNAL"
236         },
237         "timers": {
238             "config": {
239                 "connect-retry": 3,
240                 "hold-time": 60
241             }
242         },
243         "transport": {
244             "config": {
245                 "remote-port": 179,
246                 "passive-mode": True
247             }
248         },
249         "afi-safis": {
250             "afi-safi": [
251                 {
252                     "afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST"
253                 },
254                 {
255                     "afi-safi-name": "openconfig-bgp-types:IPV6-UNICAST"
256                 },
257                 {
258                     "afi-safi-name": "LINKSTATE"
259                 }
260             ]
261         }
262     }]
263 }
264
265 # IPv4 route for traffic test
266 dut1_route_address = "192.168.0.5/32"
267 dut1_route_id = 0
268 dut1_route = {
269     "bgp-inet:ipv4-route": [{
270         "route-key": dut1_route_address,
271         "path-id": dut1_route_id,
272         "prefix": dut1_route_address,
273         "attributes": {
274             "as-path": {},
275             "origin": {
276                 "value": "igp"
277             },
278             "local-pref": {
279                 "pref": 100
280             },
281             "ipv4-next-hop": {
282                 "global": "192.168.1.3"
283             }
284         }
285     }]
286 }
287
288 # IPv4 route in peer operational data
289 rib_operational = {
290     "loc-rib": {"tables": [
291         {
292             "afi": "bgp-types:ipv4-address-family",
293             "safi": "bgp-types:unicast-subsequent-address-family",
294             "bgp-inet:ipv4-routes": {
295                 "ipv4-route": dut1_route["bgp-inet:ipv4-route"]
296             }
297         }
298     ]}
299 }
300
301 route_operational = {
302     "next-hop": {"next-hop-address": "192.168.1.3"},
303     "vpp-ipv4-unicast-routing:vpp-ipv4-route": {},
304     "destination-prefix": dut1_route_address
305 }
306
307 # IPv6 route for traffic test
308 dut1_route_ip6_prefix = "3ffe:62::/64"
309 dut1_route_ip6_id = 0
310 dut1_route_ip6 = {
311     "bgp-inet:ipv6-route": [{
312         "route-key": dut1_route_ip6_prefix,
313         "path-id": dut1_route_ip6_id,
314         "prefix": dut1_route_ip6_prefix,
315         "attributes": {
316             "as-path": {},
317             "origin": {
318                 "value": "igp"
319             },
320             "local-pref": {
321                 "pref": 100
322             },
323             "ipv6-next-hop": {
324                 "global": "3ffe:63::1"
325             }
326         }
327     }]
328 }
329
330 # IPv6 route in peer operational data
331 rib_ip6_operational = {
332     "loc-rib": {"tables": [
333         {
334             "afi": "bgp-types:ipv6-address-family",
335             "safi": "bgp-types:unicast-subsequent-address-family",
336             "bgp-inet:ipv6-routes": {
337                 "ipv6-route": dut1_route_ip6["bgp-inet:ipv6-route"]
338             }
339         }
340     ]}
341 }
342
343 route_ip6_operational = {
344     "next-hop": {"next-hop-address": "3ffe:63::1"},
345     "vpp-ipv6-unicast-routing:vpp-ipv6-route": {},
346     "destination-prefix": dut1_route_ip6_prefix
347 }