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/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