Revert "Use FRR instead of Quagga when testing"

This reverts commit 04be5a3949.

Reason for revert: the FRR implementation is still not working. In
order to provide a transition to this new implementation, both
FRR and Quagga containers should be provided by this repository,
making configurable which one should be used.

Change-Id: Ie5fdadbc640c331b7e47fda686a7f43c16a4504a
Related-Bug: #2088285
This commit is contained in:
Rodolfo Alonso 2024-11-18 11:57:52 +00:00 committed by Gerrit Code Review
parent 04be5a3949
commit e7e1648efd
4 changed files with 77 additions and 36 deletions

View File

@ -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 docker_base as ctn_base
from os_ken.tests.integrated.common import oskenbgp from os_ken.tests.integrated.common import oskenbgp
from os_ken.tests.integrated.common import frr from os_ken.tests.integrated.common import quagga
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -46,8 +46,8 @@ class BgpSpeakerTestBase(unittest.TestCase):
self.r_img = self.dockerimg.create_os_ken(image=image, self.r_img = self.dockerimg.create_os_ken(image=image,
check_exist=True) check_exist=True)
self.images.append(self.r_img) self.images.append(self.r_img)
self.frr_img = 'quay.io/frr:9.0.0' self.q_img = 'osrg/quagga'
self.images.append(self.frr_img) self.images.append(self.q_img)
self.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512, self.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512,
router_id='192.168.0.1', 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_cidr = self.brdc1.addif(self.r1)
self.r1_ip = self.r1_ip_cidr.split('/')[0] self.r1_ip = self.r1_ip_cidr.split('/')[0]
self.q1 = frr.FRRBGPContainer(name='q1', asn=64522, self.q1 = quagga.QuaggaBGPContainer(name='q1', asn=64522,
router_id='192.168.0.2', router_id='192.168.0.2',
ctn_image_name=self.frr_img) ctn_image_name=self.q_img)
self.containers.append(self.q1) self.containers.append(self.q1)
self.q1.add_route('192.168.160.0/24') self.q1.add_route('192.168.160.0/24')
self.q1.run(wait=True) self.q1.run(wait=True)

View File

@ -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 docker_base as ctn_base
from os_ken.tests.integrated.common import oskenbgp from os_ken.tests.integrated.common import oskenbgp
from os_ken.tests.integrated.common import frr from os_ken.tests.integrated.common import quagga
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -45,8 +45,8 @@ class BgpSpeakerTestBase(unittest.TestCase):
self.r_img = self.dockerimg.create_os_ken(image=image, self.r_img = self.dockerimg.create_os_ken(image=image,
check_exist=True) check_exist=True)
self.images.append(self.r_img) self.images.append(self.r_img)
self.frr_img = 'quay.io/frr:9.0.0' self.q_img = 'osrg/quagga'
self.images.append(self.frr_img) self.images.append(self.q_img)
self.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512, self.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512,
router_id='192.168.0.1', 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_cidr = self.brdc1.addif(self.r1)
self.r1_ip = self.r1_ip_cidr.split('/')[0] self.r1_ip = self.r1_ip_cidr.split('/')[0]
self.q1 = frr.FRRBGPContainer(name='q1', asn=64522, self.q1 = quagga.QuaggaBGPContainer(name='q1', asn=64522,
router_id='192.168.0.2', router_id='192.168.0.2',
ctn_image_name=self.frr_img) ctn_image_name=self.q_img)
self.containers.append(self.q1) self.containers.append(self.q1)
self.q1.add_route('fc00:100::/64', route_info={'rf': 'ipv6'}) self.q1.add_route('fc00:100::/64', route_info={'rf': 'ipv6'})
self.q1.run(wait=True) self.q1.run(wait=True)

View File

@ -164,6 +164,37 @@ class DockerImage(object):
return tagname return tagname
self.cmd.sudo("docker rmi -f %s" % tagname, try_times=3) 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): def create_os_ken(self, tagname='os_ken', image=None, check_exist=False):
if check_exist and self.exist(tagname): if check_exist and self.exist(tagname):
return tagname return tagname

View File

@ -26,19 +26,20 @@ from . import docker_base as base
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class FRRBGPContainer(base.BGPContainer): class QuaggaBGPContainer(base.BGPContainer):
WAIT_FOR_BOOT = 1 WAIT_FOR_BOOT = 1
SHARED_VOLUME = '/etc/frr' SHARED_VOLUME = '/etc/quagga'
def __init__(self, name, asn, router_id, ctn_image_name, zebra=False): def __init__(self, name, asn, router_id, ctn_image_name, zebra=False):
super(FRRBGPContainer, self).__init__(name, asn, router_id, super(QuaggaBGPContainer, self).__init__(name, asn, router_id,
ctn_image_name) ctn_image_name)
self.shared_volumes.append((self.config_dir, self.SHARED_VOLUME)) self.shared_volumes.append((self.config_dir, self.SHARED_VOLUME))
self.zebra = zebra self.zebra = zebra
self._create_config_debian()
def run(self, wait=False, w_time=WAIT_FOR_BOOT): def run(self, wait=False, w_time=WAIT_FOR_BOOT):
w_time = super(FRRBGPContainer, w_time = super(QuaggaBGPContainer,
self).run(wait=wait, w_time=self.WAIT_FOR_BOOT) self).run(wait=wait, w_time=self.WAIT_FOR_BOOT)
return w_time return w_time
@ -163,6 +164,24 @@ class FRRBGPContainer(base.BGPContainer):
self._create_config_zebra() self._create_config_zebra()
self._create_config_daemons(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'): def _create_config_daemons(self, zebra='no'):
c = base.CmdBuffer() c = base.CmdBuffer()
c << 'zebra=%s' % zebra c << 'zebra=%s' % zebra
@ -173,15 +192,6 @@ class FRRBGPContainer(base.BGPContainer):
c << 'ripngd=no' c << 'ripngd=no'
c << 'isisd=no' c << 'isisd=no'
c << 'babeld=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: with open('{0}/daemons'.format(self.config_dir), 'w') as f:
LOG.info("[%s's new config]", self.name) LOG.info("[%s's new config]", self.name)
LOG.info(str(c)) LOG.info(str(c))
@ -249,9 +259,9 @@ class FRRBGPContainer(base.BGPContainer):
c << 'debug bgp fsm' c << 'debug bgp fsm'
c << 'debug bgp updates' c << 'debug bgp updates'
c << 'debug bgp events' c << 'debug bgp events'
c << 'log file {0}/frr.log'.format(self.SHARED_VOLUME) c << 'log file {0}/bgpd.log'.format(self.SHARED_VOLUME)
with open('{0}/frr.conf'.format(self.config_dir), 'w') as f: with open('{0}/bgpd.conf'.format(self.config_dir), 'w') as f:
LOG.info("[%s's new config]", self.name) LOG.info("[%s's new config]", self.name)
LOG.info(str(c)) LOG.info(str(c))
f.writelines(str(c)) f.writelines(str(c))
@ -274,10 +284,10 @@ class FRRBGPContainer(base.BGPContainer):
def vtysh(self, cmd, config=True): def vtysh(self, cmd, config=True):
if not isinstance(cmd, list): if not isinstance(cmd, list):
cmd = [cmd] cmd = [cmd]
cmd = ' '.join("-C '{0}'".format(c) for c in cmd) cmd = ' '.join("-c '{0}'".format(c) for c in cmd)
if config: if config:
return self.exec_on_ctn( 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), "'router bgp {0}' {1}".format(self.asn, cmd),
capture=True) capture=True)
else: else:
@ -294,7 +304,7 @@ class FRRBGPContainer(base.BGPContainer):
self.exec_on_ctn(cmd, capture=True) self.exec_on_ctn(cmd, capture=True)
class RawFRRBGPContainer(FRRBGPContainer): class RawQuaggaBGPContainer(QuaggaBGPContainer):
def __init__(self, name, config, ctn_image_name, def __init__(self, name, config, ctn_image_name,
zebra=False): zebra=False):
asn = None asn = None
@ -306,15 +316,15 @@ class RawFRRBGPContainer(FRRBGPContainer):
if line.startswith('bgp router-id'): if line.startswith('bgp router-id'):
router_id = line[len('bgp router-id'):].strip() router_id = line[len('bgp router-id'):].strip()
if not asn: if not asn:
raise Exception('asn not in FRR config') raise Exception('asn not in quagga config')
if not router_id: if not router_id:
raise Exception('router-id not in FRR config') raise Exception('router-id not in quagga config')
self.config = config self.config = config
super(RawFRRBGPContainer, self).__init__(name, asn, router_id, super(RawQuaggaBGPContainer, self).__init__(name, asn, router_id,
ctn_image_name, zebra) ctn_image_name, zebra)
def create_config(self): def create_config(self):
with open(os.path.join(self.config_dir, 'frr.conf'), 'w') as f: with open(os.path.join(self.config_dir, 'bgpd.conf'), 'w') as f:
LOG.info("[%s's new config]", self.name) LOG.info("[%s's new config]", self.name)
LOG.info(self.config) LOG.info(self.config)
f.writelines(self.config) f.writelines(self.config)