summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authormageshgv <mageshgv@gmail.com>2019-10-16 16:48:41 -0700
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-10-17 14:54:52 +0900
commit0794811562fdad2affbf48200b88e36cad88a578 (patch)
treeb9fbc63b7f8a12245ee8209d04797afffe4657a0 /test
parent0235f7c67539e199eb59e7ffb09409e07a8d13e0 (diff)
Transition to graceful restart state on hold timer expiry if applicable
Diffstat (limited to 'test')
-rw-r--r--test/scenario_test/graceful_restart_test.py43
-rw-r--r--test/scenario_test/long_lived_graceful_restart_test.py71
2 files changed, 99 insertions, 15 deletions
diff --git a/test/scenario_test/graceful_restart_test.py b/test/scenario_test/graceful_restart_test.py
index 59dfe226..18c5f55f 100644
--- a/test/scenario_test/graceful_restart_test.py
+++ b/test/scenario_test/graceful_restart_test.py
@@ -131,11 +131,12 @@ class GoBGPTestBase(unittest.TestCase):
time.sleep(1)
self.assertEqual(len(g3.get_global_rib('10.10.20.0/24')), 1)
- def test_05_graceful_restart(self):
+ def test_05_holdtime_expiry_graceful_restart(self):
g1 = self.bgpds['g1']
g2 = self.bgpds['g2']
g3 = self.bgpds['g3']
- g1.stop_gobgp()
+ g1.local("ip route add blackhole {}/32".format(g2.ip_addrs[0][1].split("/")[0]))
+ g1.local("ip route add blackhole {}/32".format(g3.ip_addrs[0][1].split("/")[0]))
g2.wait_for(expected_state=BGP_FSM_ACTIVE, peer=g1)
self.assertEqual(len(g2.get_global_rib('10.10.20.0/24')), 1)
self.assertEqual(len(g2.get_global_rib('10.10.30.0/24')), 1)
@@ -147,11 +148,45 @@ class GoBGPTestBase(unittest.TestCase):
self.assertEqual(len(g3.get_global_rib('10.10.30.0/24')), 1)
def test_06_test_restart_timer_expire(self):
+ g2 = self.bgpds['g2']
+ time.sleep(GRACEFUL_RESTART_TIME + 5)
+ g2 = self.bgpds['g2']
+ self.assertEqual(len(g2.get_global_rib()), 0)
+
+ def test_07_establish_after_graceful_restart(self):
+ g1 = self.bgpds['g1']
+ g2 = self.bgpds['g2']
+ g3 = self.bgpds['g3']
+ g1.local("ip route del blackhole {}/32".format(g2.ip_addrs[0][1].split("/")[0]))
+ g1.local("ip route del blackhole {}/32".format(g3.ip_addrs[0][1].split("/")[0]))
+ g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g2)
+ g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g3)
+ self.assertEqual(len(g2.get_global_rib('10.10.20.0/24')), 1)
+ self.assertEqual(len(g2.get_global_rib('10.10.30.0/24')), 1)
+ self.assertEqual(len(g3.get_global_rib('10.10.20.0/24')), 1)
+ self.assertEqual(len(g3.get_global_rib('10.10.30.0/24')), 1)
+
+ def test_08_graceful_restart(self):
+ g1 = self.bgpds['g1']
+ g2 = self.bgpds['g2']
+ g3 = self.bgpds['g3']
+ g1.stop_gobgp()
+ g2.wait_for(expected_state=BGP_FSM_ACTIVE, peer=g1)
+ self.assertEqual(len(g2.get_global_rib('10.10.20.0/24')), 1)
+ self.assertEqual(len(g2.get_global_rib('10.10.30.0/24')), 1)
+ for d in g2.get_global_rib():
+ for p in d['paths']:
+ self.assertTrue(p['stale'])
+
+ self.assertEqual(len(g3.get_global_rib('10.10.20.0/24')), 0)
+ self.assertEqual(len(g3.get_global_rib('10.10.30.0/24')), 1)
+
+ def test_09_test_restart_timer_expire(self):
time.sleep(GRACEFUL_RESTART_TIME + 5)
g2 = self.bgpds['g2']
self.assertEqual(len(g2.get_global_rib()), 0)
- def test_07_multineighbor_established(self):
+ def test_10_multineighbor_established(self):
g1 = self.bgpds['g1']
g2 = self.bgpds['g2']
g3 = self.bgpds['g3']
@@ -170,7 +205,7 @@ class GoBGPTestBase(unittest.TestCase):
g2.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g1)
g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g1)
- def test_08_multineighbor_graceful_restart(self):
+ def test_11_multineighbor_graceful_restart(self):
g1 = self.bgpds['g1']
g2 = self.bgpds['g2']
g3 = self.bgpds['g3']
diff --git a/test/scenario_test/long_lived_graceful_restart_test.py b/test/scenario_test/long_lived_graceful_restart_test.py
index 1fb5edac..4c185894 100644
--- a/test/scenario_test/long_lived_graceful_restart_test.py
+++ b/test/scenario_test/long_lived_graceful_restart_test.py
@@ -78,18 +78,12 @@ class GoBGPTestBase(unittest.TestCase):
g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g3)
g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g4)
- def test_02_graceful_restart(self):
+ def _test_graceful_restart(self):
g1 = self.bgpds['g1']
g2 = self.bgpds['g2']
g3 = self.bgpds['g3']
g4 = self.bgpds['g4']
- g2.local('gobgp global rib add 10.0.0.0/24')
- g2.local('gobgp global rib add 10.10.0.0/24 community no-llgr')
-
- time.sleep(1)
-
- g2.stop_gobgp()
g1.wait_for(expected_state=BGP_FSM_ACTIVE, peer=g2)
time.sleep(1)
@@ -117,7 +111,62 @@ class GoBGPTestBase(unittest.TestCase):
# withdrawn
self.assertEqual(len(g4.get_global_rib('10.0.0.0/24')), 0)
- def test_03_softreset_preserves_llgr_community(self):
+ def test_02_hold_timer_expiry_graceful_restart(self):
+ g1 = self.bgpds['g1']
+ g2 = self.bgpds['g2']
+ g3 = self.bgpds['g3']
+ g4 = self.bgpds['g4']
+
+ g2.local('gobgp global rib add 10.0.0.0/24')
+ g2.local('gobgp global rib add 10.10.0.0/24 community no-llgr')
+
+ time.sleep(1)
+
+ g2.local("ip route add blackhole {}/32".format(g1.ip_addrs[0][1].split("/")[0]))
+ g2.local("ip route add blackhole {}/32".format(g3.ip_addrs[0][1].split("/")[0]))
+ g2.local("ip route add blackhole {}/32".format(g4.ip_addrs[0][1].split("/")[0]))
+
+ self._test_graceful_restart()
+
+ def test_03_neighbor_established_after_hold_time_expiry(self):
+ g1 = self.bgpds['g1']
+ g2 = self.bgpds['g2']
+ g3 = self.bgpds['g3']
+ g4 = self.bgpds['g4']
+ g2.local("ip route del blackhole {}/32".format(g1.ip_addrs[0][1].split("/")[0]))
+ g2.local("ip route del blackhole {}/32".format(g3.ip_addrs[0][1].split("/")[0]))
+ g2.local("ip route del blackhole {}/32".format(g4.ip_addrs[0][1].split("/")[0]))
+
+ g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g2)
+ time.sleep(1)
+ self.assertEqual(len(g1.get_global_rib('10.0.0.0/24')), 1)
+ self.assertEqual(len(g1.get_global_rib('10.10.0.0/24')), 1)
+ # check llgr-stale community is not present in 10.0.0.0/24
+ r = g1.get_global_rib('10.0.0.0/24')[0]['paths'][0]
+ comms = list(chain.from_iterable([attr['communities'] for attr in r['attrs'] if attr['type'] == 8]))
+ self.assertFalse(0xffff0006 in comms)
+
+ # check llgr-stale community is not present in 10.0.0.0/24
+ self.assertEqual(len(g3.get_global_rib('10.0.0.0/24')), 1)
+ r = g3.get_global_rib('10.0.0.0/24')[0]['paths'][0]
+ comms = list(chain.from_iterable([attr['communities'] for attr in r['attrs'] if attr['type'] == 8]))
+ self.assertFalse(0xffff0006 in comms)
+
+ def test_04_graceful_restart(self):
+ g1 = self.bgpds['g1']
+ g2 = self.bgpds['g2']
+ g3 = self.bgpds['g3']
+ g4 = self.bgpds['g4']
+
+ g2.local('gobgp global rib add 10.0.0.0/24')
+ g2.local('gobgp global rib add 10.10.0.0/24 community no-llgr')
+
+ time.sleep(1)
+
+ g2.stop_gobgp()
+ self._test_graceful_restart()
+
+ def test_05_softreset_preserves_llgr_community(self):
g1 = self.bgpds['g1']
g2 = self.bgpds['g2']
g3 = self.bgpds['g3']
@@ -147,7 +196,7 @@ class GoBGPTestBase(unittest.TestCase):
# g4 is not llgr capable, llgr-stale route must not be advertized on softreset g1
self.assertEqual(len(g4.get_global_rib('10.0.0.0/24')), 0)
- def test_04_neighbor_established(self):
+ def test_06_neighbor_established(self):
g1 = self.bgpds['g1']
g2 = self.bgpds['g2']
# g3 = self.bgpds['g3']
@@ -165,7 +214,7 @@ class GoBGPTestBase(unittest.TestCase):
for p in d['paths']:
self.assertFalse(p.get('stale', False))
- def test_05_llgr_stale_route_depreferenced(self):
+ def test_07_llgr_stale_route_depreferenced(self):
g1 = self.bgpds['g1']
g2 = self.bgpds['g2']
g3 = self.bgpds['g3']
@@ -193,7 +242,7 @@ class GoBGPTestBase(unittest.TestCase):
self.assertEqual(len(rib), 1)
self.assertTrue(g2.asn in rib[0]['paths'][0]['aspath'])
- def test_06_llgr_restart_timer_expire(self):
+ def test_08_llgr_restart_timer_expire(self):
time.sleep(LONG_LIVED_GRACEFUL_RESTART_TIME + 5)
g3 = self.bgpds['g3']
rib = g3.get_global_rib('10.10.0.0/24')