From de14f336868b6303e73b77b9d3a63ad4d58cc866 Mon Sep 17 00:00:00 2001 From: peusterm Date: Tue, 15 Mar 2016 16:14:21 +0100 Subject: [PATCH] Fix: Always use Mininet's default controller for unit tests. Only use the other one if you really want to test it. --- src/emuvim/dcemulator/net.py | 15 +++++++++------ src/emuvim/test/base.py | 8 ++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/emuvim/dcemulator/net.py b/src/emuvim/dcemulator/net.py index 81d16ab..d91ef4a 100755 --- a/src/emuvim/dcemulator/net.py +++ b/src/emuvim/dcemulator/net.py @@ -40,10 +40,13 @@ class DCNetwork(Dockernet): Dockernet.__init__( self, switch=OVSKernelSwitch, **kwargs) - # start Ryu controller - self.startRyu() + # Ryu management + self.ryu_process = None + if controller == RemoteController: + # start Ryu controller + self.startRyu() - # add a remote controller to be able to use Ryu + # add the specified controller self.addController('c0', controller=controller) # graph of the complete DC network @@ -208,18 +211,18 @@ class DCNetwork(Dockernet): # start Ryu controller with rest-API python_install_path = site.getsitepackages()[0] ryu_path = python_install_path + '/ryu/app/simple_switch_13.py' - ryu_path2 = python_install_path + '/ryu/app/ofctl_rest.py' + ryu_path2 = python_install_path + '/ryu/app/ofctl_rest.py' # change the default Openflow controller port to 6653 (official IANA-assigned port number), as used by Mininet # Ryu still uses 6633 as default ryu_option = '--ofp-tcp-listen-port' ryu_of_port = '6653' - ryu_cmd = 'ryu-manager' + ryu_cmd = 'ryu-manager' FNULL = open("/tmp/ryu.log", 'w') self.ryu_process = Popen([ryu_cmd, ryu_path, ryu_path2, ryu_option, ryu_of_port], stdout=FNULL, stderr=FNULL) time.sleep(1) def stopRyu(self): - if self.ryu_process: + if self.ryu_process is not None: self.ryu_process.terminate() self.ryu_process.kill() diff --git a/src/emuvim/test/base.py b/src/emuvim/test/base.py index 13ace1b..d5329a9 100644 --- a/src/emuvim/test/base.py +++ b/src/emuvim/test/base.py @@ -28,12 +28,16 @@ class SimpleTestTopology(unittest.TestCase): def createNet( self, nswitches=0, ndatacenter=0, nhosts=0, ndockers=0, - autolinkswitches=False): + autolinkswitches=False, controller=Controller): """ Creates a Mininet instance and automatically adds some nodes to it. + + Attention, we should always use Mininet's default controller + for our tests. Only use other controllers if you want to test + specific controller functionality. """ - self.net = DCNetwork() + self.net = DCNetwork(controller=controller) # add some switches for i in range(0, nswitches): -- 2.17.1