Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.91 KB | None | 0 0
  1. From 02521c91c47ea3e43a9dae05b98dfa6def9feaff Mon Sep 17 00:00:00 2001
  2. From: Philippe Guibert <philippe.guibert@6wind.com>
  3. Date: Thu, 3 Oct 2019 08:38:25 +0200
  4. Subject: [PATCH] topotests: add bgp route reflector scenario
  5.  
  6. that scenario involves 2 route reflector servers, replicating the same
  7. route to a route reflector client, named r1. the goal is to check there
  8. is no flapping when one route reflector server leaves, as the other
  9. remaing present.
  10.  
  11. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
  12. ---
  13. tests/topotests/bgp_rr_case/#__init__.py# | 1 +
  14. tests/topotests/bgp_rr_case/__init__.py | 0
  15. tests/topotests/bgp_rr_case/r1/bgpd.conf | 31 ++++
  16. tests/topotests/bgp_rr_case/r1/zebra.conf | 10 ++
  17. tests/topotests/bgp_rr_case/r2/bgpd.conf | 28 ++++
  18. tests/topotests/bgp_rr_case/r2/zebra.conf | 13 ++
  19. tests/topotests/bgp_rr_case/r3/bgpd.conf | 24 +++
  20. tests/topotests/bgp_rr_case/r3/zebra.conf | 13 ++
  21. tests/topotests/bgp_rr_case/r4/bgpd.conf | 36 +++++
  22. tests/topotests/bgp_rr_case/r4/zebra.conf | 11 ++
  23. .../topotests/bgp_rr_case/test_bgp_rr_case.py | 153 ++++++++++++++++++
  24. 11 files changed, 320 insertions(+)
  25. create mode 100644 tests/topotests/bgp_rr_case/#__init__.py#
  26. create mode 100644 tests/topotests/bgp_rr_case/__init__.py
  27. create mode 100644 tests/topotests/bgp_rr_case/r1/bgpd.conf
  28. create mode 100644 tests/topotests/bgp_rr_case/r1/zebra.conf
  29. create mode 100644 tests/topotests/bgp_rr_case/r2/bgpd.conf
  30. create mode 100644 tests/topotests/bgp_rr_case/r2/zebra.conf
  31. create mode 100644 tests/topotests/bgp_rr_case/r3/bgpd.conf
  32. create mode 100644 tests/topotests/bgp_rr_case/r3/zebra.conf
  33. create mode 100644 tests/topotests/bgp_rr_case/r4/bgpd.conf
  34. create mode 100644 tests/topotests/bgp_rr_case/r4/zebra.conf
  35. create mode 100755 tests/topotests/bgp_rr_case/test_bgp_rr_case.py
  36.  
  37. diff --git a/tests/topotests/bgp_rr_case/#__init__.py# b/tests/topotests/bgp_rr_case/#__init__.py#
  38. new file mode 100644
  39. index 000000000000..9029c51c87bf
  40. --- /dev/null
  41. +++ b/tests/topotests/bgp_rr_case/#__init__.py#
  42. @@ -0,0 +1 @@
  43. +macs
  44. \ No newline at end of file
  45. diff --git a/tests/topotests/bgp_rr_case/__init__.py b/tests/topotests/bgp_rr_case/__init__.py
  46. new file mode 100644
  47. index 000000000000..e69de29bb2d1
  48. diff --git a/tests/topotests/bgp_rr_case/r1/bgpd.conf b/tests/topotests/bgp_rr_case/r1/bgpd.conf
  49. new file mode 100644
  50. index 000000000000..08f2a54ced15
  51. --- /dev/null
  52. +++ b/tests/topotests/bgp_rr_case/r1/bgpd.conf
  53. @@ -0,0 +1,31 @@
  54. +debug bgp updates
  55. +debug bgp zebra
  56. +debug bgp neighbor-events
  57. +debug bgp vpn label
  58. +debug bgp vpn leak-from-vrf
  59. +debug bgp vpn leak-to-vrf
  60. +!
  61. +router bgp 100
  62. + bgp router-id 10.0.1.1
  63. + neighbor 10.0.1.101 remote-as 100
  64. + neighbor 10.0.1.100 remote-as 100
  65. + address-family ipv4 vpn
  66. + neighbor 10.0.1.101 activate
  67. + neighbor 10.0.1.101 soft-reconfiguration inbound
  68. + neighbor 10.0.1.100 activate
  69. + neighbor 10.0.1.100 soft-reconfiguration inbound
  70. + !
  71. +!
  72. +router bgp 100 vrf r1-cust1
  73. + bgp router-id 10.0.1.1
  74. + address-family ipv4 unicast
  75. + label vpn export auto
  76. + maximum-paths 4
  77. + maximum-paths ibgp 4
  78. + rd vpn export 64603:1111
  79. + rt vpn import 64603:1111
  80. + rt vpn export 64603:1111
  81. + import vpn
  82. + export vpn
  83. + !
  84. +!
  85. diff --git a/tests/topotests/bgp_rr_case/r1/zebra.conf b/tests/topotests/bgp_rr_case/r1/zebra.conf
  86. new file mode 100644
  87. index 000000000000..984a95dc4c50
  88. --- /dev/null
  89. +++ b/tests/topotests/bgp_rr_case/r1/zebra.conf
  90. @@ -0,0 +1,10 @@
  91. +!
  92. +interface r1-eth0
  93. + ip address 10.0.1.1/24
  94. +!
  95. +interface r1-eth1
  96. + ip address 10.0.2.22/24
  97. +!
  98. +line vty
  99. +!
  100. +debug vrf
  101. diff --git a/tests/topotests/bgp_rr_case/r2/bgpd.conf b/tests/topotests/bgp_rr_case/r2/bgpd.conf
  102. new file mode 100644
  103. index 000000000000..9a729c3f4b7e
  104. --- /dev/null
  105. +++ b/tests/topotests/bgp_rr_case/r2/bgpd.conf
  106. @@ -0,0 +1,28 @@
  107. +log stdout
  108. +debug bgp neighbor-events
  109. +debug bgp updates
  110. +debug bgp zebra
  111. +!
  112. +router bgp 100
  113. + bgp router-id 10.0.3.100
  114. + neighbor 10.0.1.1 remote-as 100
  115. + neighbor 10.0.2.1 remote-as 90
  116. + address-family ipv4 vpn
  117. + neighbor 10.0.1.1 activate
  118. + neighbor 10.0.1.1 route-reflector-client
  119. + neighbor 10.0.2.1 activate
  120. + !
  121. + !
  122. +router bgp 100 vrf r2-cust1
  123. + bgp router-id 10.0.3.100
  124. + address-family ipv4 unicast
  125. + label vpn export auto
  126. + rd vpn export 64603:1111
  127. + rt vpn import 64603:1111
  128. + rt vpn export 64603:1111
  129. + import vpn
  130. + export vpn
  131. + !
  132. +!
  133. +
  134. +
  135. diff --git a/tests/topotests/bgp_rr_case/r2/zebra.conf b/tests/topotests/bgp_rr_case/r2/zebra.conf
  136. new file mode 100644
  137. index 000000000000..0138a78bb2c8
  138. --- /dev/null
  139. +++ b/tests/topotests/bgp_rr_case/r2/zebra.conf
  140. @@ -0,0 +1,13 @@
  141. +!
  142. +interface lo
  143. + ip address 10.0.3.100/32
  144. +!
  145. +interface r2-eth0
  146. + ip address 10.0.1.100/24
  147. +!
  148. +interface r2-eth1
  149. + ip address 10.0.2.100/24
  150. +!
  151. +line vty
  152. +!
  153. +debug vrf
  154. diff --git a/tests/topotests/bgp_rr_case/r3/bgpd.conf b/tests/topotests/bgp_rr_case/r3/bgpd.conf
  155. new file mode 100644
  156. index 000000000000..55d74a7bd55f
  157. --- /dev/null
  158. +++ b/tests/topotests/bgp_rr_case/r3/bgpd.conf
  159. @@ -0,0 +1,24 @@
  160. +!
  161. +router bgp 100
  162. + bgp router-id 10.0.3.101
  163. + neighbor 10.0.1.1 remote-as 100
  164. + neighbor 10.0.2.1 remote-as 90
  165. + address-family ipv4 vpn
  166. + neighbor 10.0.1.1 activate
  167. + neighbor 10.0.1.1 route-reflector-client
  168. + neighbor 10.0.2.1 activate
  169. + !
  170. + !
  171. +!
  172. +router bgp 100 vrf r3-cust1
  173. + bgp router-id 10.0.3.101
  174. + address-family ipv4 unicast
  175. + label vpn export auto
  176. + rd vpn export 64603:1111
  177. + rt vpn import 64603:1111
  178. + rt vpn export 64603:1111
  179. + import vpn
  180. + export vpn
  181. + !
  182. +!
  183. +
  184. diff --git a/tests/topotests/bgp_rr_case/r3/zebra.conf b/tests/topotests/bgp_rr_case/r3/zebra.conf
  185. new file mode 100644
  186. index 000000000000..095d05eb17a7
  187. --- /dev/null
  188. +++ b/tests/topotests/bgp_rr_case/r3/zebra.conf
  189. @@ -0,0 +1,13 @@
  190. +!
  191. +interface lo
  192. + ip address 10.0.3.101/32
  193. +!
  194. +interface r3-eth0
  195. + ip address 10.0.1.101/24
  196. +!
  197. +interface r3-eth1
  198. + ip address 10.0.2.101/24
  199. +!
  200. +line vty
  201. +!
  202. +debug vrf
  203. diff --git a/tests/topotests/bgp_rr_case/r4/bgpd.conf b/tests/topotests/bgp_rr_case/r4/bgpd.conf
  204. new file mode 100644
  205. index 000000000000..e97d7233c845
  206. --- /dev/null
  207. +++ b/tests/topotests/bgp_rr_case/r4/bgpd.conf
  208. @@ -0,0 +1,36 @@
  209. +log stdout
  210. +debug bgp neighbor-events
  211. +debug bgp updates
  212. +debug bgp zebra
  213. +!
  214. +router bgp 90
  215. + bgp router-id 10.0.2.1
  216. + neighbor 10.0.2.100 remote-as 100
  217. + neighbor 10.0.2.101 remote-as 100
  218. + address-family ipv4 vpn
  219. + neighbor 10.0.2.100 activate
  220. + neighbor 10.0.2.100 route-map test3 out
  221. + neighbor 10.0.2.101 activate
  222. + neighbor 10.0.2.101 route-map test2 out
  223. + network 44.44.44.0/24 rd 64603:1111 label 4444
  224. + !
  225. +!
  226. +router bgp 90 vrf r4-cust1
  227. + bgp router-id 10.0.2.1
  228. + address-family ipv4 unicast
  229. + label vpn export auto
  230. + rd vpn export 64603:1111
  231. + rt vpn import 64603:1111
  232. + rt vpn export 64603:1111
  233. + import vpn
  234. + export vpn
  235. + !
  236. +!
  237. +route-map test2 permit 1
  238. + set extcommunity rt 64603:1111
  239. + set ip next-hop 10.0.2.1
  240. +!
  241. +route-map test3 permit 1
  242. + set extcommunity rt 64603:1111
  243. + set ip next-hop 10.0.2.1
  244. +!
  245. diff --git a/tests/topotests/bgp_rr_case/r4/zebra.conf b/tests/topotests/bgp_rr_case/r4/zebra.conf
  246. new file mode 100644
  247. index 000000000000..0b8f0ad0a99e
  248. --- /dev/null
  249. +++ b/tests/topotests/bgp_rr_case/r4/zebra.conf
  250. @@ -0,0 +1,11 @@
  251. +log stdout
  252. +debug bgp neighbor-events
  253. +debug bgp updates
  254. +debug bgp zebra
  255. +!
  256. +interface r4-eth0
  257. + ip address 10.0.2.1/24
  258. +!
  259. +line vty
  260. +!
  261. +debug vrf
  262. diff --git a/tests/topotests/bgp_rr_case/test_bgp_rr_case.py b/tests/topotests/bgp_rr_case/test_bgp_rr_case.py
  263. new file mode 100755
  264. index 000000000000..c96ee31b351c
  265. --- /dev/null
  266. +++ b/tests/topotests/bgp_rr_case/test_bgp_rr_case.py
  267. @@ -0,0 +1,153 @@
  268. +#!/usr/bin/env python
  269. +
  270. +#
  271. +# test_bgp_rr_case_topo1.py
  272. +# Part of NetDEF Topology Tests
  273. +#
  274. +# Copyright (c) 2019 by 6WIND
  275. +#
  276. +# Permission to use, copy, modify, and/or distribute this software
  277. +# for any purpose with or without fee is hereby granted, provided
  278. +# that the above copyright notice and this permission notice appear
  279. +# in all copies.
  280. +#
  281. +# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
  282. +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  283. +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
  284. +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
  285. +# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  286. +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  287. +# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  288. +# OF THIS SOFTWARE.
  289. +#
  290. +
  291. +"""
  292. +test_bgp_rr_case_topo1.py: Test BGP RR topology
  293. +"""
  294. +
  295. +import json
  296. +import os
  297. +import sys
  298. +import pytest
  299. +import getopt
  300. +
  301. +# Save the Current Working Directory to find configuration files.
  302. +CWD = os.path.dirname(os.path.realpath(__file__))
  303. +sys.path.append(os.path.join(CWD, '../'))
  304. +
  305. +# pylint: disable=C0413
  306. +# Import topogen and topotest helpers
  307. +from lib import topotest
  308. +from lib.topogen import Topogen, TopoRouter, get_topogen
  309. +from lib.topolog import logger
  310. +
  311. +# Required to instantiate the topology builder class.
  312. +from mininet.topo import Topo
  313. +
  314. +
  315. +#####################################################
  316. +##
  317. +## Network Topology Definition
  318. +##
  319. +#####################################################
  320. +
  321. +class BGPRRCASETopo1(Topo):
  322. + "BGP RR Topology 1"
  323. +
  324. + def build(self, **_opts):
  325. + tgen = get_topogen(self)
  326. +
  327. + # Setup Routers
  328. + tgen.add_router('r1')
  329. +
  330. + # Setup Switches
  331. + switch = tgen.add_switch('s1')
  332. + switch.add_link(tgen.gears['r1'])
  333. +
  334. + tgen.add_router('r2')
  335. + tgen.add_router('r3')
  336. + switch.add_link(tgen.gears['r2'])
  337. + switch.add_link(tgen.gears['r3'])
  338. +
  339. + tgen.add_router('r4')
  340. + switch = tgen.add_switch('s2')
  341. + switch.add_link(tgen.gears['r2'])
  342. + switch.add_link(tgen.gears['r3'])
  343. + switch.add_link(tgen.gears['r4'])
  344. + switch.add_link(tgen.gears['r1'])
  345. +
  346. +
  347. +#####################################################
  348. +##
  349. +## Tests starting
  350. +##
  351. +#####################################################
  352. +
  353. +def setup_module(module):
  354. + tgen = Topogen(BGPRRCASETopo1, module.__name__)
  355. + tgen.start_topology()
  356. +
  357. + if tgen.hasmpls != True:
  358. + logger.info('MPLS not available, skipping setup')
  359. + return False
  360. + #run daemons
  361. + cmds_vrflite = ['ip link add {}-cust1 type vrf table 101',
  362. + 'ip ru add oif {}-cust1 table 101',
  363. + 'ip ru add iif {}-cust1 table 101',
  364. + 'ip li set dev {}-cust1 up',
  365. + 'echo 1 > /proc/sys/net/mpls/conf/{}-eth0/input',
  366. + 'echo 1 > /proc/sys/net/mpls/conf/{}-eth1/input']
  367. + router = tgen.gears['r1']
  368. + for cmd in cmds_vrflite:
  369. + logger.info('cmd to r1: '+cmd);
  370. + output = router.run(cmd.format('r1'))
  371. + logger.info('result: '+output);
  372. +
  373. + router_list = tgen.routers()
  374. + for rname, router in router_list.iteritems():
  375. + logger.info('router {}'.format(rname))
  376. + router.load_config(
  377. + TopoRouter.RD_ZEBRA,
  378. + os.path.join(CWD, '{}/zebra.conf'.format(rname))
  379. + )
  380. + if rname == 'r1':
  381. + router.load_config(
  382. + TopoRouter.RD_BGP,
  383. + os.path.join(CWD, '{}/bgpd.conf'.format(rname))
  384. + )
  385. + else:
  386. + router.load_config(
  387. + TopoRouter.RD_BGP,
  388. + os.path.join(CWD, '{}/bgpd.conf'.format(rname)),
  389. + '-Z'
  390. + )
  391. + logger.info('Launching BGP and ZEBRA for {}'.format(rname))
  392. + # BGP and ZEBRA start without underlying VRF
  393. + tgen.start_router()
  394. +
  395. +
  396. +def teardown_module(module):
  397. + tgen = get_topogen()
  398. + tgen.stop_topology()
  399. +
  400. +def test_bgp_convergence():
  401. + "Test for BGP topology convergence"
  402. + tgen = get_topogen()
  403. +
  404. + # uncomment if you want to troubleshoot
  405. + # tgen.mininet_cli()
  406. + # Skip if previous fatal error condition is raised
  407. + logger.info('waiting for bgp convergence')
  408. + tgen.mininet_cli()
  409. + if tgen.routers_have_failure():
  410. + pytest.skip(tgen.errors)
  411. +
  412. + logger.info('end test')
  413. +
  414. +
  415. +if __name__ == '__main__':
  416. +
  417. + args = ["-s"] + sys.argv[1:]
  418. + ret = pytest.main(args)
  419. +
  420. + sys.exit(ret)
  421. --
  422. 2.17.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement