diff options
author | 2019-05-22 15:23:41 +0200 | |
---|---|---|
committer | 2019-05-23 04:13:53 +0000 | |
commit | 931b7d52a023ea73e596d90c6e9e938de903100b (patch) | |
tree | 2a65632d12bb35f1892e76b8ccd804ab84da21b8 /test | |
parent | ce1a0daa15be4c3b7a3df64ea57ad231664e700f (diff) |
Docker test improvementsvom
Small changes to enable kept running vpp and sysrepo instances after
test execution.
Fixed typos (file name and and method in py file).
Change-Id: I32e56464e61bf1548984ea9845a8d08cf6a3917b
Signed-off-by: Pavel Kotucek <pavel.kotucek@pantheon.tech>
Diffstat (limited to 'test')
-rw-r--r-- | test/framework.py (renamed from test/framewrok.py) | 11 | ||||
-rw-r--r-- | test/netopeer_controler.py | 5 | ||||
-rw-r--r-- | test/test_ietf_interfaces.py | 4 | ||||
-rw-r--r-- | test/topology.py | 21 | ||||
-rw-r--r-- | test/vpp_controler.py | 7 |
5 files changed, 37 insertions, 11 deletions
diff --git a/test/framewrok.py b/test/framework.py index 9fbf240..b308a1a 100644 --- a/test/framewrok.py +++ b/test/framework.py @@ -27,12 +27,19 @@ class SweetcombTestCase(unittest.TestCase): return cls.instance @classmethod - def create_topoly(cls): + def create_topology(cls, debug=False): cls.topology = Topology() - cls.topology.create_topology() + cls.topology.create_topology(debug) cls.vpp = cls.topology.get_vpp() cls.netopeer_cli = cls.topology.get_netopeer_cli() + def check_response(self, resps, expected_result, checks): + assert resps[1] == expected_result + for key,val in checks.items(): + for resp in resps: + r = str(resp).strip() + if r.find("<"+key+">") == 0: + assert r[r.find("<"+key+">")+len("<"+key+">"):r.rfind("</"+key+">")] == val diff --git a/test/netopeer_controler.py b/test/netopeer_controler.py index 74c7dc6..e95cbb4 100644 --- a/test/netopeer_controler.py +++ b/test/netopeer_controler.py @@ -42,6 +42,7 @@ class Netopeer_controler: def spawn(self): self.child = pexpect.spawn(self.name) self.child.logfile = open('/var/log/Netopeer_controler.log', 'wb') + self.child.setwinsize(1,1024) self.pid = self.child.pid self.child.expect(">") self.child.sendline("connect\r") @@ -58,7 +59,7 @@ class Netopeer_controler: def get(self, msg): self.child.sendline("get --filter-xpath {}\r".format(msg)) self.child.expect("> ") - print(self.child.before.decode('ascii')) + return self.child.before.decode('ascii') def edit_config(self, msg): f = open("/tmp/tmp_example.xml", "w") @@ -67,4 +68,4 @@ class Netopeer_controler: self.child.sendline("edit-config --target running --config=/tmp/tmp_example.xml\r") self.child.expect("> ") - print(self.child.before.decode('ascii')) + return self.child.before.decode('ascii') diff --git a/test/test_ietf_interfaces.py b/test/test_ietf_interfaces.py index 55ef029..2b421d3 100644 --- a/test/test_ietf_interfaces.py +++ b/test/test_ietf_interfaces.py @@ -17,14 +17,14 @@ import unittest import util -from framewrok import SweetcombTestCase +from framework import SweetcombTestCase class TestIetfInterfaces(SweetcombTestCase): def setUp(self): super(TestIetfInterfaces, self).setUp() - self.create_topoly() + self.create_topology() def tearDown(self): super(TestIetfInterfaces, self).setUp() diff --git a/test/topology.py b/test/topology.py index 43f15e3..617601b 100644 --- a/test/topology.py +++ b/test/topology.py @@ -24,6 +24,8 @@ import psutil import time class Topology: + debug = False + def __init__(self): self.process = [] @@ -31,6 +33,8 @@ class Topology: self._kill_process() def _kill_process(self): + if self.debug: + return if not self.process: return @@ -67,7 +71,11 @@ class Topology: print("Start sysrepo deamon.") #TODO: Need property close. err = open("/var/log/sysrepod", 'wb') - self.sysrepo = subprocess.Popen(["sysrepod", "-d", "-l 3"], + if self.debug: + params = "-l 4" + else: + params = "-l 3" + self.sysrepo = subprocess.Popen(["sysrepod", "-d", params], stdout=subprocess.PIPE, stderr=err) self.process.append(self.sysrepo) @@ -75,7 +83,11 @@ class Topology: print("Start sysrepo plugins.") #TODO: Need property close. err = open("/var/log/sysrepo-plugind", 'wb') - self.splugin = subprocess.Popen(["sysrepo-plugind", "-d", "-l 3"], + if self.debug: + params = "-l 4" + else: + params = "-l 3" + self.splugin = subprocess.Popen(["sysrepo-plugind", "-d", params], stdout=subprocess.PIPE, stderr=err) self.process.append(self.splugin) @@ -93,7 +105,7 @@ class Topology: def _start_vpp(self): print("Start VPP.") - self.vpp = Vpp_controler() + self.vpp = Vpp_controler(self.debug) self.vpp.spawn() self.process.append(self.vpp) @@ -103,8 +115,9 @@ class Topology: def get_netopeer_cli(self): return self.netopeer_cli - def create_topology(self): + def create_topology(self, debug=False): #try: + self.debug = debug self._prepare_linux_enviroment() self._start_vpp() self._start_sysrepo() diff --git a/test/vpp_controler.py b/test/vpp_controler.py index 561f5a0..e764e9b 100644 --- a/test/vpp_controler.py +++ b/test/vpp_controler.py @@ -19,11 +19,14 @@ import time import psutil class Vpp_controler: - def __init__(self): + debug = False + + def __init__(self, debug=False): self.cmd = "vpp" self.ccmd = "vppctl" self.configuration = "/root/src/sweetcomb/test/conf/vpp.conf" self.process = None + self.debug = debug def __del__(self): #self.kill() @@ -50,6 +53,8 @@ class Vpp_controler: self.process = None def terminate(self): + if self.debug: + return if self.process is None: return |