From 4d285ff3e8e0bd2905cfe57b1567065b893f88cd Mon Sep 17 00:00:00 2001 From: Dmytro Shytyi Date: Mon, 11 Dec 2023 16:15:37 +0100 Subject: [PATCH] topotest: isis_srv6_te_topo1 SRv6 Policy is an ordered list of segments that represent a source-routed policy. Packet flows are steered into an SRv6 Policy. Signed-off-by: Dmytro Shytyi Signed-off-by: Philippe Guibert --- .../isis_srv6_te_topo1/dst/zebra.conf | 23 + .../isis_srv6_te_topo1/rt1/bgpd.conf | 45 ++ .../isis_srv6_te_topo1/rt1/isisd.conf | 35 ++ .../isis_srv6_te_topo1/rt1/pathd.conf | 10 + .../isis_srv6_te_topo1/rt1/sharpd.conf | 0 .../isis_srv6_te_topo1/rt1/staticd.conf | 0 .../rt1/step1/show_ip_route.ref | 276 ++++++++++ .../rt1/step1/show_ipv6_route.ref | 246 +++++++++ .../rt1/step1/show_srv6_locator_table.ref | 19 + .../show_yang_interface_isis_adjacencies.ref | 32 ++ .../rt1/step2/show_srv6_route.ref | 36 ++ .../rt1/step3/show_srv6_additional_route.ref | 37 ++ .../rt1/step4/show_ipv6_route.ref | 37 ++ .../isis_srv6_te_topo1/rt1/zebra.conf | 41 ++ .../isis_srv6_te_topo1/rt2/isisd.conf | 48 ++ .../isis_srv6_te_topo1/rt2/zebra.conf | 33 ++ .../isis_srv6_te_topo1/rt3/isisd.conf | 48 ++ .../isis_srv6_te_topo1/rt3/zebra.conf | 32 ++ .../isis_srv6_te_topo1/rt4/isisd.conf | 56 +++ .../isis_srv6_te_topo1/rt4/zebra.conf | 35 ++ .../isis_srv6_te_topo1/rt5/isisd.conf | 56 +++ .../isis_srv6_te_topo1/rt5/zebra.conf | 35 ++ .../isis_srv6_te_topo1/rt6/bgpd.conf | 45 ++ .../isis_srv6_te_topo1/rt6/isisd.conf | 42 ++ .../isis_srv6_te_topo1/rt6/sharpd.conf | 0 .../isis_srv6_te_topo1/rt6/zebra.conf | 45 ++ .../isis_srv6_te_topo1/src/zebra.conf | 6 + .../test_isis_srv6_te_topo1.py | 476 ++++++++++++++++++ 28 files changed, 1794 insertions(+) create mode 100644 tests/topotests/isis_srv6_te_topo1/dst/zebra.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/bgpd.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/isisd.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/pathd.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/sharpd.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/staticd.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/step1/show_ip_route.ref create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/step1/show_ipv6_route.ref create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/step1/show_srv6_locator_table.ref create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/step1/show_yang_interface_isis_adjacencies.ref create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/step2/show_srv6_route.ref create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/step3/show_srv6_additional_route.ref create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/step4/show_ipv6_route.ref create mode 100644 tests/topotests/isis_srv6_te_topo1/rt1/zebra.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt2/isisd.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt2/zebra.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt3/isisd.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt3/zebra.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt4/isisd.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt4/zebra.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt5/isisd.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt5/zebra.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt6/bgpd.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt6/isisd.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt6/sharpd.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/rt6/zebra.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/src/zebra.conf create mode 100644 tests/topotests/isis_srv6_te_topo1/test_isis_srv6_te_topo1.py diff --git a/tests/topotests/isis_srv6_te_topo1/dst/zebra.conf b/tests/topotests/isis_srv6_te_topo1/dst/zebra.conf new file mode 100644 index 000000000000..23bdbe12057c --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/dst/zebra.conf @@ -0,0 +1,23 @@ +log file zebra.log +! +hostname dst +! +! debug zebra kernel +! debug zebra packet +! debug zebra mpls +! +interface lo + ip address 9.9.9.2/32 + ipv6 address fc00:0:9::1/128 +! +interface eth-rt6 + ip address 10.0.10.2/24 + ipv6 address 2001:db8:10::2/64 +! +ip forwarding +! +ip route 10.8.0.2/24 10.0.10.1 +ipv6 route 2001:db8:1::/64 2001:db8:10::1 +! +line vty +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/bgpd.conf b/tests/topotests/isis_srv6_te_topo1/rt1/bgpd.conf new file mode 100644 index 000000000000..40cea2d86fbd --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt1/bgpd.conf @@ -0,0 +1,45 @@ +frr defaults traditional +! +hostname r1 +password zebra +! +log stdout notifications +log commands +! +router bgp 65001 + bgp router-id 192.0.2.1 + no bgp ebgp-requires-policy + no bgp default ipv4-unicast + neighbor fc00:0:6b::1 remote-as 65002 + neighbor fc00:0:6b::1 ebgp-multihop + neighbor fc00:0:6b::1 update-source fc00:0:1b::1 + neighbor fc00:0:6b::1 timers 3 10 + neighbor fc00:0:6b::1 timers connect 1 + neighbor fc00:0:6b::1 capability extended-nexthop + ! + segment-routing srv6 + locator loc2 + ! + address-family ipv6 + neighbor fc00:0:6b::1 activate + exit-address-family +! +address-family ipv4 vpn + neighbor fc00:0:6b::1 activate + exit-address-family + ! +! +router bgp 65001 vrf vrf10 + bgp router-id 192.0.2.1 + ! + address-family ipv4 unicast + redistribute connected + sid vpn export 1 + rd vpn export 65001:10 + rt vpn both 0:10 + import vpn + export vpn + exit-address-family + ! +! +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/isisd.conf b/tests/topotests/isis_srv6_te_topo1/rt1/isisd.conf new file mode 100644 index 000000000000..29e1a3117165 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt1/isisd.conf @@ -0,0 +1,35 @@ +password 1 +hostname rt1 +log file isisd.log +! +! debug isis events +! debug isis route-events +! debug isis spf-events +! debug isis sr-events +! debug isis lsp-gen +! +interface lo + ip router isis 1 + ipv6 router isis 1 + isis passive +! +interface eth-sw1 + ip router isis 1 + ipv6 router isis 1 + isis hello-interval 1 + isis hello-multiplier 10 +! +router isis 1 + lsp-gen-interval 2 + net 49.0000.0000.0000.0001.00 + is-type level-1 + topology ipv6-unicast + segment-routing srv6 + locator loc1 + node-msd + max-segs-left 3 + max-end-pop 3 + max-h-encaps 2 + max-end-d 5 + interface sr0 +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/pathd.conf b/tests/topotests/isis_srv6_te_topo1/rt1/pathd.conf new file mode 100644 index 000000000000..da7616d8df7f --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt1/pathd.conf @@ -0,0 +1,10 @@ +segment-routing + traffic-eng + segment-list srv6-header + index 1 ipv6-address fc00:0:3:: + index 2 ipv6-address fc00:0:5:: + index 3 ipv6-address fc00:0:6:: + exit + exit +exit +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/sharpd.conf b/tests/topotests/isis_srv6_te_topo1/rt1/sharpd.conf new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/staticd.conf b/tests/topotests/isis_srv6_te_topo1/rt1/staticd.conf new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/step1/show_ip_route.ref b/tests/topotests/isis_srv6_te_topo1/rt1/step1/show_ip_route.ref new file mode 100644 index 000000000000..590d75afbf99 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt1/step1/show_ip_route.ref @@ -0,0 +1,276 @@ +{ + "2.2.2.2\/32":[ + { + "prefix":"2.2.2.2\/32", + "protocol":"isis", + "selected":true, + "destSelected":true, + "distance":115, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.2", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + } + ] + } + ], + "3.3.3.3\/32":[ + { + "prefix":"3.3.3.3\/32", + "protocol":"isis", + "selected":true, + "destSelected":true, + "distance":115, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.3", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + } + ] + } + ], + "4.4.4.4\/32":[ + { + "prefix":"4.4.4.4\/32", + "protocol":"isis", + "selected":true, + "destSelected":true, + "distance":115, + "metric":30, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.2", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + } + ] + } + ], + "5.5.5.5\/32":[ + { + "prefix":"5.5.5.5\/32", + "protocol":"isis", + "selected":true, + "destSelected":true, + "distance":115, + "metric":30, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.3", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + } + ] + } + ], + "6.6.6.6\/32":[ + { + "prefix":"6.6.6.6\/32", + "protocol":"isis", + "selected":true, + "destSelected":true, + "distance":115, + "metric":40, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.2", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + }, + { + "fib":true, + "ip":"10.0.1.3", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + } + ] + } + ], + "10.0.1.0\/24":[ + { + "prefix":"10.0.1.0\/24", + "protocol":"isis", + "distance":115, + "metric":20, + "nexthops":[ + { + "ip":"10.0.1.2", + "afi":"ipv4", + "interfaceName":"eth-sw1" + }, + { + "ip":"10.0.1.3", + "afi":"ipv4", + "interfaceName":"eth-sw1" + } + ] + } + ], + "10.0.2.0\/24":[ + { + "prefix":"10.0.2.0\/24", + "protocol":"isis", + "selected":true, + "destSelected":true, + "distance":115, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.2", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + } + ] + } + ], + "10.0.3.0\/24":[ + { + "prefix":"10.0.3.0\/24", + "protocol":"isis", + "selected":true, + "destSelected":true, + "distance":115, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.2", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + } + ] + } + ], + "10.0.4.0\/24":[ + { + "prefix":"10.0.4.0\/24", + "protocol":"isis", + "selected":true, + "destSelected":true, + "distance":115, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.3", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + } + ] + } + ], + "10.0.5.0\/24":[ + { + "prefix":"10.0.5.0\/24", + "protocol":"isis", + "selected":true, + "destSelected":true, + "distance":115, + "metric":20, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.3", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + } + ] + } + ], + "10.0.6.0\/24":[ + { + "prefix":"10.0.6.0\/24", + "protocol":"isis", + "selected":true, + "destSelected":true, + "distance":115, + "metric":30, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.2", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + }, + { + "fib":true, + "ip":"10.0.1.3", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + } + ] + } + ], + "10.0.7.0\/24":[ + { + "prefix":"10.0.7.0\/24", + "protocol":"isis", + "selected":true, + "destSelected":true, + "distance":115, + "metric":30, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.2", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + } + ] + } + ], + "10.0.8.0\/24":[ + { + "prefix":"10.0.8.0\/24", + "protocol":"isis", + "selected":true, + "destSelected":true, + "distance":115, + "metric":30, + "installed":true, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.3", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true + } + ] + } + ] +} diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/step1/show_ipv6_route.ref b/tests/topotests/isis_srv6_te_topo1/rt1/step1/show_ipv6_route.ref new file mode 100644 index 000000000000..4311cb260dd6 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt1/step1/show_ipv6_route.ref @@ -0,0 +1,246 @@ +{ + "fc00:0:1::/128": [ + { + "prefix": "fc00:0:1::/128", + "prefixLen": 128, + "protocol": "isis", + "selected": true, + "distance": 115, + "installed": true, + "nexthops": [ + { + "flags": 3, + "fib": true, + "directlyConnected": true, + "active": true, + "weight": 1, + "seg6local": { + "action": "End" + } + } + ] + } + ], + "fc00:0:1:1::/128": [ + { + "prefix": "fc00:0:1:1::/128", + "prefixLen": 128, + "protocol": "isis", + "selected": true, + "distance": 115, + "installed": true, + "nexthops": [ + { + "flags": 3, + "fib": true, + "directlyConnected": true, + "active": true, + "weight": 1, + "seg6local": { + "action": "End.X" + } + } + ] + } + ], + "fc00:0:1:2::/128": [ + { + "prefix": "fc00:0:1:2::/128", + "prefixLen": 128, + "protocol": "isis", + "selected": true, + "distance": 115, + "installed": true, + "nexthops": [ + { + "flags": 3, + "fib": true, + "directlyConnected": true, + "active": true, + "weight": 1, + "seg6local": { + "action": "End.X" + } + } + ] + } + ], + "fc00:0:2::/48": [ + { + "prefix": "fc00:0:2::/48", + "prefixLen": 48, + "protocol": "isis", + "selected": true, + "distance": 115, + "installed": true, + "nexthops": [ + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "active": true, + "weight": 1 + } + ] + } + ], + "fc00:0:2::1/128": [ + { + "prefix": "fc00:0:2::1/128", + "prefixLen": 128, + "protocol": "isis", + "selected": true, + "distance": 115, + "installed": true, + "nexthops": [ + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "active": true, + "weight": 1 + } + ] + } + ], + "fc00:0:3::/48": [ + { + "prefix": "fc00:0:3::/48", + "prefixLen": 48, + "protocol": "isis", + "selected": true, + "distance": 115, + "installed": true, + "nexthops": [ + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "active": true, + "weight": 1 + } + ] + } + ], + "fc00:0:3::1/128": [ + { + "prefix": "fc00:0:3::1/128", + "prefixLen": 128, + "protocol": "isis", + "selected": true, + "distance": 115, + "installed": true, + "nexthops": [ + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "active": true, + "weight": 1 + } + ] + } + ], + "fc00:0:4::/48": [ + { + "prefix": "fc00:0:4::/48", + "prefixLen": 48, + "protocol": "isis", + "selected": true, + "distance": 115, + "installed": true, + "nexthops": [ + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "active": true, + "weight": 1 + } + ] + } + ], + "fc00:0:4::1/128": [ + { + "prefix": "fc00:0:4::1/128", + "prefixLen": 128, + "protocol": "isis", + "selected": true, + "distance": 115, + "installed": true, + "nexthops": [ + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "active": true, + "weight": 1 + } + ] + } + ], + "fc00:0:5::/48": [ + { + "prefix": "fc00:0:5::/48", + "prefixLen": 48, + "protocol": "isis", + "selected": true, + "distance": 115, + "installed": true, + "nexthops": [ + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "active": true, + "weight": 1 + } + ] + } + ], + "fc00:0:5::1/128": [ + { + "prefix": "fc00:0:5::1/128", + "prefixLen": 128, + "protocol": "isis", + "selected": true, + "distance": 115, + "installed": true, + "nexthops": [ + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "active": true, + "weight": 1 + } + ] + } + ], + "fc00:0:6::/48": [ + { + "prefix": "fc00:0:6::/48", + "prefixLen": 48, + "protocol": "isis", + "selected": true, + "distance": 115, + "installed": true, + "nexthops": [ + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "active": true, + "weight": 1 + }, + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "active": true, + "weight": 1 + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/step1/show_srv6_locator_table.ref b/tests/topotests/isis_srv6_te_topo1/rt1/step1/show_srv6_locator_table.ref new file mode 100644 index 000000000000..bb10aba9424d --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt1/step1/show_srv6_locator_table.ref @@ -0,0 +1,19 @@ +{ + "locators":[ + { + "name":"loc1", + "prefix":"fc00:0:1::/48", + "blockBitsLength":32, + "nodeBitsLength":16, + "functionBitsLength":16, + "argumentBitsLength":0, + "statusUp":true, + "chunks":[ + { + "prefix":"fc00:0:1::/48", + "proto":"isis" + } + ] + } + ] +} diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/step1/show_yang_interface_isis_adjacencies.ref b/tests/topotests/isis_srv6_te_topo1/rt1/step1/show_yang_interface_isis_adjacencies.ref new file mode 100644 index 000000000000..9c5901b90ff1 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt1/step1/show_yang_interface_isis_adjacencies.ref @@ -0,0 +1,32 @@ +{ + "frr-interface:lib": { + "interface": [ + { + "name": "eth-sw1", + "vrf": "default", + "state": { + "frr-isisd:isis": { + "adjacencies": { + "adjacency": [ + { + "neighbor-sys-type": "level-1", + "neighbor-sysid": "0000.0000.0003", + "hold-timer": 10, + "neighbor-priority": 64, + "state": "up" + }, + { + "neighbor-sys-type": "level-1", + "neighbor-sysid": "0000.0000.0002", + "hold-timer": 10, + "neighbor-priority": 64, + "state": "up" + } + ] + } + } + } + } + ] + } +} diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/step2/show_srv6_route.ref b/tests/topotests/isis_srv6_te_topo1/rt1/step2/show_srv6_route.ref new file mode 100644 index 000000000000..a57c04d5a982 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt1/step2/show_srv6_route.ref @@ -0,0 +1,36 @@ +{ + "2001:db8:10::/64": [ + { + "prefix": "2001:db8:10::/64", + "prefixLen": 64, + "protocol": "static", + "distance": 1, + "installed": true, + "nexthops": [ + { + "flags": 133, + "ip": "fc00:0:6::", + "afi": "ipv6", + "active": true, + "recursive": true, + "weight": 1, + "srteColor": 1 + }, + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "weight": 1, + "seg6local": { + "action": "unspec" + }, + "seg6": [ + "fc00:0:3::", + "fc00:0:5::", + "fc00:0:6::" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/step3/show_srv6_additional_route.ref b/tests/topotests/isis_srv6_te_topo1/rt1/step3/show_srv6_additional_route.ref new file mode 100644 index 000000000000..fc4bd55d37fd --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt1/step3/show_srv6_additional_route.ref @@ -0,0 +1,37 @@ +{ + "fc00:0:6b::/48": [ + { + "prefix": "fc00:0:6b::/48", + "prefixLen": 48, + "protocol": "static", + "selected": true, + "nexthops": [ + { + "flags": 133, + "ip": "fc00:0:6::", + "afi": "ipv6", + "active":true, + "recursive": true, + "weight": 1, + "srteColor": 1 + }, + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "resolver": true, + "active": true, + "weight": 1, + "seg6local": { + "action": "unspec" + }, + "seg6": [ + "fc00:0:3::", + "fc00:0:5::", + "fc00:0:6::" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/step4/show_ipv6_route.ref b/tests/topotests/isis_srv6_te_topo1/rt1/step4/show_ipv6_route.ref new file mode 100644 index 000000000000..fffa60e950bc --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt1/step4/show_ipv6_route.ref @@ -0,0 +1,37 @@ +{ + "fc00:0:6b::/48": [ + { + "prefix": "fc00:0:6b::/48", + "prefixLen": 48, + "protocol": "static", + "distance": 1, + "metric": 0, + "installed": true, + "nexthops": [ + { + "flags": 133, + "ip": "fc00:0:6::", + "afi": "ipv6", + "active": true, + "recursive": true, + "weight": 1, + "srteColor": 1 + }, + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "active": true, + "weight": 1 + }, + { + "flags": 3, + "fib": true, + "afi": "ipv6", + "active": true, + "weight": 1 + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/isis_srv6_te_topo1/rt1/zebra.conf b/tests/topotests/isis_srv6_te_topo1/rt1/zebra.conf new file mode 100644 index 000000000000..8c61f76ee367 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt1/zebra.conf @@ -0,0 +1,41 @@ +log file zebra.log +! +hostname rt1 +! +! debug zebra kernel +! debug zebra packet +! +interface lo + ip address 1.1.1.1/32 + ipv6 address fc00:0:1::1/48 + ipv6 address fc00:0:1b::1/48 +! +interface eth-sw1 + ip address 10.0.1.1/24 + ipv6 address 2001:db8:1::1/64 +! +interface eth-src + ip address 10.8.0.1/24 +exit +! +segment-routing + srv6 + locators + locator loc1 + prefix fc00:0:1::/48 block-len 32 node-len 16 func-bits 16 + exit + ! + locator loc2 + prefix fc00:0:1b::/48 block-len 32 node-len 16 func-bits 16 + exit + ! + exit + ! + exit + ! +exit +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt2/isisd.conf b/tests/topotests/isis_srv6_te_topo1/rt2/isisd.conf new file mode 100644 index 000000000000..b095f049101f --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt2/isisd.conf @@ -0,0 +1,48 @@ +hostname rt2 +log file isisd.log +! +! debug isis events +! debug isis route-events +! debug isis spf-events +! debug isis sr-events +! debug isis lsp-gen +! +interface lo + ip router isis 1 + ipv6 router isis 1 + isis passive +! +interface eth-sw1 + ip router isis 1 + ipv6 router isis 1 + isis hello-interval 1 + isis hello-multiplier 10 +! +interface eth-rt4-1 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +interface eth-rt4-2 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +router isis 1 + lsp-gen-interval 2 + net 49.0000.0000.0000.0002.00 + is-type level-1 + topology ipv6-unicast + segment-routing srv6 + locator loc1 + node-msd + max-segs-left 3 + max-end-pop 3 + max-h-encaps 2 + max-end-d 5 + interface sr0 +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt2/zebra.conf b/tests/topotests/isis_srv6_te_topo1/rt2/zebra.conf new file mode 100644 index 000000000000..81dfb37eca31 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt2/zebra.conf @@ -0,0 +1,33 @@ +log file zebra.log +! +hostname rt2 +! +! debug zebra kernel +! debug zebra packet +! +interface lo + ip address 2.2.2.2/32 + ipv6 address fc00:0:2::1/128 +! +interface eth-sw1 + ip address 10.0.1.2/24 + ipv6 address 2001:db8:1::2/64 +! +interface eth-rt4-1 + ip address 10.0.2.2/24 +! +interface eth-rt4-2 + ip address 10.0.3.2/24 +! +segment-routing + srv6 + locators + locator loc1 + prefix fc00:0:2::/48 block-len 32 node-len 16 func-bits 16 + ! + ! +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt3/isisd.conf b/tests/topotests/isis_srv6_te_topo1/rt3/isisd.conf new file mode 100644 index 000000000000..e237db2f4940 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt3/isisd.conf @@ -0,0 +1,48 @@ +hostname rt3 +log file isisd.log +! +! debug isis events +! debug isis route-events +! debug isis spf-events +! debug isis sr-events +! debug isis lsp-gen +! +interface lo + ip router isis 1 + ipv6 router isis 1 + isis passive +! +interface eth-sw1 + ip router isis 1 + ipv6 router isis 1 + isis hello-interval 1 + isis hello-multiplier 10 +! +interface eth-rt5-1 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +interface eth-rt5-2 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +router isis 1 + lsp-gen-interval 2 + net 49.0000.0000.0000.0003.00 + is-type level-1 + topology ipv6-unicast + segment-routing srv6 + locator loc1 + node-msd + max-segs-left 3 + max-end-pop 3 + max-h-encaps 2 + max-end-d 5 + interface sr0 +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt3/zebra.conf b/tests/topotests/isis_srv6_te_topo1/rt3/zebra.conf new file mode 100644 index 000000000000..72f259e61261 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt3/zebra.conf @@ -0,0 +1,32 @@ +log file zebra.log +! +hostname rt3 +! +! debug zebra kernel +! debug zebra packet +! +interface lo + ip address 3.3.3.3/32 + ipv6 address fc00:0:3::1/128 +! +interface eth-sw1 + ip address 10.0.1.3/24 +! +interface eth-rt5-1 + ip address 10.0.4.3/24 +! +interface eth-rt5-2 + ip address 10.0.5.3/24 +! +segment-routing + srv6 + locators + locator loc1 + prefix fc00:0:3::/48 block-len 32 node-len 16 func-bits 16 + ! + ! +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt4/isisd.conf b/tests/topotests/isis_srv6_te_topo1/rt4/isisd.conf new file mode 100644 index 000000000000..b4c92146a1f6 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt4/isisd.conf @@ -0,0 +1,56 @@ +hostname rt4 +log file isisd.log +! +! debug isis events +! debug isis route-events +! debug isis spf-events +! debug isis sr-events +! debug isis lsp-gen +! +interface lo + ip router isis 1 + ipv6 router isis 1 + isis passive +! +interface eth-rt2-1 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +interface eth-rt2-2 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +interface eth-rt5 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +interface eth-rt6 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +router isis 1 + lsp-gen-interval 2 + net 49.0000.0000.0000.0004.00 + is-type level-1 + topology ipv6-unicast + segment-routing srv6 + locator loc1 + node-msd + max-segs-left 3 + max-end-pop 3 + max-h-encaps 2 + max-end-d 5 + interface sr0 +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt4/zebra.conf b/tests/topotests/isis_srv6_te_topo1/rt4/zebra.conf new file mode 100644 index 000000000000..103e0baabb28 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt4/zebra.conf @@ -0,0 +1,35 @@ +log file zebra.log +! +hostname rt4 +! +! debug zebra kernel +! debug zebra packet +! +interface lo + ip address 4.4.4.4/32 + ipv6 address fc00:0:4::1/128 +! +interface eth-rt2-1 + ip address 10.0.2.4/24 +! +interface eth-rt2-2 + ip address 10.0.3.4/24 +! +interface eth-rt5 + ip address 10.0.6.4/24 +! +interface eth-rt6 + ip address 10.0.7.4/24 +! +segment-routing + srv6 + locators + locator loc1 + prefix fc00:0:4::/48 block-len 32 node-len 16 func-bits 16 + ! + ! +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt5/isisd.conf b/tests/topotests/isis_srv6_te_topo1/rt5/isisd.conf new file mode 100644 index 000000000000..26f895dd82ea --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt5/isisd.conf @@ -0,0 +1,56 @@ +hostname rt5 +log file isisd.log +! +! debug isis events +! debug isis route-events +! debug isis spf-events +! debug isis sr-events +! debug isis lsp-gen +! +interface lo + ip router isis 1 + ipv6 router isis 1 + isis passive +! +interface eth-rt3-1 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +interface eth-rt3-2 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +interface eth-rt4 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +interface eth-rt6 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +router isis 1 + lsp-gen-interval 2 + net 49.0000.0000.0000.0005.00 + is-type level-1 + topology ipv6-unicast + segment-routing srv6 + locator loc1 + node-msd + max-segs-left 3 + max-end-pop 3 + max-h-encaps 2 + max-end-d 5 + interface sr0 +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt5/zebra.conf b/tests/topotests/isis_srv6_te_topo1/rt5/zebra.conf new file mode 100644 index 000000000000..91db38147b12 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt5/zebra.conf @@ -0,0 +1,35 @@ +log file zebra.log +! +hostname rt5 +! +! debug zebra kernel +! debug zebra packet +! +interface lo + ip address 5.5.5.5/32 + ipv6 address fc00:0:5::1/128 +! +interface eth-rt3-1 + ip address 10.0.4.5/24 +! +interface eth-rt3-2 + ip address 10.0.5.5/24 +! +interface eth-rt4 + ip address 10.0.6.5/24 +! +interface eth-rt6 + ip address 10.0.8.5/24 +! +segment-routing + srv6 + locators + locator loc1 + prefix fc00:0:5::/48 block-len 32 node-len 16 func-bits 16 + ! + ! +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt6/bgpd.conf b/tests/topotests/isis_srv6_te_topo1/rt6/bgpd.conf new file mode 100644 index 000000000000..78a3279fc4c4 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt6/bgpd.conf @@ -0,0 +1,45 @@ +frr defaults traditional +! +hostname r2 +password zebra +! +log stdout notifications +log commands +! +router bgp 65002 + bgp router-id 192.0.2.2 + no bgp ebgp-requires-policy + no bgp default ipv4-unicast + neighbor fc00:0:1b::1 remote-as 65001 + neighbor fc00:0:1b::1 ebgp-multihop + neighbor fc00:0:1b::1 update-source fc00:0:6b::1 + neighbor fc00:0:1b::1 timers 3 10 + neighbor fc00:0:1b::1 timers connect 1 + neighbor fc00:0:1b::1 capability extended-nexthop + ! + segment-routing srv6 + locator loc2 + ! + address-family ipv6 + neighbor fc00:0:1b::1 activate + network 2001:db8:11::1/64 + exit-address-family + ! + address-family ipv4 vpn + neighbor fc00:0:1b::1 activate + exit-address-family + ! +! +router bgp 65002 vrf vrf10 + bgp router-id 192.0.2.2 + ! + address-family ipv4 unicast + redistribute connected + sid vpn export 1 + rd vpn export 65002:10 + rt vpn both 0:10 + import vpn + export vpn + exit-address-family + ! +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt6/isisd.conf b/tests/topotests/isis_srv6_te_topo1/rt6/isisd.conf new file mode 100644 index 000000000000..f8816db43aac --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt6/isisd.conf @@ -0,0 +1,42 @@ +hostname rt6 +log file isisd.log +! +! debug isis events +! debug isis route-events +! debug isis spf-events +! debug isis sr-events +! debug isis lsp-gen +! +interface lo + ip router isis 1 + ipv6 router isis 1 + isis passive +! +interface eth-rt4 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +interface eth-rt5 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-interval 1 + isis hello-multiplier 10 +! +router isis 1 + lsp-gen-interval 2 + net 49.0000.0000.0000.0006.00 + is-type level-1 + topology ipv6-unicast + segment-routing srv6 + locator loc1 + node-msd + max-segs-left 3 + max-end-pop 3 + max-h-encaps 2 + max-end-d 5 + interface sr0 +! diff --git a/tests/topotests/isis_srv6_te_topo1/rt6/sharpd.conf b/tests/topotests/isis_srv6_te_topo1/rt6/sharpd.conf new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/topotests/isis_srv6_te_topo1/rt6/zebra.conf b/tests/topotests/isis_srv6_te_topo1/rt6/zebra.conf new file mode 100644 index 000000000000..55b74dbfa23a --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/rt6/zebra.conf @@ -0,0 +1,45 @@ +log file zebra.log +! +hostname rt6 +! +! debug zebra kernel +! debug zebra packet +! +interface lo + ip address 6.6.6.6/32 + ipv6 address fc00:0:6::1/48 + ipv6 address fc00:0:6b::1/48 +! +interface eth-rt4 + ip address 10.0.7.6/24 +! +interface eth-rt5 + ip address 10.0.8.6/24 +! +interface eth-dst + ip address 10.0.10.1/24 + ip address 2001:db8:10::1/64 + ip address 2001:db8:11::1/64 +! +segment-routing + srv6 + locators + locator loc1 + prefix fc00:0:6::/48 block-len 32 node-len 16 func-bits 16 + exit + ! + locator loc2 + prefix fc00:0:6b::/48 block-len 32 node-len 16 func-bits 16 + exit + ! + exit + ! + exit + ! +exit +ip forwarding +! +ip route fc00:0:9::1/128 2001:db8:10::2 +! +line vty +! diff --git a/tests/topotests/isis_srv6_te_topo1/src/zebra.conf b/tests/topotests/isis_srv6_te_topo1/src/zebra.conf new file mode 100644 index 000000000000..dd6b394a164c --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/src/zebra.conf @@ -0,0 +1,6 @@ +ip route 10.0.10.0/24 10.8.0.1 +! +interface eth-rt1 + ip address 10.8.0.2/24 +exit +! diff --git a/tests/topotests/isis_srv6_te_topo1/test_isis_srv6_te_topo1.py b/tests/topotests/isis_srv6_te_topo1/test_isis_srv6_te_topo1.py new file mode 100644 index 000000000000..9122cda2f5f0 --- /dev/null +++ b/tests/topotests/isis_srv6_te_topo1/test_isis_srv6_te_topo1.py @@ -0,0 +1,476 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: ISC + +# +# Copyright 2023 6WIND S.A. +# Dmytro Shytyi +# + + +""" +test_isis_srv6_te_topo1.py: + + + +---------+ + | | + | SRC | + | | + +---------+ + |eth-rt1 + | + |10.8.0.0/24 + | + |eth-src + +---------+ + | | + | RT1 | + | 1.1.1.1 | + | | + +---------+ + |eth-sw1 + | + | + | + +---------+ | +---------+ + | | | | | + | RT2 |eth-sw1 | eth-sw1| RT3 | + | 2.2.2.2 +----------+----------+ 3.3.3.3 | + | | 10.0.1.0/24 | | + +---------+ +---------+ + eth-rt4-1| |eth-rt4-2 eth-rt5-1| |eth-rt5-2 + | | | | + 10.0.2.0/24| |10.0.3.0/24 10.0.4.0/24| |10.0.5.0/24 + | | | | + eth-rt2-1| |eth-rt2-2 eth-rt3-1| |eth-rt3-2 + +---------+ +---------+ + | | | | + | RT4 | 10.0.6.0/24 | RT5 | + | 4.4.4.4 +---------------------+ 5.5.5.5 | + | |eth-rt5 eth-rt4| | + +---------+ +---------+ + eth-rt6| |eth-rt6 + | | + 10.0.7.0/24| |10.0.8.0/24 + | +---------+ | + | | | | + | | RT6 | | + +----------+ 6.6.6.6 +-----------+ + eth-rt4| |eth-rt5 + +---------+ + |eth-dst (.1) + | + |10.0.10.0/24 + | + |eth-rt6 (.2) + +---------+ + | | + | DST | + | | + +---------+ + +""" + +import os +import re +import sys +import json +import functools +import pytest + +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, "../")) + +# pylint: disable=C0413 +# Import topogen and topotest helpers +from lib import topotest +from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topolog import logger +from lib.common_config import ( + required_linux_kernel_version, + create_interface_in_kernel, +) + +pytestmark = [pytest.mark.isisd, pytest.mark.sharpd] + + +def build_topo(tgen): + """Build function""" + + # Define FRR Routers + tgen.add_router("rt1") + tgen.add_router("rt2") + tgen.add_router("rt3") + tgen.add_router("rt4") + tgen.add_router("rt5") + tgen.add_router("rt6") + tgen.add_router("dst") + tgen.add_router("src") + + # Define connections + switch = tgen.add_switch("s1") + switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1") + switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1") + switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1") + + switch = tgen.add_switch("s2") + switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-1") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-1") + + switch = tgen.add_switch("s3") + switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-2") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-2") + + switch = tgen.add_switch("s4") + switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-1") + switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-1") + + switch = tgen.add_switch("s5") + switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-2") + switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-2") + + switch = tgen.add_switch("s6") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5") + switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4") + + switch = tgen.add_switch("s7") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6") + switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4") + + switch = tgen.add_switch("s8") + switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6") + switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5") + + switch = tgen.add_switch("s9") + switch.add_link(tgen.gears["rt6"], nodeif="eth-dst") + switch.add_link(tgen.gears["dst"], nodeif="eth-rt6") + + switch = tgen.add_switch("s10") + switch.add_link(tgen.gears["rt1"], nodeif="eth-src") + switch.add_link(tgen.gears["src"], nodeif="eth-rt1") + + # Add dummy interface for SRv6 + create_interface_in_kernel( + tgen, + "rt1", + "sr0", + "2001:db8::1", + netmask="128", + create=True, + ) + create_interface_in_kernel( + tgen, + "rt2", + "sr0", + "2001:db8::2", + netmask="128", + create=True, + ) + create_interface_in_kernel( + tgen, + "rt3", + "sr0", + "2001:db8::3", + netmask="128", + create=True, + ) + create_interface_in_kernel( + tgen, + "rt4", + "sr0", + "2001:db8::4", + netmask="128", + create=True, + ) + create_interface_in_kernel( + tgen, + "rt5", + "sr0", + "2001:db8::5", + netmask="128", + create=True, + ) + create_interface_in_kernel( + tgen, + "rt6", + "sr0", + "2001:db8::6", + netmask="128", + create=True, + ) + + +def setup_module(mod): + """Sets up the pytest environment""" + + # Verify if kernel requirements are satisfied + result = required_linux_kernel_version("4.10") + if result is not True: + pytest.skip("Kernel requirements are not met") + + # Build the topology + tgen = Topogen(build_topo, mod.__name__) + tgen.start_topology() + + # For all registered routers, load the zebra and isis configuration files + for rname, router in tgen.routers().items(): + router.load_config( + TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) + ) + if os.path.exists("{}/isisd.conf".format(rname)): + router.load_config( + TopoRouter.RD_ISIS, os.path.join(CWD, "{}/isisd.conf".format(rname)) + ) + if os.path.exists("{}/bgpd.conf".format(rname)): + router.load_config( + TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname)) + ) + if os.path.exists("{}/pathd.conf".format(rname)): + router.load_config( + TopoRouter.RD_PATH, os.path.join(CWD, "{}/pathd.conf".format(rname)) + ) + if os.path.exists("{}/staticd.conf".format(rname)): + router.load_config( + TopoRouter.RD_STATIC, os.path.join(CWD, "{}/staticd.conf".format(rname)) + ) + + tgen.gears["rt1"].run("sysctl net.vrf.strict_mode=1") + tgen.gears["rt1"].run("ip link add vrf10 type vrf table 10") + tgen.gears["rt1"].run("ip link set vrf10 up") + tgen.gears["rt1"].run("ip link set eth-src master vrf10") + + tgen.gears["rt6"].run("sysctl net.vrf.strict_mode=1") + tgen.gears["rt6"].run("ip link add vrf10 type vrf table 10") + tgen.gears["rt6"].run("ip link set vrf10 up") + tgen.gears["rt6"].run("sysctl -w net.ipv6.conf.all.seg6_enabled=1") + tgen.gears["rt6"].run("sysctl -w net.ipv6.conf.default.seg6_enabled=1") + tgen.gears["rt6"].run("sysctl -w net.ipv6.conf.eth-rt4.seg6_enabled=1") + tgen.gears["rt6"].run("sysctl -w net.ipv6.conf.eth-rt5.seg6_enabled=1") + + # Start routers + tgen.start_router() + + +def teardown_module(mod): + "Teardown the pytest environment" + + # Teardown the topology + tgen = get_topogen() + tgen.stop_topology() + + +def router_compare_json_output(rname, command, reference): + "Compare router JSON output" + + logger.info('Comparing router "%s" "%s" output', rname, command) + + tgen = get_topogen() + filename = "{}/{}/{}".format(CWD, rname, reference) + expected = json.loads(open(filename).read()) + + # Run test function until we get an result. Wait at most 60 seconds. + test_func = functools.partial( + topotest.router_json_cmp, tgen.gears[rname], command, expected + ) + _, diff = topotest.run_and_expect(test_func, None, count=120, wait=0.5) + assertmsg = '"{}" JSON output mismatches the expected result'.format(rname) + assert diff is None, assertmsg + + +def check_ping6(name, dest_addr, expect_connected): + def _check(name, dest_addr, match): + tgen = get_topogen() + output = tgen.gears[name].run("ping6 {} -c 1 -w 1".format(dest_addr)) + logger.info(output) + if match not in output: + return "ping fail" + + match = "{} packet loss".format("0%" if expect_connected else "100%") + logger.info("[+] check {} {} {}".format(name, dest_addr, match)) + tgen = get_topogen() + func = functools.partial(_check, name, dest_addr, match) + success, result = topotest.run_and_expect(func, None, count=10, wait=1) + assert result is None, "Failed" + + +# +# Step 1 +# +# Test initial network convergence +# +def test_isis_adjacencies_step1(): + logger.info("Test (step 1): check IS-IS adjacencies") + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + for rname in ["rt1"]: + router_compare_json_output( + rname, + "show yang operational-data /frr-interface:lib isisd", + "step1/show_yang_interface_isis_adjacencies.ref", + ) + + +def test_rib_ipv4_step1(): + logger.info("Test (step 1): verify IPv4 RIB") + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + for rname in ["rt1"]: + router_compare_json_output( + rname, "show ip route isis json", "step1/show_ip_route.ref" + ) + + +def test_rib_ipv6_step1(): + logger.info("Test (step 1): verify IPv6 RIB") + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + for rname in ["rt1"]: + router_compare_json_output( + rname, "show ipv6 route isis json", "step1/show_ipv6_route.ref" + ) + + +def test_srv6_locator_step1(): + logger.info("Test (step 1): verify SRv6 Locator") + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + for rname in ["rt1"]: + router_compare_json_output( + rname, + "show segment-routing srv6 locator json", + "step1/show_srv6_locator_table.ref", + ) + + +# +# Step 2 +# +# Test SRv6 TE Policy activted +# + + +def test_srv6_te_policy_activated(): + logger.info("Test (step 2): verify SRv6 TE policy activated") + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + tgen.gears["rt1"].vtysh_cmd( + "configure \n \ + ipv6 route 2001:db8:10::/64 fc00:0:6:: color 1 \n \ + segment-routing \n \ + traffic-eng \n \ + policy color 1 endpoint fc00:0:6:: \n \ + candidate-path preference 1 name srv6 explicit segment-list srv6-header \n \ + exit \ + exit \ + exit \ + !" + ) + + for rname in ["rt1"]: + router_compare_json_output( + rname, + "show ipv6 route static json", + "step2/show_srv6_route.ref", + ) + + +# +# Step 3 +# +# Test SRv6 additional srv6 route. +# + + +def test_srv6_te_policy_additional_route(): + logger.info("Test (step 3): verify SRv6 TE additional route") + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + tgen.gears["rt1"].vtysh_cmd( + "configure \n \ + no ipv6 route 2001:db8:10::/64 fc00:0:6:: color 1 \n \ + ipv6 route fc00:0:6b::/48 fc00:0:6:: color 1 \n \ + exit \ + !" + ) + + # Add this to use 'eth-dst' if for BGP tests. + tgen.gears["rt6"].run("ip link set eth-dst master vrf10") + + for rname in ["rt1"]: + router_compare_json_output( + rname, + "show ipv6 route static json", + "step3/show_srv6_additional_route.ref", + ) + + +# +# Step 4 +# +# Test SRv6 TE Policy removed +# + + +def test_srv6_te_policy_removed(): + logger.info("Test (step 3): verify SRv6 TE policy removed") + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + tgen.gears["rt1"].vtysh_cmd( + "configure \n \ + segment-routing \n \ + traffic-eng \n \ + no policy color 1 endpoint fc00:0:6:: \n \ + exit \ + exit \ + exit \ + !" + ) + + for rname in ["rt1"]: + router_compare_json_output( + rname, + "show ipv6 route static json", + "step4/show_ipv6_route.ref", + ) + + +# Memory leak test template +def test_memory_leak(): + "Run the memory leak test and report results." + tgen = get_topogen() + if not tgen.is_memleak_enabled(): + pytest.skip("Memory leak test/report is disabled") + + tgen.report_memory_leaks() + + +if __name__ == "__main__": + args = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(args))