Use FRR instead of Quagga when testing
Change-Id: I0ae53d3d29a234b25c44f78a693191bd218b1ede
This commit is contained in:
parent
8798a90e7d
commit
04be5a3949
@ -20,7 +20,7 @@ import unittest
|
||||
|
||||
from os_ken.tests.integrated.common import docker_base as ctn_base
|
||||
from os_ken.tests.integrated.common import oskenbgp
|
||||
from os_ken.tests.integrated.common import quagga
|
||||
from os_ken.tests.integrated.common import frr
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -46,8 +46,8 @@ class BgpSpeakerTestBase(unittest.TestCase):
|
||||
self.r_img = self.dockerimg.create_os_ken(image=image,
|
||||
check_exist=True)
|
||||
self.images.append(self.r_img)
|
||||
self.q_img = 'osrg/quagga'
|
||||
self.images.append(self.q_img)
|
||||
self.frr_img = 'quay.io/frr:9.0.0'
|
||||
self.images.append(self.frr_img)
|
||||
|
||||
self.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512,
|
||||
router_id='192.168.0.1',
|
||||
@ -58,9 +58,9 @@ class BgpSpeakerTestBase(unittest.TestCase):
|
||||
self.r1_ip_cidr = self.brdc1.addif(self.r1)
|
||||
self.r1_ip = self.r1_ip_cidr.split('/')[0]
|
||||
|
||||
self.q1 = quagga.QuaggaBGPContainer(name='q1', asn=64522,
|
||||
router_id='192.168.0.2',
|
||||
ctn_image_name=self.q_img)
|
||||
self.q1 = frr.FRRBGPContainer(name='q1', asn=64522,
|
||||
router_id='192.168.0.2',
|
||||
ctn_image_name=self.frr_img)
|
||||
self.containers.append(self.q1)
|
||||
self.q1.add_route('192.168.160.0/24')
|
||||
self.q1.run(wait=True)
|
||||
|
@ -20,7 +20,7 @@ import unittest
|
||||
|
||||
from os_ken.tests.integrated.common import docker_base as ctn_base
|
||||
from os_ken.tests.integrated.common import oskenbgp
|
||||
from os_ken.tests.integrated.common import quagga
|
||||
from os_ken.tests.integrated.common import frr
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -45,8 +45,8 @@ class BgpSpeakerTestBase(unittest.TestCase):
|
||||
self.r_img = self.dockerimg.create_os_ken(image=image,
|
||||
check_exist=True)
|
||||
self.images.append(self.r_img)
|
||||
self.q_img = 'osrg/quagga'
|
||||
self.images.append(self.q_img)
|
||||
self.frr_img = 'quay.io/frr:9.0.0'
|
||||
self.images.append(self.frr_img)
|
||||
|
||||
self.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512,
|
||||
router_id='192.168.0.1',
|
||||
@ -57,9 +57,9 @@ class BgpSpeakerTestBase(unittest.TestCase):
|
||||
self.r1_ip_cidr = self.brdc1.addif(self.r1)
|
||||
self.r1_ip = self.r1_ip_cidr.split('/')[0]
|
||||
|
||||
self.q1 = quagga.QuaggaBGPContainer(name='q1', asn=64522,
|
||||
router_id='192.168.0.2',
|
||||
ctn_image_name=self.q_img)
|
||||
self.q1 = frr.FRRBGPContainer(name='q1', asn=64522,
|
||||
router_id='192.168.0.2',
|
||||
ctn_image_name=self.frr_img)
|
||||
self.containers.append(self.q1)
|
||||
self.q1.add_route('fc00:100::/64', route_info={'rf': 'ipv6'})
|
||||
self.q1.run(wait=True)
|
||||
|
@ -164,37 +164,6 @@ class DockerImage(object):
|
||||
return tagname
|
||||
self.cmd.sudo("docker rmi -f %s" % tagname, try_times=3)
|
||||
|
||||
def create_quagga(self, tagname='quagga', image=None, check_exist=False):
|
||||
if check_exist and self.exist(tagname):
|
||||
return tagname
|
||||
workdir = os.path.join(TEST_BASE_DIR, tagname)
|
||||
pkges = ' '.join([
|
||||
'telnet',
|
||||
'tcpdump',
|
||||
'quagga-bgpd',
|
||||
])
|
||||
if image:
|
||||
use_image = image
|
||||
else:
|
||||
use_image = self.baseimage
|
||||
c = CmdBuffer()
|
||||
c << 'FROM %s' % use_image
|
||||
c << 'RUN apt-get update'
|
||||
c << 'RUN apt-get install -qy --no-install-recommends %s' % pkges
|
||||
c << 'RUN echo "#!/bin/sh" > /bgpd'
|
||||
c << 'RUN echo mkdir -p /run/quagga >> /bgpd'
|
||||
c << 'RUN echo chmod 755 /run/quagga >> /bgpd'
|
||||
c << 'RUN echo chown quagga:quagga /run/quagga >> /bgpd'
|
||||
c << 'RUN echo exec /usr/sbin/bgpd >> /bgpd'
|
||||
c << 'RUN chmod +x /bgpd'
|
||||
c << 'CMD /bgpd'
|
||||
|
||||
self.cmd.sudo('rm -rf %s' % workdir)
|
||||
self.cmd.execute('mkdir -p %s' % workdir)
|
||||
self.cmd.execute("echo '%s' > %s/Dockerfile" % (str(c), workdir))
|
||||
self.build(tagname, workdir)
|
||||
return tagname
|
||||
|
||||
def create_os_ken(self, tagname='os_ken', image=None, check_exist=False):
|
||||
if check_exist and self.exist(tagname):
|
||||
return tagname
|
||||
|
@ -26,20 +26,19 @@ from . import docker_base as base
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class QuaggaBGPContainer(base.BGPContainer):
|
||||
class FRRBGPContainer(base.BGPContainer):
|
||||
|
||||
WAIT_FOR_BOOT = 1
|
||||
SHARED_VOLUME = '/etc/quagga'
|
||||
SHARED_VOLUME = '/etc/frr'
|
||||
|
||||
def __init__(self, name, asn, router_id, ctn_image_name, zebra=False):
|
||||
super(QuaggaBGPContainer, self).__init__(name, asn, router_id,
|
||||
ctn_image_name)
|
||||
super(FRRBGPContainer, self).__init__(name, asn, router_id,
|
||||
ctn_image_name)
|
||||
self.shared_volumes.append((self.config_dir, self.SHARED_VOLUME))
|
||||
self.zebra = zebra
|
||||
self._create_config_debian()
|
||||
|
||||
def run(self, wait=False, w_time=WAIT_FOR_BOOT):
|
||||
w_time = super(QuaggaBGPContainer,
|
||||
w_time = super(FRRBGPContainer,
|
||||
self).run(wait=wait, w_time=self.WAIT_FOR_BOOT)
|
||||
return w_time
|
||||
|
||||
@ -164,24 +163,6 @@ class QuaggaBGPContainer(base.BGPContainer):
|
||||
self._create_config_zebra()
|
||||
self._create_config_daemons(zebra)
|
||||
|
||||
def _create_config_debian(self):
|
||||
c = base.CmdBuffer()
|
||||
c << 'vtysh_enable=yes'
|
||||
c << 'zebra_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'bgpd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'ospfd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'ospf6d_options=" --daemon -A ::1"'
|
||||
c << 'ripd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'ripngd_options=" --daemon -A ::1"'
|
||||
c << 'isisd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'babeld_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'watchquagga_enable=yes'
|
||||
c << 'watchquagga_options=(--daemon)'
|
||||
with open('{0}/debian.conf'.format(self.config_dir), 'w') as f:
|
||||
LOG.info("[%s's new config]", self.name)
|
||||
LOG.info(str(c))
|
||||
f.writelines(str(c))
|
||||
|
||||
def _create_config_daemons(self, zebra='no'):
|
||||
c = base.CmdBuffer()
|
||||
c << 'zebra=%s' % zebra
|
||||
@ -192,6 +173,15 @@ class QuaggaBGPContainer(base.BGPContainer):
|
||||
c << 'ripngd=no'
|
||||
c << 'isisd=no'
|
||||
c << 'babeld=no'
|
||||
c << 'vtysh_enable=yes'
|
||||
c << 'zebra_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'bgpd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'ospfd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'ospf6d_options=" --daemon -A ::1"'
|
||||
c << 'ripd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'ripngd_options=" --daemon -A ::1"'
|
||||
c << 'isisd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'babeld_options=" --daemon -A 127.0.0.1"'
|
||||
with open('{0}/daemons'.format(self.config_dir), 'w') as f:
|
||||
LOG.info("[%s's new config]", self.name)
|
||||
LOG.info(str(c))
|
||||
@ -259,9 +249,9 @@ class QuaggaBGPContainer(base.BGPContainer):
|
||||
c << 'debug bgp fsm'
|
||||
c << 'debug bgp updates'
|
||||
c << 'debug bgp events'
|
||||
c << 'log file {0}/bgpd.log'.format(self.SHARED_VOLUME)
|
||||
c << 'log file {0}/frr.log'.format(self.SHARED_VOLUME)
|
||||
|
||||
with open('{0}/bgpd.conf'.format(self.config_dir), 'w') as f:
|
||||
with open('{0}/frr.conf'.format(self.config_dir), 'w') as f:
|
||||
LOG.info("[%s's new config]", self.name)
|
||||
LOG.info(str(c))
|
||||
f.writelines(str(c))
|
||||
@ -284,10 +274,10 @@ class QuaggaBGPContainer(base.BGPContainer):
|
||||
def vtysh(self, cmd, config=True):
|
||||
if not isinstance(cmd, list):
|
||||
cmd = [cmd]
|
||||
cmd = ' '.join("-c '{0}'".format(c) for c in cmd)
|
||||
cmd = ' '.join("-C '{0}'".format(c) for c in cmd)
|
||||
if config:
|
||||
return self.exec_on_ctn(
|
||||
"vtysh -d bgpd -c 'en' -c 'conf t' -c "
|
||||
"vtysh -d bgpd -C 'en' -C 'conf t' -C "
|
||||
"'router bgp {0}' {1}".format(self.asn, cmd),
|
||||
capture=True)
|
||||
else:
|
||||
@ -304,7 +294,7 @@ class QuaggaBGPContainer(base.BGPContainer):
|
||||
self.exec_on_ctn(cmd, capture=True)
|
||||
|
||||
|
||||
class RawQuaggaBGPContainer(QuaggaBGPContainer):
|
||||
class RawFRRBGPContainer(FRRBGPContainer):
|
||||
def __init__(self, name, config, ctn_image_name,
|
||||
zebra=False):
|
||||
asn = None
|
||||
@ -316,15 +306,15 @@ class RawQuaggaBGPContainer(QuaggaBGPContainer):
|
||||
if line.startswith('bgp router-id'):
|
||||
router_id = line[len('bgp router-id'):].strip()
|
||||
if not asn:
|
||||
raise Exception('asn not in quagga config')
|
||||
raise Exception('asn not in FRR config')
|
||||
if not router_id:
|
||||
raise Exception('router-id not in quagga config')
|
||||
raise Exception('router-id not in FRR config')
|
||||
self.config = config
|
||||
super(RawQuaggaBGPContainer, self).__init__(name, asn, router_id,
|
||||
ctn_image_name, zebra)
|
||||
super(RawFRRBGPContainer, self).__init__(name, asn, router_id,
|
||||
ctn_image_name, zebra)
|
||||
|
||||
def create_config(self):
|
||||
with open(os.path.join(self.config_dir, 'bgpd.conf'), 'w') as f:
|
||||
with open(os.path.join(self.config_dir, 'frr.conf'), 'w') as f:
|
||||
LOG.info("[%s's new config]", self.name)
|
||||
LOG.info(self.config)
|
||||
f.writelines(self.config)
|
Loading…
Reference in New Issue
Block a user