#!/usr/bin/env python
+# SPDX-License-Identifier: ISC
#
# test_all_protocol_startup.py
# Copyright (c) 2017 by
# Network Device Education Foundation, Inc. ("NetDEF")
#
-# Permission to use, copy, modify, and/or distribute this software
-# for any purpose with or without fee is hereby granted, provided
-# that the above copyright notice and this permission notice appear
-# in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
-# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
-# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
-# OF THIS SOFTWARE.
-#
"""
test_all_protocol_startup.py: Test of all protocols at same time
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from lib import topotest
from lib.topogen import Topogen, get_topogen
+from lib.common_config import (
+ required_linux_kernel_version,
+)
fatal_error = ""
print("******************************************\n")
# Not really implemented yet - just sleep 60 secs for now
- sleep(60)
+ sleep(5)
# Make sure that all daemons are running
failures = 0
net["r1"].cmd(
'vtysh -c "sharp install routes 6.6.6.4 nexthop-group infinite-recursive 1"'
)
+ sleep(5)
net["r1"].cmd(
'vtysh -c "sharp install routes 6.6.6.3 nexthop-group infinite-recursive 1"'
)
+ sleep(5)
net["r1"].cmd(
'vtysh -c "sharp install routes 6.6.6.2 nexthop-group infinite-recursive 1"'
)
+ sleep(5)
net["r1"].cmd(
'vtysh -c "sharp install routes 6.6.6.1 nexthop-group infinite-recursive 1"'
'vtysh -c "c t" -c "nexthop-group replace" -c "nexthop 1.1.1.1 r1-eth1 onlink" -c "nexthop 1.1.1.2 r1-eth2 onlink"'
)
+ # At the moment there is absolutely no real easy way to query sharpd
+ # for the nexthop group actually installed. If it is not installed
+ # sharpd will just transmit the nexthops down instead of the nexthop
+ # group id. Leading to a situation where the replace is not actually
+ # being tested. So let's just wait some time here because this
+ # is hard and this test fails all the time
+ sleep(5)
+
# Create with sharpd using nexthop-group
net["r1"].cmd('vtysh -c "sharp install routes 3.3.3.1 nexthop-group replace 1"')
assert fatal_error == "", fatal_error
+def test_resilient_nexthop_group():
+ net = get_topogen().net
+
+ result = required_linux_kernel_version("5.19")
+ if result is not True:
+ pytest.skip("Kernel requirements are not met, kernel version should be >= 5.19")
+
+ net["r1"].cmd(
+ 'vtysh -c "conf" -c "nexthop-group resilience" -c "resilient buckets 64 idle-timer 128 unbalanced-timer 256" -c "nexthop 1.1.1.1 r1-eth1 onlink" -c "nexthop 1.1.1.2 r1-eth2 onlink"'
+ )
+
+ output = net["r1"].cmd('vtysh -c "show nexthop-group rib sharp"')
+ output = re.findall(r"Buckets", output)
+
+ verify_nexthop_group(185483878)
+ assert len(output) == 1, "Resilient NHG not created in zebra"
+
+
def test_shutdown_check_stderr():
global fatal_error
net = get_topogen().net