summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--test/scenario_test/lib/base.py6
-rw-r--r--test/scenario_test/lib/quagga.py16
-rw-r--r--test/scenario_test/pip-requires.txt1
3 files changed, 12 insertions, 11 deletions
diff --git a/test/scenario_test/lib/base.py b/test/scenario_test/lib/base.py
index 66e610d9..721e1c1d 100644
--- a/test/scenario_test/lib/base.py
+++ b/test/scenario_test/lib/base.py
@@ -171,6 +171,12 @@ class Container(object):
def local(self, cmd):
return local("docker exec -it {0} {1}".format(self.name, cmd))
+ def get_pid(self):
+ if self.is_running:
+ cmd = "docker inspect -f '{{.State.Pid}}' " + self.name
+ return int(local(cmd, capture=True))
+ return -1
+
class BGPContainer(Container):
diff --git a/test/scenario_test/lib/quagga.py b/test/scenario_test/lib/quagga.py
index 5141ff7d..0346768f 100644
--- a/test/scenario_test/lib/quagga.py
+++ b/test/scenario_test/lib/quagga.py
@@ -15,6 +15,7 @@
from base import *
import telnetlib
+from nsenter import Namespace
class QuaggaTelnetDaemon(object):
@@ -22,19 +23,11 @@ class QuaggaTelnetDaemon(object):
TELNET_PORT = 2605
def __init__(self, ctn):
- ip_addr = None
- for _, ip_addr, br in ctn.ip_addrs:
- if br.ip_addr:
- break
-
- if not ip_addr:
- Exception('quagga telnet daemon {0}'
- ' is not ip reachable'.format(self.name))
-
- self.host = ip_addr.split('/')[0]
+ self.ns = Namespace(ctn.get_pid(), 'net')
def __enter__(self):
- self.tn = telnetlib.Telnet(self.host, self.TELNET_PORT)
+ self.ns.__enter__()
+ self.tn = telnetlib.Telnet('127.0.0.1', self.TELNET_PORT)
self.tn.read_until("Password: ")
self.tn.write(self.TELNET_PASSWORD + "\n")
self.tn.write("enable\n")
@@ -43,6 +36,7 @@ class QuaggaTelnetDaemon(object):
def __exit__(self, type, value, traceback):
self.tn.close()
+ self.ns.__exit__(type, value, traceback)
class QuaggaBGPContainer(BGPContainer):
diff --git a/test/scenario_test/pip-requires.txt b/test/scenario_test/pip-requires.txt
index b02d2c63..f8157aed 100644
--- a/test/scenario_test/pip-requires.txt
+++ b/test/scenario_test/pip-requires.txt
@@ -5,3 +5,4 @@ ecdsa
pycrypto>=2.1
fabric
netaddr
+nsenter