summaryrefslogtreecommitdiffhomepage
path: root/test/scenario_test/bgp_zebra_nht_test.py
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2018-05-16 16:01:34 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-05-23 13:00:33 +0900
commit87245b488bedca33b766ccd967636946416587cc (patch)
tree3216742a11ba1533f2b75cc625245e97de84bcb4 /test/scenario_test/bgp_zebra_nht_test.py
parent34f74cd314c512ee028983a321d1012f63adb26d (diff)
bgp_zebra_nht_test: Test cases when nexthop unreachable
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'test/scenario_test/bgp_zebra_nht_test.py')
-rw-r--r--test/scenario_test/bgp_zebra_nht_test.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/scenario_test/bgp_zebra_nht_test.py b/test/scenario_test/bgp_zebra_nht_test.py
index b7937ccd..ff5eb77a 100644
--- a/test/scenario_test/bgp_zebra_nht_test.py
+++ b/test/scenario_test/bgp_zebra_nht_test.py
@@ -223,6 +223,60 @@ class ZebraNHTTest(unittest.TestCase):
assert_several_times(f=_f_r2)
assert_several_times(f=_f_r1)
+ def test_06_nexthop_unreachable(self):
+ # Test to update the nexthop state if nexthop become unreachable by
+ # link down. If the link r2-r3 and r2-r4 goes down, there is no route
+ # to r3.
+
+ def _f_r2():
+ self.assertEqual(self.r2.local(
+ "gobgp global rib -a ipv4 10.3.1.0/24"
+ " | grep '^* ' > /dev/null"
+ " && echo OK || echo NG",
+ capture=True), 'OK')
+
+ def _f_r1():
+ self.assertEqual(self.r1.local(
+ "gobgp global rib -a ipv4 10.3.1.0/24"
+ "| grep 'Network not in table' > /dev/null"
+ " && echo OK || echo NG",
+ capture=True), 'OK')
+
+ ifname = get_ifname_with_prefix('192.168.23.3/24', f=self.r3.local)
+ self.r3.local('ip link set %s down' % ifname)
+ ifname = get_ifname_with_prefix('192.168.24.4/24', f=self.r4.local)
+ self.r4.local('ip link set %s down' % ifname)
+
+ assert_several_times(f=_f_r2, t=120)
+ assert_several_times(f=_f_r1, t=120)
+ # Confirm the stability of the nexthop state
+ for _ in range(10):
+ time.sleep(1)
+ _f_r2()
+ _f_r1()
+
+ def test_07_nexthop_restore(self):
+ # Test to update the nexthop state if nexthop become reachable again.
+ # If the link r2-r3 and r2-r4 goes up again, MED/Metric should be
+ # update with the initial value.
+
+ # MED/Metric = 10(r2 to r3) + 10(r3-ethX to r3-lo)
+ med = 20
+
+ def _f_r2():
+ self._assert_med_equal(self.r2, '10.3.1.0/24', med)
+
+ def _f_r1():
+ self._assert_med_equal(self.r1, '10.3.1.0/24', med)
+
+ ifname = get_ifname_with_prefix('192.168.23.3/24', f=self.r3.local)
+ self.r3.local('ip link set %s up' % ifname)
+ ifname = get_ifname_with_prefix('192.168.24.4/24', f=self.r4.local)
+ self.r4.local('ip link set %s up' % ifname)
+
+ assert_several_times(f=_f_r2)
+ assert_several_times(f=_f_r1)
+
if __name__ == '__main__':
output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True)