summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2018-01-09 14:27:00 +0900
committerIWASE Yusuke <iwase.yusuke0@gmail.com>2018-01-09 15:52:42 +0900
commit4e993174e369966f313fb859fc759c104d8f8841 (patch)
treea197e70ef18a0b88b401ff8ae3bfdb4c5c5d6bcd
parenta4b070be96f1482e397948f7c93ad0a9da9c8192 (diff)
test/lib/base: Removes redundant routes from host
When creating a new Docker network (Linux Bridge), some routes to its subnet will be installed in to the container host's routing table. This routes enable containers to communicate each other through the container host's rouging table, then causes the unexpected success of scenario tests (e.g., ping between containers). This patch removes the unexpected routes from the container host and avoid this problem. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-rw-r--r--test/lib/base.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/lib/base.py b/test/lib/base.py
index da3cf611..9a543c45 100644
--- a/test/lib/base.py
+++ b/test/lib/base.py
@@ -169,6 +169,17 @@ class Bridge(object):
try_several_times(lambda: local("ip addr add {0} dev {1}".format(self.ip_addr, self.name)))
self.ctns = []
+ # Note: Here removes routes from the container host to prevent traffic
+ # from going through the container host's routing table.
+ if with_ip:
+ local('ip route del {0}; echo $?'.format(subnet),
+ capture=True)
+ # When IPv6, 2 routes will be installed to the container host's
+ # routing table.
+ if self.subnet.version == 6:
+ local('ip -6 route del {0}; echo $?'.format(subnet),
+ capture=True)
+
def next_ip_address(self):
return "{0}/{1}".format(self._ip_generator.next(),
self.subnet.prefixlen)
@@ -508,11 +519,11 @@ class BGPContainer(Container):
def add_static_route(self, network, next_hop):
cmd = '/sbin/ip route add {0} via {1}'.format(network, next_hop)
- self.local(cmd)
+ self.local(cmd, capture=True)
def set_ipv6_forward(self):
cmd = 'sysctl -w net.ipv6.conf.all.forwarding=1'
- self.local(cmd)
+ self.local(cmd, capture=True)
def create_config(self):
raise Exception('implement create_config() method')