summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/topotests/Dockerfile138
-rw-r--r--tests/topotests/bgp_max_med_on_startup/r1/bgpd.conf2
-rw-r--r--tests/topotests/bgp_max_med_on_startup/test_bgp_max_med_on_startup.py4
-rw-r--r--tests/topotests/bgp_peer_group/r1/bgpd.conf12
-rw-r--r--tests/topotests/bgp_peer_group/r1/frr.conf21
-rw-r--r--tests/topotests/bgp_peer_group/r1/zebra.conf9
-rw-r--r--tests/topotests/bgp_peer_group/r2/bgpd.conf11
-rw-r--r--tests/topotests/bgp_peer_group/r2/frr.conf19
-rw-r--r--tests/topotests/bgp_peer_group/r2/zebra.conf9
-rw-r--r--tests/topotests/bgp_peer_group/r3/frr.conf (renamed from tests/topotests/bgp_peer_group/r3/bgpd.conf)5
-rw-r--r--tests/topotests/bgp_peer_group/r3/zebra.conf6
-rw-r--r--tests/topotests/bgp_peer_group/test_bgp_peer-group.py41
-rw-r--r--tests/topotests/docker/README.md2
-rwxr-xr-xtests/topotests/docker/frr-topotests.sh7
-rwxr-xr-xtests/topotests/docker/inner/compile_frr.sh5
-rwxr-xr-xtests/topotests/docker/inner/entrypoint.sh5
-rw-r--r--tests/topotests/isis_topo1/test_isis_topo1.py161
-rw-r--r--tests/topotests/ospfapi/test_ospf_clientapi.py2
18 files changed, 332 insertions, 127 deletions
diff --git a/tests/topotests/Dockerfile b/tests/topotests/Dockerfile
index 1503e67d31..d55827fe6c 100644
--- a/tests/topotests/Dockerfile
+++ b/tests/topotests/Dockerfile
@@ -1,60 +1,98 @@
-FROM ubuntu:18.04
+FROM ubuntu:22.04
-RUN export DEBIAN_FRONTEND=noninteractive \
- && apt-get update \
- && apt-get install -y \
- autoconf \
- binutils \
- bison \
- ca-certificates \
- flex \
+ARG DEBIAN_FRONTEND=noninteractive
+ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
+
+RUN apt update -y && apt upgrade -y && \
+ # Basic build requirements from documentation
+ apt-get install -y \
+ autoconf \
+ automake \
+ bison \
+ build-essential \
+ flex \
+ git \
+ install-info \
+ libc-ares-dev \
+ libcap-dev \
+ libelf-dev \
+ libjson-c-dev \
+ libpam0g-dev \
+ libreadline-dev \
+ libsnmp-dev \
+ libsqlite3-dev \
+ lsb-release \
+ libtool \
+ lcov \
+ make \
+ perl \
+ pkg-config \
+ python3-dev \
+ python3-sphinx \
+ screen \
+ texinfo \
+ tmux \
+ && \
+ # Protobuf build requirements
+ apt-get install -y \
+ libprotobuf-c-dev \
+ protobuf-c-compiler \
+ && \
+ # Libyang2 extra build requirements
+ apt-get install -y \
+ cmake \
+ libpcre2-dev \
+ && \
+ # GRPC extra build requirements
+ apt-get install -y \
+ libgrpc-dev \
+ libgrpc++-dev \
+ protobuf-compiler-grpc \
+ && \
+ # Runtime/triage/testing requirements
+ apt-get install -y \
+ rsync \
+ curl \
gdb \
- git \
- gpg \
- install-info \
- iputils-ping \
+ kmod \
iproute2 \
- less \
- libtool \
- libjson-c-dev \
- libpcre3-dev \
- libpython-dev \
- libpython3-dev \
- libreadline-dev \
- libc-ares-dev \
- libcap-dev \
- libelf-dev \
- man \
- mininet \
- pkg-config \
- python-pip \
+ iputils-ping \
+ liblua5.3-dev \
+ libssl-dev \
+ lua5.3 \
+ net-tools \
python3 \
- python3-dev \
- python3-sphinx \
- python3-pytest \
- rsync \
+ python3-pip \
+ snmp \
+ snmp-mibs-downloader \
+ snmpd \
+ sudo \
+ time \
+ tshark \
+ valgrind \
+ yodl \
strace \
tcpdump \
- texinfo \
- tmux \
- valgrind \
- vim \
- wget \
- x11-xserver-utils \
- xterm \
- && pip install \
- exabgp==3.4.17 \
- "scapy>=2.4.2" \
- ipaddr \
- pytest \
- && rm -rf /var/lib/apt/lists/*
+ && \
+ download-mibs && \
+ wget https://raw.githubusercontent.com/FRRouting/frr-mibs/main/iana/IANA-IPPM-METRICS-REGISTRY-MIB -O /usr/share/snmp/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB && \
+ wget https://raw.githubusercontent.com/FRRouting/frr-mibs/main/ietf/SNMPv2-PDU -O /usr/share/snmp/mibs/ietf/SNMPv2-PDU && \
+ wget https://raw.githubusercontent.com/FRRouting/frr-mibs/main/ietf/IPATM-IPMC-MIB -O /usr/share/snmp/mibs/ietf/IPATM-IPMC-MIB && \
+ python3 -m pip install wheel && \
+ python3 -m pip install 'protobuf<4' grpcio grpcio-tools && \
+ python3 -m pip install 'pytest>=6.2.4' 'pytest-xdist>=2.3.0' && \
+ python3 -m pip install 'scapy>=2.4.5' && \
+ python3 -m pip install xmltodict && \
+ python3 -m pip install git+https://github.com/Exa-Networks/exabgp@0659057837cd6c6351579e9f0fa47e9fb7de7311
+
+# Install FRR built packages
+RUN mkdir -p /etc/apt/keyrings && \
+ curl -s -o /etc/apt/keyrings/frrouting.gpg https://deb.frrouting.org/frr/keys.gpg && \
+ echo deb '[signed-by=/etc/apt/keyrings/frrouting.gpg]' https://deb.frrouting.org/frr \
+ $(lsb_release -s -c) "frr-stable" > /etc/apt/sources.list.d/frr.list && \
+ apt-get update && apt-get install -y librtr-dev libyang2-dev libyang2-tools
-RUN export DEBIAN_FRONTEND=noninteractive \
- && wget -qO- https://deb.frrouting.org/frr/keys.asc | apt-key add - \
- && echo "deb https://deb.frrouting.org/frr bionic frr-stable" > /etc/apt/sources.list.d/frr.list \
- && apt-get update \
- && apt-get install -y libyang-dev \
- && rm -rf /var/lib/apt/lists/*
+RUN apt install -y openvswitch-switch
RUN groupadd -r -g 92 frr \
&& groupadd -r -g 85 frrvty \
diff --git a/tests/topotests/bgp_max_med_on_startup/r1/bgpd.conf b/tests/topotests/bgp_max_med_on_startup/r1/bgpd.conf
index 41bf96344a..14f90b859d 100644
--- a/tests/topotests/bgp_max_med_on_startup/r1/bgpd.conf
+++ b/tests/topotests/bgp_max_med_on_startup/r1/bgpd.conf
@@ -1,6 +1,6 @@
!
router bgp 65001
- bgp max-med on-startup 5 777
+ bgp max-med on-startup 30 777
no bgp ebgp-requires-policy
neighbor 192.168.255.2 remote-as 65001
neighbor 192.168.255.2 timers 3 10
diff --git a/tests/topotests/bgp_max_med_on_startup/test_bgp_max_med_on_startup.py b/tests/topotests/bgp_max_med_on_startup/test_bgp_max_med_on_startup.py
index 545d7bd245..12ec88249a 100644
--- a/tests/topotests/bgp_max_med_on_startup/test_bgp_max_med_on_startup.py
+++ b/tests/topotests/bgp_max_med_on_startup/test_bgp_max_med_on_startup.py
@@ -82,12 +82,12 @@ def test_bgp_max_med_on_startup():
# Check session is established
test_func = functools.partial(_bgp_converge, router2)
- _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=1.0)
assert result is None, "Failed bgp convergence on r2"
# Check metric has value of max-med
test_func = functools.partial(_bgp_has_routes, router2, 777)
- _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=1.0)
assert result is None, "r2 does not receive routes with metric 777"
# Check that when the max-med timer expires, metric is updated
diff --git a/tests/topotests/bgp_peer_group/r1/bgpd.conf b/tests/topotests/bgp_peer_group/r1/bgpd.conf
deleted file mode 100644
index 68d8e61a59..0000000000
--- a/tests/topotests/bgp_peer_group/r1/bgpd.conf
+++ /dev/null
@@ -1,12 +0,0 @@
-!
-router bgp 65001
- neighbor PG peer-group
- neighbor PG remote-as external
- neighbor PG timers 3 10
- neighbor 192.168.255.3 peer-group PG
- neighbor r1-eth0 interface peer-group PG
- neighbor PG1 peer-group
- neighbor PG1 remote-as external
- neighbor PG1 timers 3 20
- neighbor 192.168.251.2 peer-group PG1
-!
diff --git a/tests/topotests/bgp_peer_group/r1/frr.conf b/tests/topotests/bgp_peer_group/r1/frr.conf
new file mode 100644
index 0000000000..035c8e4cf1
--- /dev/null
+++ b/tests/topotests/bgp_peer_group/r1/frr.conf
@@ -0,0 +1,21 @@
+!
+interface r1-eth0
+ ip address 192.168.255.1/24
+!
+interface r1-eth1
+ ip address 192.168.251.1/30
+!
+ip forwarding
+!
+router bgp 65001
+ neighbor PG peer-group
+ neighbor PG remote-as external
+ neighbor PG timers 3 10
+ neighbor 192.168.255.3 peer-group PG
+ neighbor r1-eth0 interface peer-group PG
+ neighbor PG1 peer-group
+ neighbor PG1 remote-as external
+ neighbor PG1 timers 3 20
+ neighbor PG1 graceful-restart-disable
+ neighbor 192.168.251.2 peer-group PG1
+!
diff --git a/tests/topotests/bgp_peer_group/r1/zebra.conf b/tests/topotests/bgp_peer_group/r1/zebra.conf
deleted file mode 100644
index 16fd8c538c..0000000000
--- a/tests/topotests/bgp_peer_group/r1/zebra.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-!
-interface r1-eth0
- ip address 192.168.255.1/24
-!
-interface r1-eth1
- ip address 192.168.251.1/30
-!
-ip forwarding
-!
diff --git a/tests/topotests/bgp_peer_group/r2/bgpd.conf b/tests/topotests/bgp_peer_group/r2/bgpd.conf
deleted file mode 100644
index d0e8f017d1..0000000000
--- a/tests/topotests/bgp_peer_group/r2/bgpd.conf
+++ /dev/null
@@ -1,11 +0,0 @@
-!
-router bgp 65002
- neighbor PG peer-group
- neighbor PG remote-as external
- neighbor PG timers 3 10
- neighbor r2-eth0 interface peer-group PG
- neighbor PG1 peer-group
- neighbor PG1 remote-as external
- neighbor PG1 timers 3 20
- neighbor 192.168.251.1 peer-group PG1
-!
diff --git a/tests/topotests/bgp_peer_group/r2/frr.conf b/tests/topotests/bgp_peer_group/r2/frr.conf
new file mode 100644
index 0000000000..4713789f15
--- /dev/null
+++ b/tests/topotests/bgp_peer_group/r2/frr.conf
@@ -0,0 +1,19 @@
+!
+interface r2-eth0
+ ip address 192.168.255.2/24
+!
+interface r2-eth1
+ ip address 192.168.251.2/30
+!
+ip forwarding
+!
+router bgp 65002
+ neighbor PG peer-group
+ neighbor PG remote-as external
+ neighbor PG timers 3 10
+ neighbor r2-eth0 interface peer-group PG
+ neighbor PG1 peer-group
+ neighbor PG1 remote-as external
+ neighbor PG1 timers 3 20
+ neighbor 192.168.251.1 peer-group PG1
+!
diff --git a/tests/topotests/bgp_peer_group/r2/zebra.conf b/tests/topotests/bgp_peer_group/r2/zebra.conf
deleted file mode 100644
index c2ad956c9c..0000000000
--- a/tests/topotests/bgp_peer_group/r2/zebra.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-!
-interface r2-eth0
- ip address 192.168.255.2/24
-!
-interface r2-eth1
- ip address 192.168.251.2/30
-!
-ip forwarding
-!
diff --git a/tests/topotests/bgp_peer_group/r3/bgpd.conf b/tests/topotests/bgp_peer_group/r3/frr.conf
index 5a1340fb0b..e8bffaab51 100644
--- a/tests/topotests/bgp_peer_group/r3/bgpd.conf
+++ b/tests/topotests/bgp_peer_group/r3/frr.conf
@@ -1,4 +1,9 @@
!
+interface r3-eth0
+ ip address 192.168.255.3/24
+!
+ip forwarding
+!
router bgp 65003
no bgp ebgp-requires-policy
neighbor PG peer-group
diff --git a/tests/topotests/bgp_peer_group/r3/zebra.conf b/tests/topotests/bgp_peer_group/r3/zebra.conf
deleted file mode 100644
index e9fdfb70c5..0000000000
--- a/tests/topotests/bgp_peer_group/r3/zebra.conf
+++ /dev/null
@@ -1,6 +0,0 @@
-!
-interface r3-eth0
- ip address 192.168.255.3/24
-!
-ip forwarding
-!
diff --git a/tests/topotests/bgp_peer_group/test_bgp_peer-group.py b/tests/topotests/bgp_peer_group/test_bgp_peer-group.py
index 7d476b0538..45f713b8a2 100644
--- a/tests/topotests/bgp_peer_group/test_bgp_peer-group.py
+++ b/tests/topotests/bgp_peer_group/test_bgp_peer-group.py
@@ -2,12 +2,14 @@
# SPDX-License-Identifier: ISC
#
-# Copyright (c) 2021 by
+# Copyright (c) 2021-2024 by
# Donatas Abraitis <donatas.abraitis@gmail.com>
+# Donatas Abraitis <donatas@opensourcerouting.org>
#
"""
-Test if peer-group works for numbered and unnumbered configurations.
+Test if various random settings with peer-group works for
+numbered and unnumbered configurations.
"""
import os
@@ -21,7 +23,7 @@ sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
from lib import topotest
-from lib.topogen import Topogen, TopoRouter, get_topogen
+from lib.topogen import Topogen, get_topogen
from lib.topolog import logger
pytestmark = [pytest.mark.bgpd]
@@ -48,12 +50,7 @@ def setup_module(mod):
router_list = tgen.routers()
for _, (rname, router) in enumerate(router_list.items(), 1):
- router.load_config(
- TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
- )
- router.load_config(
- TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
- )
+ router.load_frr_config(os.path.join(CWD, "{}/frr.conf".format(rname)))
tgen.start_router()
@@ -72,14 +69,26 @@ def test_bgp_peer_group():
def _bgp_peer_group_configured():
output = json.loads(tgen.gears["r1"].vtysh_cmd("show ip bgp neighbor json"))
expected = {
- "r1-eth0": {"peerGroup": "PG", "bgpState": "Established"},
- "192.168.255.3": {"peerGroup": "PG", "bgpState": "Established"},
- "192.168.251.2": {"peerGroup": "PG1", "bgpState": "Established"},
+ "r1-eth0": {
+ "peerGroup": "PG",
+ "bgpState": "Established",
+ "neighborCapabilities": {"gracefulRestart": "advertisedAndReceived"},
+ },
+ "192.168.255.3": {
+ "peerGroup": "PG",
+ "bgpState": "Established",
+ "neighborCapabilities": {"gracefulRestart": "advertisedAndReceived"},
+ },
+ "192.168.251.2": {
+ "peerGroup": "PG1",
+ "bgpState": "Established",
+ "neighborCapabilities": {"gracefulRestart": "received"},
+ },
}
return topotest.json_cmp(output, expected)
test_func = functools.partial(_bgp_peer_group_configured)
- _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Failed bgp convergence in r1"
def _bgp_peer_group_check_advertised_routes():
@@ -97,7 +106,7 @@ def test_bgp_peer_group():
return topotest.json_cmp(output, expected)
test_func = functools.partial(_bgp_peer_group_check_advertised_routes)
- _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Failed checking advertised routes from r3"
@@ -122,7 +131,7 @@ def test_bgp_peer_group_remote_as_del_readd():
return topotest.json_cmp(output, expected)
test_func = functools.partial(_bgp_peer_group_remoteas_del)
- _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Failed bgp convergence in r1"
logger.info("Re-add bgp peer-group PG1 remote-as neighbor should be established")
@@ -139,7 +148,7 @@ def test_bgp_peer_group_remote_as_del_readd():
return topotest.json_cmp(output, expected)
test_func = functools.partial(_bgp_peer_group_remoteas_add)
- _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Failed bgp convergence in r1"
diff --git a/tests/topotests/docker/README.md b/tests/topotests/docker/README.md
index 2b40994cf6..2bd58a15b8 100644
--- a/tests/topotests/docker/README.md
+++ b/tests/topotests/docker/README.md
@@ -68,5 +68,5 @@ without pulling from the registry using the following commands:
```console
make topotests-build
-TOPOTEST_PULL=0 make topotests
+make topotests
```
diff --git a/tests/topotests/docker/frr-topotests.sh b/tests/topotests/docker/frr-topotests.sh
index ce373d9bd0..bd37055147 100755
--- a/tests/topotests/docker/frr-topotests.sh
+++ b/tests/topotests/docker/frr-topotests.sh
@@ -45,9 +45,6 @@ if [[ "$1" = "-h" ]] || [[ "$1" = "--help" ]]; then
TOPOTEST_OPTIONS These options are appended to the docker-run
command for starting the tests.
- TOPOTEST_PULL If set to 0, don't try to pull the most recent
- version of the docker image from dockerhub.
-
TOPOTEST_SANITIZER Controls whether to use the address sanitizer.
Enabled by default, set to 0 to disable.
@@ -122,10 +119,6 @@ if [ -z "$TOPOTEST_BUILDCACHE" ]; then
|| docker volume create "${TOPOTEST_BUILDCACHE}"
fi
-if [ "${TOPOTEST_PULL:-1}" = "1" ]; then
- docker pull frrouting/topotests:latest
-fi
-
if [[ -n "$TMUX" ]]; then
TMUX_OPTIONS="-v $(dirname $TMUX):$(dirname $TMUX) -e TMUX=$TMUX -e TMUX_PANE=$TMUX_PANE"
fi
diff --git a/tests/topotests/docker/inner/compile_frr.sh b/tests/topotests/docker/inner/compile_frr.sh
index 4a88dc677f..e943c385c7 100755
--- a/tests/topotests/docker/inner/compile_frr.sh
+++ b/tests/topotests/docker/inner/compile_frr.sh
@@ -58,9 +58,6 @@ if [ ! -e Makefile ]; then
fi
bash configure >&3 \
- --enable-static-bin \
- --enable-static \
- --enable-shared \
--enable-dev-build \
--with-moduledir=/usr/lib/frr/modules \
--prefix=/usr \
@@ -69,6 +66,8 @@ if [ ! -e Makefile ]; then
--sbindir=/usr/lib/frr \
--enable-multipath=0 \
--enable-fpm \
+ --enable-grpc \
+ --enable-scripting \
--enable-sharpd \
$EXTRA_CONFIGURE \
--with-pkg-extra-version=-topotests \
diff --git a/tests/topotests/docker/inner/entrypoint.sh b/tests/topotests/docker/inner/entrypoint.sh
index 44e16db4b9..b92217440b 100755
--- a/tests/topotests/docker/inner/entrypoint.sh
+++ b/tests/topotests/docker/inner/entrypoint.sh
@@ -20,6 +20,11 @@ cd "${FRR_BUILD_DIR}/tests/topotests"
log_info "Setting permissions on /tmp so we can generate logs"
chmod 1777 /tmp
+# This is a MUST, otherwise we have:
+# AddressSanitizer:DEADLYSIGNAL
+# Segmentation fault
+sysctl -w vm.mmap_rnd_bits=28
+
if [ $# -eq 0 ] || ([[ "$1" != /* ]] && [[ "$1" != ./* ]]); then
export TOPOTESTS_CHECK_MEMLEAK=/tmp/memleak_
export TOPOTESTS_CHECK_STDERR=Yes
diff --git a/tests/topotests/isis_topo1/test_isis_topo1.py b/tests/topotests/isis_topo1/test_isis_topo1.py
index fe3d865565..e02fb07daf 100644
--- a/tests/topotests/isis_topo1/test_isis_topo1.py
+++ b/tests/topotests/isis_topo1/test_isis_topo1.py
@@ -12,6 +12,7 @@
"""
test_isis_topo1.py: Test ISIS topology.
"""
+import time
import datetime
import functools
import json
@@ -314,6 +315,107 @@ def test_isis_neighbor_json():
), assertmsg
+def test_isis_neighbor_state():
+ "Check that the neighbor states remain normal when the ISIS type is switched."
+
+ tgen = get_topogen()
+ # Don't run this test if we have any failure.
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ logger.info("Checking 'show isis neighbor state on a p2p link'")
+
+ # Establish a P2P link
+ # When the IS-IS type of r3 is set to level-1-2 and the IS-IS type of r5 is set to level-1,
+ # it is expected that all neighbors exist and are in the Up state
+ r3 = tgen.gears["r3"]
+ r3.vtysh_cmd(
+ """
+ configure
+ router isis 1
+ no redistribute ipv4 connected level-1
+ no redistribute ipv4 connected level-2
+ no redistribute ipv6 connected level-1
+ no redistribute ipv6 connected level-2
+ interface r3-eth1
+ no isis circuit-type
+ isis network point-to-point
+ end
+ """
+ )
+ r5 = tgen.gears["r5"]
+ r5.vtysh_cmd(
+ """
+ configure
+ router isis 1
+ no redistribute ipv4 connected level-1
+ no redistribute ipv6 connected level-1
+ no redistribute ipv4 table 20 level-1
+ interface r5-eth0
+ no isis circuit-type
+ isis network point-to-point
+ end
+ """
+ )
+ result = _check_isis_neighbor_json("r3", "r5", True, "Up")
+ assert result is True, result
+ result = _check_isis_neighbor_json("r5", "r3", True, "Up")
+ assert result is True, result
+
+ # Remove the configuration that affects the switch of IS-IS type.
+ # Configure the IS-IS type of r3 to transition from level-1-2 to level-2-only,
+ # while maintaining the IS-IS type of r5 as level-1.
+ # In this scenario,
+ # the expectation is that some neighbors do not exist or are in the Initializing state
+ r3.vtysh_cmd(
+ """
+ configure
+ router isis 1
+ is-type level-2-only
+ end
+ """
+ )
+ result = _check_isis_neighbor_json("r3", "r5", False, "Initializing")
+ assert result is True, result
+ result = _check_isis_neighbor_json("r5", "r3", False, "Initializing")
+ assert result is True, result
+
+ # Restore to initial configuration
+ logger.info("Checking 'restore to initial configuration'")
+ r3.vtysh_cmd(
+ """
+ configure
+ interface r3-eth1
+ isis circuit-type level-1
+ no isis network point-to-point
+ router isis 1
+ no is-type
+ redistribute ipv4 connected level-1
+ redistribute ipv4 connected level-2
+ redistribute ipv6 connected level-1
+ redistribute ipv6 connected level-2
+ end
+ """
+ )
+ r5.vtysh_cmd(
+ """
+ configure
+ interface r5-eth0
+ isis circuit-type level-1
+ no isis network point-to-point
+ router isis 1
+ redistribute ipv4 connected level-1
+ redistribute ipv6 connected level-1
+ redistribute ipv4 table 20 level-1
+ end
+ """
+ )
+ result = _check_isis_neighbor_json("r3", "r5", True, "Up")
+ assert result is True, result
+ result = _check_isis_neighbor_json("r5", "r3", True, "Up")
+ assert result is True, result
+
+
def test_isis_database_json():
"Check json struct in show isis database json"
@@ -623,6 +725,65 @@ def test_isis_hello_padding_during_adjacency_formation():
assert result is True, result
+def _check_isis_neighbor_json(
+ self, neighbor, neighbor_expected, neighbor_state_expected
+):
+ tgen = get_topogen()
+ router = tgen.gears[self]
+ logger.info(
+ f"check_isis_neighbor_json {router} {neighbor} {neighbor_expected} {neighbor_state_expected}"
+ )
+
+ result = _check_isis_neighbor_exist(self, neighbor)
+ if result == True:
+ return _check_isis_neighbor_state(self, neighbor, neighbor_state_expected)
+ elif neighbor_expected == True:
+ return "{} with expected neighbor {} got none ".format(router.name, neighbor)
+ else:
+ return True
+
+
+@retry(retry_timeout=60)
+def _check_isis_neighbor_exist(self, neighbor):
+ tgen = get_topogen()
+ router = tgen.gears[self]
+ logger.info(f"check_isis_neighbor_exist {router} {neighbor}")
+ neighbor_json = router.vtysh_cmd("show isis neighbor json", isjson=True)
+
+ circuits = neighbor_json.get("areas", [])[0].get("circuits", [])
+ for circuit in circuits:
+ if "adj" in circuit and circuit["adj"] == neighbor:
+ return True
+
+ return "The neighbor {} of router {} has not been learned yet ".format(
+ neighbor, router.name
+ )
+
+
+@retry(retry_timeout=5)
+def _check_isis_neighbor_state(self, neighbor, neighbor_state_expected):
+ tgen = get_topogen()
+ router = tgen.gears[self]
+ logger.info(
+ f"check_isis_neighbor_state {router} {neighbor} {neighbor_state_expected}"
+ )
+ neighbor_json = router.vtysh_cmd(
+ "show isis neighbor {} json".format(neighbor), isjson=True
+ )
+
+ circuits = neighbor_json.get("areas", [])[0].get("circuits", [])
+ for circuit in circuits:
+ interface = circuit.get("interface", {})
+ if "state" in interface:
+ neighbor_state = interface["state"]
+ if neighbor_state == neighbor_state_expected:
+ return True
+
+ return "{} peer with expected neighbor_state {} got {} ".format(
+ router.name, neighbor_state_expected, neighbor_state
+ )
+
+
@retry(retry_timeout=10)
def check_last_iih_packet_for_padding(router, expect_padding):
logfilename = "{}/{}".format(router.gearlogdir, "isisd.log")
diff --git a/tests/topotests/ospfapi/test_ospf_clientapi.py b/tests/topotests/ospfapi/test_ospf_clientapi.py
index 89a34ff9b5..9e00fcf11f 100644
--- a/tests/topotests/ospfapi/test_ospf_clientapi.py
+++ b/tests/topotests/ospfapi/test_ospf_clientapi.py
@@ -218,10 +218,12 @@ def _test_router_id(tgen, testbin):
step("router id: check for modified router id")
r1.vtysh_multicmd("conf t\nrouter ospf\nospf router-id 1.1.1.1")
+ r1.vtysh_multicmd("clear ip ospf process")
_wait_output(p, "SUCCESS: {}".format(waitlist[1]))
step("router id: check for restored router id")
r1.vtysh_multicmd("conf t\nrouter ospf\nospf router-id 1.0.0.0")
+ r1.vtysh_multicmd("clear ip ospf process")
_wait_output(p, "SUCCESS: {}".format(waitlist[2]))
except Exception as error:
logging.error("ERROR: %s", error)