Add test for RHEL-76401

This commit is contained in:
František Hrdina 2025-01-28 15:30:16 +01:00
commit 1cffbc6db0
10 changed files with 536 additions and 0 deletions

View file

@ -0,0 +1,121 @@
# This file tells the frr package which daemons to start.
#
# Sample configurations for these daemons can be found in
# /usr/share/doc/frr/examples/.
#
# ATTENTION:
#
# When activating a daemon for the first time, a config file, even if it is
# empty, has to be present *and* be owned by the user and group "frr", else
# the daemon will not be started by /etc/init.d/frr. The permissions should
# be u=rw,g=r,o=.
# When using "vtysh" such a config file is also needed. It should be owned by
# group "frrvty" and set to ug=rw,o= though. Check /etc/pam.d/frr, too.
#
# The watchfrr, zebra and staticd daemons are always started.
#
bgpd=yes
ospfd=no
ospf6d=no
ripd=no
ripngd=no
isisd=no
pimd=no
pim6d=no
nhrpd=no
eigrpd=no
sharpd=no
pbrd=no
bfdd=yes
fabricd=no
vrrpd=no
pathd=no
#
# If this option is set the /etc/init.d/frr script automatically loads
# the config via "vtysh -b" when the servers are started.
# Check /etc/pam.d/frr if you intend to use "vtysh"!
#
vtysh_enable=yes
zebra_options=" -A 127.0.0.1 -s 90000000"
bgpd_options=" -A 127.0.0.1"
ospfd_options=" -A 127.0.0.1"
ospf6d_options=" -A ::1"
ripd_options=" -A 127.0.0.1"
ripngd_options=" -A ::1"
isisd_options=" -A 127.0.0.1"
pimd_options=" -A 127.0.0.1"
pim6d_options=" -A ::1"
nhrpd_options=" -A 127.0.0.1"
eigrpd_options=" -A 127.0.0.1"
sharpd_options=" -A 127.0.0.1"
pbrd_options=" -A 127.0.0.1"
staticd_options="-A 127.0.0.1"
bfdd_options=" -A 127.0.0.1"
fabricd_options="-A 127.0.0.1"
vrrpd_options=" -A 127.0.0.1"
pathd_options=" -A 127.0.0.1"
# If you want to pass a common option to all daemons, you can use the
# "frr_global_options" variable.
#
#frr_global_options=""
# The list of daemons to watch is automatically generated by the init script.
# This variable can be used to pass options to watchfrr that will be passed
# prior to the daemon list.
#
# To make watchfrr create/join the specified netns, add the the "--netns"
# option here. It will only have an effect in /etc/frr/<somename>/daemons, and
# you need to start FRR with "/usr/lib/frr/frrinit.sh start <somename>".
#
watchfrr_options="--netns=vnc"
# configuration profile
#
#frr_profile="traditional"
#frr_profile="datacenter"
# This is the maximum number of FD's that will be available. Upon startup this
# is read by the control files and ulimit is called. Uncomment and use a
# reasonable value for your setup if you are expecting a large number of peers
# in say BGP.
#
#MAX_FDS=1024
# Uncomment this option if you want to run FRR as a non-root user. Note that
# you should know what you are doing since most of the daemons need root
# to work. This could be useful if you want to run FRR in a container
# for instance.
# FRR_NO_ROOT="yes"
# For any daemon, you can specify a "wrap" command to start instead of starting
# the daemon directly. This will simply be prepended to the daemon invocation.
# These variables have the form daemon_wrap, where 'daemon' is the name of the
# daemon (the same pattern as the daemon_options variables).
#
# Note that when daemons are started, they are told to daemonize with the `-d`
# option. This has several implications. For one, the init script expects that
# when it invokes a daemon, the invocation returns immediately. If you add a
# wrap command here, it must comply with this expectation and daemonize as
# well, or the init script will never return. Furthermore, because daemons are
# themselves daemonized with -d, you must ensure that your wrapper command is
# capable of following child processes after a fork() if you need it to do so.
#
# If your desired wrapper does not support daemonization, you can wrap it with
# a utility program that daemonizes programs, such as 'daemonize'. An example
# of this might look like:
#
# bgpd_wrap="/usr/bin/daemonize /usr/bin/mywrapper"
#
# This is particularly useful for programs which record processes but lack
# daemonization options, such as perf and rr.
#
# If you wish to wrap all daemons in the same way, you may set the "all_wrap"
# variable.
#
#all_wrap=""

View file

@ -0,0 +1,121 @@
# This file tells the frr package which daemons to start.
#
# Sample configurations for these daemons can be found in
# /usr/share/doc/frr/examples/.
#
# ATTENTION:
#
# When activating a daemon for the first time, a config file, even if it is
# empty, has to be present *and* be owned by the user and group "frr", else
# the daemon will not be started by /etc/init.d/frr. The permissions should
# be u=rw,g=r,o=.
# When using "vtysh" such a config file is also needed. It should be owned by
# group "frrvty" and set to ug=rw,o= though. Check /etc/pam.d/frr, too.
#
# The watchfrr, zebra and staticd daemons are always started.
#
bgpd=yes
ospfd=no
ospf6d=no
ripd=no
ripngd=no
isisd=no
pimd=no
pim6d=no
nhrpd=no
eigrpd=no
sharpd=no
pbrd=no
bfdd=yes
fabricd=no
vrrpd=no
pathd=no
#
# If this option is set the /etc/init.d/frr script automatically loads
# the config via "vtysh -b" when the servers are started.
# Check /etc/pam.d/frr if you intend to use "vtysh"!
#
vtysh_enable=yes
zebra_options=" -A 127.0.0.1 -s 90000000"
bgpd_options=" -A 127.0.0.1"
ospfd_options=" -A 127.0.0.1"
ospf6d_options=" -A ::1"
ripd_options=" -A 127.0.0.1"
ripngd_options=" -A ::1"
isisd_options=" -A 127.0.0.1"
pimd_options=" -A 127.0.0.1"
pim6d_options=" -A ::1"
nhrpd_options=" -A 127.0.0.1"
eigrpd_options=" -A 127.0.0.1"
sharpd_options=" -A 127.0.0.1"
pbrd_options=" -A 127.0.0.1"
staticd_options="-A 127.0.0.1"
bfdd_options=" -A 127.0.0.1"
fabricd_options="-A 127.0.0.1"
vrrpd_options=" -A 127.0.0.1"
pathd_options=" -A 127.0.0.1"
# If you want to pass a common option to all daemons, you can use the
# "frr_global_options" variable.
#
#frr_global_options=""
# The list of daemons to watch is automatically generated by the init script.
# This variable can be used to pass options to watchfrr that will be passed
# prior to the daemon list.
#
# To make watchfrr create/join the specified netns, add the the "--netns"
# option here. It will only have an effect in /etc/frr/<somename>/daemons, and
# you need to start FRR with "/usr/lib/frr/frrinit.sh start <somename>".
#
watchfrr_options="--netns=vns"
# configuration profile
#
#frr_profile="traditional"
#frr_profile="datacenter"
# This is the maximum number of FD's that will be available. Upon startup this
# is read by the control files and ulimit is called. Uncomment and use a
# reasonable value for your setup if you are expecting a large number of peers
# in say BGP.
#
#MAX_FDS=1024
# Uncomment this option if you want to run FRR as a non-root user. Note that
# you should know what you are doing since most of the daemons need root
# to work. This could be useful if you want to run FRR in a container
# for instance.
# FRR_NO_ROOT="yes"
# For any daemon, you can specify a "wrap" command to start instead of starting
# the daemon directly. This will simply be prepended to the daemon invocation.
# These variables have the form daemon_wrap, where 'daemon' is the name of the
# daemon (the same pattern as the daemon_options variables).
#
# Note that when daemons are started, they are told to daemonize with the `-d`
# option. This has several implications. For one, the init script expects that
# when it invokes a daemon, the invocation returns immediately. If you add a
# wrap command here, it must comply with this expectation and daemonize as
# well, or the init script will never return. Furthermore, because daemons are
# themselves daemonized with -d, you must ensure that your wrapper command is
# capable of following child processes after a fork() if you need it to do so.
#
# If your desired wrapper does not support daemonization, you can wrap it with
# a utility program that daemonizes programs, such as 'daemonize'. An example
# of this might look like:
#
# bgpd_wrap="/usr/bin/daemonize /usr/bin/mywrapper"
#
# This is particularly useful for programs which record processes but lack
# daemonization options, such as perf and rr.
#
# If you wish to wrap all daemons in the same way, you may set the "all_wrap"
# variable.
#
#all_wrap=""

View file

@ -0,0 +1,31 @@
hostname RouterVNC
!
log file <CLIENT_FRR_LOG> debugging
!
debug bgp keepalives
debug bgp neighbor-events
debug bgp nht
debug bgp updates in
debug bgp updates out
debug bgp zebra
debug bgp bfd
debug bfd distributed
debug bfd peer
debug bfd zebra
debug bfd network
!
router bgp <CLIENT_BGP_AS>
bgp router-id <CLIENT_IF_ADDR>
no bgp ebgp-requires-policy
neighbor <SERVER_IF_ADDR> remote-as <SERVER_BGP_AS>
neighbor <SERVER_IF_ADDR> bfd
exit
!
bfd
peer <SERVER_IF_ADDR>
exit
!
exit
line vty
!
exit

View file

@ -0,0 +1,23 @@
[Unit]
Description=FRRouting
Documentation=https://frrouting.readthedocs.io/en/latest/setup.html
Wants=network.target
After=network-pre.target systemd-sysctl.service
Before=network.target
OnFailure=heartbeat-failed@%n.service
[Service]
Nice=-5
Type=forking
NotifyAccess=all
StartLimitInterval=3m
StartLimitBurst=3
TimeoutSec=2m
WatchdogSec=60s
RestartSec=5
Restart=on-abnormal
LimitNOFILE=1024
ExecStart=/sbin/ip netns exec vnc /usr/libexec/frr/frrinit.sh start vnc
ExecStop=/sbin/ip netns exec vnc /usr/libexec/frr/frrinit.sh stop vnc
ExecReload=/sbin/ip netns exec vnc /usr/libexec/frr/frrinit.sh reload vnc
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,33 @@
hostname RouterVNS
log file <SERVER_FRR_LOG>
log timestamp precision 3
no ipv6 forwarding
service integrated-vtysh-config
!
debug bgp keepalives
debug bgp neighbor-events
debug bgp nht
debug bgp updates in
debug bgp updates out
debug bgp zebra
debug bgp bfd
debug bfd distributed
debug bfd peer
debug bfd zebra
debug bfd network
!
router bgp <SERVER_BGP_AS>
bgp router-id <SERVER_IF_ADDR>
no bgp ebgp-requires-policy
neighbor <CLIENT_IF_ADDR> remote-as <CLIENT_BGP_AS>
neighbor <CLIENT_IF_ADDR> bfd profile foo
exit
!
bfd
peer <CLIENT_IF_ADDR>
exit
!
exit
line vty
!
exit

View file

@ -0,0 +1,23 @@
[Unit]
Description=FRRouting
Documentation=https://frrouting.readthedocs.io/en/latest/setup.html
Wants=network.target
After=network-pre.target systemd-sysctl.service
Before=network.target
OnFailure=heartbeat-failed@%n.service
[Service]
Nice=-5
Type=forking
NotifyAccess=all
StartLimitInterval=3m
StartLimitBurst=3
TimeoutSec=2m
WatchdogSec=60s
RestartSec=5
Restart=on-abnormal
LimitNOFILE=1024
ExecStart=/sbin/ip netns exec vns /usr/libexec/frr/frrinit.sh start vns
ExecStop=/sbin/ip netns exec vns /usr/libexec/frr/frrinit.sh stop vns
ExecReload=/sbin/ip netns exec vns /usr/libexec/frr/frrinit.sh reload vns
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,30 @@
summary: Test summary
description: ''
contact: Frantisek Hrdina <fhrdina@redhat.com>
component:
- frr
test: ./test.sh
framework: beakerlib
recommend:
- frr
require:
- library(virtual-network/virtual-network)
duration: 10m
enabled: true
tag:
- Tier1
tier: '1'
link:
- verifies: https://issues.redhat.com/browse/RHEL-76401
environment:
AVC_ERROR: +no_avc_check
adjust:
- enabled: false
when: distro < rhel-9.6
continue: false
- enabled: false
when: distro < rhel-10.0
continue: false
- enabled: false
when: distro < centos-stream-9
continue: false

View file

@ -0,0 +1,152 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="frr"
SERVER_CLIENT_IF_ADDR="192.168.222.0"
SERVER_CLIENT_IF_PREFIX="24"
SERVER_IF_ADDR="192.168.222.1"
SERVER_IF_PREFIX="24"
SERVER_IF_BCAST="192.168.222.255"
SERVER_BGP_AS="65000"
SERVER_FRR_LOG="/var/log/frr/frr-r1.log"
SERVER_CONF_DIR="/etc/frr/vns/"
CLIENT_IF_ADDR="192.168.222.2"
CLIENT_IF_PREFIX="24"
CLIENT_IF_BCAST="192.168.222.255"
CLIENT_BGP_AS="65001"
CLIENT_FRR_LOG="/var/log/frr/frr-r2.log"
CLIENT_CONF_DIR="/etc/frr/vnc/"
MAIN_LOG="/tmp/log_routes"
rlJournalStart
rlPhaseStartSetup "import virtual-network library"
rlRun "rlImport virtual-network/virtual-network" || rlDie "Import of the library required for the test failed"
rlPhaseEnd
rlPhaseStartSetup
rlAssertRpm $PACKAGE
TestDir=$(pwd)
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
rlRun "pushd $tmp"
# Need to disable SeLinux, because it does not allow to start service via unit file
# in a network namespace using "ip netns exec". And there are other issues with pid files, log files, etc.
rlRun "setenforce 0" 0 "Disabling SELinux"
rlRun "ORIG_AVC_ERROR=${AVC_ERROR}"
rlRun "AVC_ERROR=+no_avc_check"
# set up the network, we want a specific IPv4 address for neighbor communication and two IPv6 addresses
# for the set src part of the configuration
vnCreateServerClientNetwork
vnRunServer "ip link set ${vnSERVER_IFACE} up" 0 "Setting the SERVER side of veth UP"
vnRunServer "ip link set lo up" 0 "Setting the SERVER side loopback UP"
vnRunClient "ip link set ${vnCLIENT_IFACE} up" 0 "Setting the CLIENT side of veth UP"
vnRunClient "ip link set lo up" 0 "Setting the CLIENT side loopback UP"
vnRunServer "ip addr add ${SERVER_IF_ADDR}/${SERVER_IF_PREFIX} broadcast ${SERVER_IF_BCAST} dev ${vnSERVER_IFACE}" 0 "Configuring IPv4 address on SERVER side of veth"
vnRunClient "ip addr add ${CLIENT_IF_ADDR}/${CLIENT_IF_PREFIX} broadcast ${CLIENT_IF_BCAST} dev ${vnCLIENT_IFACE}" 0 "Configuring IPv4 address on CLIENT side of veth"
rlRun "ip a"
vnRunClient "ip a"
vnRunServer "ip a"
rlRun "rlFileBackup --clean /etc/frr/"
rlRun "rlFileBackup --clean /etc/systemd/system/"
rlRun "rlFileBackup --clean /var/log/frr/"
rlRun "rlFileBackup --clean /var/log/audit/audit.log"
rlRun "rlFileBackup --clean /var/run/frr"
rlRun "rlFileBackup --clean /run/frr"
rlRun "rlFileBackup --clean /root/.history_frr"
rlRun "mkdir /etc/frr/{vns,vnc}"
rm -rf /etc/frr/frr.conf
#vtysh.conf and frr.conf are in /etc/frr/vns for the server namespace
rlRun "cp -f $TestDir/vtysh-vns.conf ${SERVER_CONF_DIR}vtysh.conf" 0 "Copying vtysh configuration for the SERVER"
rlRun "cp -f $TestDir/frr-vns.conf ${SERVER_CONF_DIR}frr.conf" 0 "Copying frr configuration for the SERVER"
#vtysh.conf and frr.conf are in /etc/frr/vnc for the client namespace
rlRun "cp -f $TestDir/vtysh-vnc.conf ${CLIENT_CONF_DIR}vtysh.conf" 0 "Copying vtysh configuration for the CLIENT"
rlRun "cp -f $TestDir/frr-vnc.conf ${CLIENT_CONF_DIR}frr.conf" 0 "Copying frr configuration for the CLIENT"
#I need separate daemons files as well for watchfrr options
rlRun "cp -f $TestDir/daemons-vns ${SERVER_CONF_DIR}daemons" 0 "Copying daemons file for the SERVER"
rlRun "cp -f $TestDir/daemons-vnc ${CLIENT_CONF_DIR}daemons" 0 "Copying daemons file for the CLIENT"
rlRun "ls -lR /etc/frr/*"
rlRun "cp -f $TestDir/frr-vn{s,c}.service /etc/systemd/system/" 0 "Copying custom unit files to run frr in network namespaces"
# /etc/frr/vns/frr.conf
rlRun "sed -i 's|<SERVER_FRR_LOG>|${SERVER_FRR_LOG}|g' ${SERVER_CONF_DIR}frr.conf"
rlRun "sed -i 's|<SERVER_IF_ADDR>|${SERVER_IF_ADDR}|g' ${SERVER_CONF_DIR}frr.conf"
rlRun "sed -i 's|<CLIENT_IF_ADDR>|${CLIENT_IF_ADDR}|g' ${SERVER_CONF_DIR}frr.conf"
rlRun "sed -i 's|<SERVER_BGP_AS>|${SERVER_BGP_AS}|g' ${SERVER_CONF_DIR}frr.conf"
rlRun "sed -i 's|<CLIENT_BGP_AS>|${CLIENT_BGP_AS}|g' ${SERVER_CONF_DIR}frr.conf"
rlRun "cat ${SERVER_CONF_DIR}frr.conf"
# /etc/frr/vnc/frr.conf
rlRun "sed -i 's|<CLIENT_FRR_LOG>|${CLIENT_FRR_LOG}|g' ${CLIENT_CONF_DIR}frr.conf"
rlRun "sed -i 's|<CLIENT_IF_ADDR>|${CLIENT_IF_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf"
rlRun "sed -i 's|<SERVER_IF_ADDR>|${SERVER_IF_ADDR}|g' ${CLIENT_CONF_DIR}frr.conf"
rlRun "sed -i 's|<CLIENT_BGP_AS>|${CLIENT_BGP_AS}|g' ${CLIENT_CONF_DIR}frr.conf"
rlRun "sed -i 's|<SERVER_BGP_AS>|${SERVER_BGP_AS}|g' ${CLIENT_CONF_DIR}frr.conf"
rlRun "cat ${CLIENT_CONF_DIR}frr.conf"
rlRun "systemctl daemon-reload"
rlPhaseEnd
rlPhaseStartTest
rlRun "systemctl start frr-vns.service" 0 "Starting FRR on SERVER side"
rlRun "systemctl start frr-vnc.service" 0 "Starting FRR on CLIENT side"
#vtysh also needs to run for a specific namespace
rlRun "vtysh -N vns -c 'sh run'"
rlRun "vtysh -N vnc -c 'sh run'"
# Check that BGP was established
rlRun "sleep 5m" 0 "Waiting for peers to exchange routes and converge"
rlRun "vtysh -N vns -c 'show bgp neighbors' &> show-bgp-neighbors.log"
rlAssertGrep "BGP state = Established" show-bgp-neighbors.log
# The shutdown of BFD should set BGP's status to idle.
rlRun "vtysh -N vns -c 'conf t' -c 'bfd' -c 'profile foo' -c 'shutdown'"
sleep 5s
rlRun "vtysh -N vns -c 'show bgp neighbors' &> show-bgp-neighbors.log"
rlAssertNotGrep "BGP state = Established" show-bgp-neighbors.log
rlAssertGrep "BGP state = Idle" show-bgp-neighbors.log
rlPhaseEnd
rlPhaseStartCleanup
rlRun "systemctl stop frr-vns.service frr-vnc.service" 0 "Stopping FRR"
vnRemoveServerClientNetwork
rlFileRestore
rlRun "systemctl daemon-reload"
# restoring SELinux
rlRun "setenforce 1" 0 "re-Enabling SELinux"
rlRun "AVC_ERROR=${ORIG_AVC_ERROR}"
# This should prevent propagating AVCs to the tests, that are following
rlRun "fixfiles restore"
rlRun "restorecon -R -v /"
rlRun "popd"
rlRun "rm -r $tmp" 0 "Remove tmp directory"
rlPhaseEnd
rlJournalEnd

View file

@ -0,0 +1 @@
service integrated-vtysh-config

View file

@ -0,0 +1 @@
service integrated-vtysh-config