From: peusterm Date: Mon, 14 Mar 2016 16:21:56 +0000 (+0100) Subject: CI problem seems to be caused by not started Ryu controller. X-Git-Tag: v3.1~162^2~1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=ef6629e1ac730db146a8d50b08cadc26f87f21fa;p=osm%2Fvim-emu.git CI problem seems to be caused by not started Ryu controller. --- diff --git a/src/emuvim/dcemulator/net.py b/src/emuvim/dcemulator/net.py index da546ab..bc54293 100755 --- a/src/emuvim/dcemulator/net.py +++ b/src/emuvim/dcemulator/net.py @@ -5,13 +5,13 @@ Distributed Cloud Emulator (dcemulator) import logging import site +import time from subprocess import Popen import os from mininet.net import Dockernet -from mininet.node import Controller, OVSSwitch, OVSKernelSwitch, Switch, Docker, Host, RemoteController +from mininet.node import Controller, DefaultController, OVSSwitch, OVSKernelSwitch, Docker, RemoteController from mininet.cli import CLI -from mininet.log import setLogLevel, info, debug from mininet.link import TCLink import networkx as nx from emuvim.dcemulator.monitoring import DCNetworkMonitor @@ -27,7 +27,7 @@ class DCNetwork(Dockernet): This class is used by topology definition scripts. """ - def __init__(self, dc_emulation_max_cpu=1.0, **kwargs): + def __init__(self, controller=RemoteController, dc_emulation_max_cpu=1.0, **kwargs): """ Create an extended version of a Dockernet network :param dc_emulation_max_cpu: max. CPU time used by containers in data centers @@ -38,20 +38,20 @@ class DCNetwork(Dockernet): # call original Docker.__init__ and setup default controller Dockernet.__init__( - self, controller=RemoteController, switch=OVSKernelSwitch, **kwargs) + self, switch=OVSKernelSwitch, **kwargs) - # ass a remote controller to be able to use Ryu - self.addController('c0', controller=RemoteController) + # start Ryu controller + self.startRyu() + + # add a remote controller to be able to use Ryu + self.addController('c0', controller=controller) # graph of the complete DC network - self.DCNetwork_graph=nx.DiGraph() + self.DCNetwork_graph = nx.DiGraph() # monitoring agent self.monitor_agent = DCNetworkMonitor(self) - # start Ryu controller - self.startRyu() - # initialize resource model registrar self.rm_registrar = ResourceModelRegistrar(dc_emulation_max_cpu) @@ -215,5 +215,6 @@ class DCNetwork(Dockernet): ryu_option = '--ofp-tcp-listen-port' ryu_of_port = '6653' ryu_cmd = 'ryu-manager' - FNULL = open(os.devnull, 'w') - self.ryu_process = Popen([ryu_cmd, ryu_path, ryu_path2, ryu_option, ryu_of_port], stdout=FNULL, stderr=FNULL) \ No newline at end of file + 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) \ No newline at end of file diff --git a/src/emuvim/test/base.py b/src/emuvim/test/base.py index f652259..13ace1b 100644 --- a/src/emuvim/test/base.py +++ b/src/emuvim/test/base.py @@ -8,6 +8,7 @@ import subprocess import docker from emuvim.dcemulator.net import DCNetwork from mininet.clean import cleanup +from mininet.node import Controller class SimpleTestTopology(unittest.TestCase): """ @@ -32,7 +33,7 @@ class SimpleTestTopology(unittest.TestCase): Creates a Mininet instance and automatically adds some nodes to it. """ - self.net = net = DCNetwork() + self.net = DCNetwork() # add some switches for i in range(0, nswitches): diff --git a/src/emuvim/test/test_emulator.py b/src/emuvim/test/test_emulator.py index d552f1f..fb8714a 100755 --- a/src/emuvim/test/test_emulator.py +++ b/src/emuvim/test/test_emulator.py @@ -40,7 +40,7 @@ class testEmulatorTopology( SimpleTestTopology ): # stop Mininet network self.stopNet() - @unittest.skip("disabled to test if CI fails because this is the first test.") + #@unittest.skip("disabled to test if CI fails because this is the first test.") def testMultipleDatacenterDirect(self): """ Create a two data centers and interconnect them. @@ -57,7 +57,6 @@ class testEmulatorTopology( SimpleTestTopology ): assert(len(self.getDockernetContainers()) == 0) assert(len(self.net.hosts) == 2) assert(len(self.net.switches) == 2) - time.sleep(5) # check connectivity by using ping assert(self.net.ping([self.h[0], self.h[1]]) <= 0.0) # stop Mininet network