summaryrefslogtreecommitdiffhomepage
path: root/test/scenario_test
diff options
context:
space:
mode:
Diffstat (limited to 'test/scenario_test')
-rw-r--r--test/scenario_test/bgp_zebra_test.py26
-rw-r--r--test/scenario_test/lib/base.py9
-rw-r--r--test/scenario_test/lib/quagga.py9
3 files changed, 29 insertions, 15 deletions
diff --git a/test/scenario_test/bgp_zebra_test.py b/test/scenario_test/bgp_zebra_test.py
index 7f09f12b..9fbf8cfe 100644
--- a/test/scenario_test/bgp_zebra_test.py
+++ b/test/scenario_test/bgp_zebra_test.py
@@ -100,9 +100,9 @@ class GoBGPTestBase(unittest.TestCase):
q1 = self.quaggas['ipv4']
o1 = self.others['ipv4'][0]
- next_hop = g1.ip_addrs[1][1].split('/')[0]
- o1.add_static_route(self.bridges['ipv4']['br01'].subnet, next_hop)
- q1.get_reachablily('192.168.30.2')
+ next_hop = g1.ip_addrs[0][1].split('/')[0]
+ o1.add_static_route(self.bridges['ipv4']['br02'].subnet, next_hop)
+ q1.get_reachablily('192.168.10.1')
"""
No.3 check whether the ping is reachable in container
@@ -113,9 +113,9 @@ class GoBGPTestBase(unittest.TestCase):
q1 = self.quaggas['ipv4']
o2 = self.others['ipv4'][1]
- next_hop = q1.ip_addrs[0][1].split('/')[0]
- o2.add_static_route(self.bridges['ipv4']['br03'].subnet, next_hop)
- g1.get_reachablily('192.168.10.2')
+ next_hop = q1.ip_addrs[1][1].split('/')[0]
+ o2.add_static_route(self.bridges['ipv4']['br02'].subnet, next_hop)
+ g1.get_reachablily('192.168.30.2')
"""
No.4 start up ipv4 containers and check state
@@ -149,9 +149,10 @@ class GoBGPTestBase(unittest.TestCase):
q1 = self.quaggas['ipv6']
o1 = self.others['ipv6'][0]
- next_hop = g1.ip_addrs[1][1].split('/')[0]
- o1.add_static_route(self.bridges['ipv6']['br01'].subnet, next_hop)
- q1.get_reachablily('2001:30::2')
+ next_hop = g1.ip_addrs[0][1].split('/')[0]
+ g1.set_ipv6_forward()
+ o1.add_static_route(self.bridges['ipv6']['br02'].subnet, next_hop)
+ q1.get_reachablily('2001:10::1')
"""
No.6 check whether the ping is reachable in container
@@ -162,9 +163,10 @@ class GoBGPTestBase(unittest.TestCase):
q1 = self.quaggas['ipv6']
o2 = self.others['ipv6'][1]
- next_hop = q1.ip_addrs[0][1].split('/')[0]
- o2.add_static_route(self.bridges['ipv6']['br03'].subnet, next_hop)
- g1.get_reachablily('2001:10::2')
+ next_hop = q1.ip_addrs[1][1].split('/')[0]
+ q1.set_ipv6_forward()
+ o2.add_static_route(self.bridges['ipv6']['br02'].subnet, next_hop)
+ g1.get_reachablily('2001:30::2')
if __name__ == '__main__':
diff --git a/test/scenario_test/lib/base.py b/test/scenario_test/lib/base.py
index 79e97521..8a81c245 100644
--- a/test/scenario_test/lib/base.py
+++ b/test/scenario_test/lib/base.py
@@ -327,14 +327,13 @@ class BGPContainer(Container):
ping_cmd = 'ping6'
else:
raise Exception('unsupported route family: {0}'.format(version))
- cmd = '/bin/{0} -c 1 -w 1 {1}'.format(ping_cmd, addr)
-
+ cmd = '/bin/bash -c "/bin/{0} -c 1 -w 1 {1} | xargs echo"'.format(ping_cmd, addr)
interval = 1
count = 0
while True:
res = self.local(cmd, capture=True)
print colors.yellow(res)
- if '0% packet loss' in res:
+ if '1 packets received' in res and '0% packet loss':
break
time.sleep(interval)
count += interval
@@ -363,6 +362,10 @@ class BGPContainer(Container):
cmd = '/sbin/ip route add {0} via {1}'.format(network, next_hop)
self.local(cmd)
+ def set_ipv6_forward(self):
+ cmd = 'sysctl -w net.ipv6.conf.all.forwarding=1'
+ self.local(cmd)
+
def create_config(self):
raise Exception('implement create_config() method')
diff --git a/test/scenario_test/lib/quagga.py b/test/scenario_test/lib/quagga.py
index b881f6ed..3cd29618 100644
--- a/test/scenario_test/lib/quagga.py
+++ b/test/scenario_test/lib/quagga.py
@@ -158,12 +158,14 @@ class QuaggaBGPContainer(BGPContainer):
self._create_config_zebra()
def _create_config_bgp(self):
+
c = CmdBuffer()
c << 'hostname bgpd'
c << 'password zebra'
c << 'router bgp {0}'.format(self.asn)
c << 'bgp router-id {0}'.format(self.router_id)
+ version = 4
for peer, info in self.peers.iteritems():
version = netaddr.IPNetwork(info['neigh_addr']).version
n_addr = info['neigh_addr'].split('/')[0]
@@ -192,6 +194,13 @@ class QuaggaBGPContainer(BGPContainer):
else:
raise Exception('unsupported route faily: {0}'.format(route['rf']))
+ if self.zebra:
+ if version == 6:
+ c << 'address-family ipv6 unicast'
+ c << 'redistribute connected'
+ c << 'exit-address-family'
+ else:
+ c << 'redistribute connected'
for name, policy in self.policies.iteritems():
c << 'access-list {0} {1} {2}'.format(name, policy['type'],