Implement QUAGGA restart in cord test cmd server for vrouter test cases.
Add some more vrouter tests to stress onos with more routes but disable it for now.
diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
index 2dff4e1..854c007 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -179,51 +179,6 @@
print('Removing test container %s' %self.name)
self.kill(remove=True)
-class Quagga(Container):
- quagga_config = { 'bridge' : 'quagga-br', 'ip': '10.10.0.3', 'mask' : 16 }
- ports = [ 179, 2601, 2602, 2603, 2604, 2605, 2606 ]
- host_quagga_config = os.path.join(CordTester.tester_base, 'quagga-config')
- guest_quagga_config = '/root/config'
- host_guest_map = ( (host_quagga_config, guest_quagga_config), )
-
- def __init__(self, name = 'cord-quagga', image = 'cord-test/quagga', tag = 'latest', boot_delay = 60):
- super(Quagga, self).__init__(name, image, tag = tag, quagga_config = self.quagga_config)
- if not self.img_exists():
- self.build_image(image)
- if not self.exists():
- self.remove_container(name, force=True)
- host_config = self.create_host_config(port_list = self.ports,
- host_guest_map = self.host_guest_map,
- privileged = True)
- volumes = []
- for _,g in self.host_guest_map:
- volumes.append(g)
- self.start(ports = self.ports,
- host_config = host_config,
- volumes = volumes, tty = True)
- print('Starting Quagga on container %s' %self.name)
- self.execute('{}/start.sh'.format(self.guest_quagga_config))
-
- @classmethod
- def build_image(cls, image):
- onos_quagga_ip = Onos.quagga_config['ip']
- print('Building Quagga image %s' %image)
- dockerfile = '''
-FROM ubuntu:latest
-WORKDIR /root
-RUN useradd -M quagga
-RUN mkdir /var/log/quagga && chown quagga:quagga /var/log/quagga
-RUN mkdir /var/run/quagga && chown quagga:quagga /var/run/quagga
-RUN apt-get update && apt-get install -qy git autoconf libtool gawk make telnet libreadline6-dev
-RUN git clone git://git.sv.gnu.org/quagga.git quagga && \
-(cd quagga && git checkout HEAD && ./bootstrap.sh && \
-sed -i -r 's,htonl.*?\(INADDR_LOOPBACK\),inet_addr\("{0}"\),g' zebra/zebra_fpm.c && \
-./configure --enable-fpm --disable-doc --localstatedir=/var/run/quagga && make && make install)
-RUN ldconfig
-'''.format(onos_quagga_ip)
- super(Quagga, cls).build_image(dockerfile, image)
- print('Done building image %s' %image)
-
##default onos/radius/test container images and names
onos_image_default='onosproject/onos:latest'
nose_image_default='cord-test/nose:latest'
diff --git a/src/test/utils/CordContainer.py b/src/test/utils/CordContainer.py
index c7a6850..68b9471 100644
--- a/src/test/utils/CordContainer.py
+++ b/src/test/utils/CordContainer.py
@@ -233,3 +233,53 @@
volumes = volumes,
host_config = host_config, tty = True)
+class Quagga(Container):
+ quagga_config = { 'bridge' : 'quagga-br', 'ip': '10.10.0.3', 'mask' : 16 }
+ ports = [ 179, 2601, 2602, 2603, 2604, 2605, 2606 ]
+ host_quagga_config = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'setup/quagga-config')
+ guest_quagga_config = '/root/config'
+ quagga_config_file = os.path.join(guest_quagga_config, 'testrib.conf')
+ host_guest_map = ( (host_quagga_config, guest_quagga_config), )
+
+ def __init__(self, name = 'cord-quagga', image = 'cord-test/quagga', tag = 'latest',
+ boot_delay = 15, restart = False, config_file = quagga_config_file):
+ super(Quagga, self).__init__(name, image, tag = tag, quagga_config = self.quagga_config)
+ if not self.img_exists():
+ self.build_image(image)
+ if restart is True and self.exists():
+ self.kill()
+ if not self.exists():
+ self.remove_container(name, force=True)
+ host_config = self.create_host_config(port_list = self.ports,
+ host_guest_map = self.host_guest_map,
+ privileged = True)
+ volumes = []
+ for _,g in self.host_guest_map:
+ volumes.append(g)
+ self.start(ports = self.ports,
+ host_config = host_config,
+ volumes = volumes, tty = True)
+ print('Starting Quagga on container %s' %self.name)
+ self.execute('{0}/start.sh {1}'.format(self.guest_quagga_config, config_file))
+ time.sleep(boot_delay)
+
+ @classmethod
+ def build_image(cls, image):
+ onos_quagga_ip = Onos.quagga_config['ip']
+ print('Building Quagga image %s' %image)
+ dockerfile = '''
+FROM ubuntu:latest
+WORKDIR /root
+RUN useradd -M quagga
+RUN mkdir /var/log/quagga && chown quagga:quagga /var/log/quagga
+RUN mkdir /var/run/quagga && chown quagga:quagga /var/run/quagga
+RUN apt-get update && apt-get install -qy git autoconf libtool gawk make telnet libreadline6-dev
+RUN git clone git://git.sv.gnu.org/quagga.git quagga && \
+(cd quagga && git checkout HEAD && ./bootstrap.sh && \
+sed -i -r 's,htonl.*?\(INADDR_LOOPBACK\),inet_addr\("{0}"\),g' zebra/zebra_fpm.c && \
+./configure --enable-fpm --disable-doc --localstatedir=/var/run/quagga && make && make install)
+RUN ldconfig
+'''.format(onos_quagga_ip)
+ super(Quagga, cls).build_image(dockerfile, image)
+ print('Done building image %s' %image)
+
diff --git a/src/test/utils/CordTestServer.py b/src/test/utils/CordTestServer.py
index dbf20f3..806b36b 100644
--- a/src/test/utils/CordTestServer.py
+++ b/src/test/utils/CordTestServer.py
@@ -1,7 +1,7 @@
import SocketServer as socketserver
import threading
import socket
-from CordContainer import Onos
+from CordContainer import Onos, Quagga
from nose.tools import nottest
##Server to handle container restart requests from test container.
@@ -12,12 +12,32 @@
class CordTestServer(socketserver.BaseRequestHandler):
+ def restart_onos(self, args):
+ print('Restarting ONOS')
+ onos = Onos(restart = True)
+ self.request.sendall('DONE')
+
+ def restart_quagga(self, args):
+ if args is None:
+ args = Quagga.quagga_config_file
+ print('Restarting QUAGGA with config file %s'%args)
+ quagga = Quagga(restart = True, config_file = args)
+ self.request.sendall('DONE')
+
+ callback_table = { 'RESTART_ONOS' : restart_onos,
+ 'RESTART_QUAGGA' : restart_quagga,
+ }
+
def handle(self):
data = self.request.recv(1024).strip()
- if data == 'RESTART_ONOS':
- print('Restarting ONOS')
- onos = Onos(restart = True)
- self.request.sendall('DONE')
+ cmd = data.split()[0]
+ try:
+ args = ' '.join(data.split()[1:])
+ except:
+ args = None
+
+ if self.callback_table.has_key(cmd):
+ self.callback_table[cmd](self, args)
class ThreadedTestServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
allow_reuse_address = True
@@ -43,6 +63,21 @@
s.connect( (CORD_TEST_HOST, CORD_TEST_PORT) )
s.sendall('RESTART_ONOS\n')
data = s.recv(1024).strip()
+ s.close()
+ if data == 'DONE':
+ return True
+ return False
+
+@nottest
+def cord_test_quagga_restart(config_file = None):
+ '''Send QUAGGA restart to server'''
+ if config_file is None:
+ config_file = Quagga.quagga_config_file
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.connect( (CORD_TEST_HOST, CORD_TEST_PORT) )
+ s.sendall('RESTART_QUAGGA {}\n'.format(config_file))
+ data = s.recv(1024).strip()
+ s.close()
if data == 'DONE':
return True
return False
diff --git a/src/test/vrouter/vrouterTest.py b/src/test/vrouter/vrouterTest.py
index 9e9f881..37c1523 100644
--- a/src/test/vrouter/vrouterTest.py
+++ b/src/test/vrouter/vrouterTest.py
@@ -5,8 +5,8 @@
from OltConfig import OltConfig
from OnosFlowCtrl import OnosFlowCtrl, get_mac
from onosclidriver import OnosCliDriver
-from CordContainer import Container, Onos
-from CordTestServer import cord_test_onos_restart
+from CordContainer import Container, Onos, Quagga
+from CordTestServer import cord_test_onos_restart, cord_test_quagga_restart
from portmaps import g_subscriber_port_map
import threading
import time
@@ -14,13 +14,6 @@
import json
log.setLevel('INFO')
-class Quagga(Container):
- quagga_config = '/root/config'
- def __init__(self, name = 'cord-quagga', image = 'cord-test/quagga', tag = 'latest'):
- super(Quagga, self).__init__(name, image, tag = tag)
- if not self.exists():
- raise Exception('Quagga container was not started by cord-test')
-
class vrouter_exchange(unittest.TestCase):
apps = ('org.onosproject.vrouter', 'org.onosproject.fwd')
@@ -128,16 +121,14 @@
return cord_test_onos_restart()
@classmethod
- def start_quagga(cls, stop = True, networks = 4, gateway = GATEWAY):
- quagga = Quagga()
- log.info('Starting Quagga on container %s with %d networks' %(quagga.name, networks))
- if stop is True:
- quagga.execute('{}/stop.sh'.format(Quagga.quagga_config))
+ def start_quagga(cls, networks = 4, gateway = GATEWAY):
+ log.info('Restarting Quagga container with configuration for %d networks' %(networks))
config = cls.generate_conf(networks = networks, gateway = gateway)
- with open('{}/testrib_gen.conf'.format(cls.quagga_config_path), 'w') as f:
+ host_config_file = '{}/testrib_gen.conf'.format(Quagga.host_quagga_config)
+ guest_config_file = os.path.join(Quagga.guest_quagga_config, 'testrib_gen.conf')
+ with open(host_config_file, 'w') as f:
f.write(config)
- quagga.execute('{0}/start.sh {1}/testrib_gen.conf'.format(Quagga.quagga_config, Quagga.quagga_config))
- time.sleep(10)
+ cord_test_quagga_restart(config_file = guest_config_file)
@classmethod
def generate_vrouter_conf(cls, networks = 4):
@@ -209,7 +200,7 @@
vrouter_configs = cls.vrouter_config_get(networks = networks)
cls.start_onos(network_cfg = vrouter_configs)
##Start quagga
- cls.start_quagga(networks = networks, stop = True, gateway = cls.GATEWAY)
+ cls.start_quagga(networks = networks, gateway = cls.GATEWAY)
return vrouter_configs
def vrouter_port_send_recv(self, ingress, egress, dst_mac, dst_ip):
@@ -255,7 +246,7 @@
log.info('Discovered hosts: %s' %hosts)
routes = json.loads(self.cli.routes(jsonFormat = True))
log.info('Routes: %s' %routes)
- #assert_equal(len(routes['routes4']), networks)
+ assert_equal(len(routes['routes4']), networks)
flows = json.loads(self.cli.flows(jsonFormat = True))
flows = filter(lambda f: f['flows'], flows)
#log.info('Flows: %s' %flows)
@@ -270,7 +261,7 @@
assert_equal(res, True)
def test_vrouter_2(self):
- '''Test vrouter with 20 routes'''
+ '''Test vrouter with 50 routes'''
res = self.__vrouter_network_verify(50)
assert_equal(res, True)
@@ -280,6 +271,30 @@
assert_equal(res, True)
def test_vrouter_4(self):
- '''Test vrouter with 200 routes'''
+ '''Test vrouter with 300 routes'''
res = self.__vrouter_network_verify(300)
assert_equal(res, True)
+
+ @nottest
+ def test_vrouter_5(self):
+ '''Test vrouter with 1000 routes'''
+ res = self.__vrouter_network_verify(1000)
+ assert_equal(res, True)
+
+ @nottest
+ def test_vrouter_6(self):
+ '''Test vrouter with 10000 routes'''
+ res = self.__vrouter_network_verify(10000)
+ assert_equal(res, True)
+
+ @nottest
+ def test_vrouter_7(self):
+ '''Test vrouter with 100000 routes'''
+ res = self.__vrouter_network_verify(100000)
+ assert_equal(res, True)
+
+ @nottest
+ def test_vrouter_8(self):
+ '''Test vrouter with 1000000 routes'''
+ res = self.__vrouter_network_verify(1000000)
+ assert_equal(res, True)