From 2c7cac91ed6e7db0f6937923d2b57f97dbdbc337 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:53:30 +0200 Subject: Adding upstream version 8.4.4. Signed-off-by: Daniel Baumann --- tests/topotests/isis_sr_te_topo1/dst/zebra.conf | 19 + tests/topotests/isis_sr_te_topo1/rt1/bgpd.conf | 16 + tests/topotests/isis_sr_te_topo1/rt1/isisd.conf | 30 + tests/topotests/isis_sr_te_topo1/rt1/pathd.conf | 21 + .../rt1/step1/show_mpls_table_with_candidate.ref | 91 +++ .../step1/show_mpls_table_without_candidate.ref | 74 ++ .../rt1/step2/show_operational_data.ref | 13 + .../step2/show_operational_data_with_candidate.ref | 20 + ...show_operational_data_with_single_candidate.ref | 20 + .../show_operational_data_with_two_candidates.ref | 25 + .../isis_sr_te_topo1/rt1/step4/show_mpls_table.ref | 20 + .../rt1/step4/show_mpls_table_add_segment.ref | 21 + .../rt1/step4/show_mpls_table_change_segment.ref | 21 + .../rt1/step5/show_ip_route_bgp_active_srte.ref | 29 + .../rt1/step5/show_ip_route_bgp_empty.ref | 2 + .../rt1/step5/show_ip_route_bgp_inactive_srte.ref | 38 + .../rt1/step5/show_operational_data_active.ref | 20 + .../rt1/step5/show_operational_data_inactive.ref | 20 + tests/topotests/isis_sr_te_topo1/rt1/zebra.conf | 19 + tests/topotests/isis_sr_te_topo1/rt2/isisd.conf | 41 + tests/topotests/isis_sr_te_topo1/rt2/zebra.conf | 25 + tests/topotests/isis_sr_te_topo1/rt3/isisd.conf | 41 + tests/topotests/isis_sr_te_topo1/rt3/zebra.conf | 25 + tests/topotests/isis_sr_te_topo1/rt4/isisd.conf | 48 ++ tests/topotests/isis_sr_te_topo1/rt4/zebra.conf | 28 + tests/topotests/isis_sr_te_topo1/rt5/isisd.conf | 48 ++ tests/topotests/isis_sr_te_topo1/rt5/zebra.conf | 28 + tests/topotests/isis_sr_te_topo1/rt6/bgpd.conf | 12 + tests/topotests/isis_sr_te_topo1/rt6/isisd.conf | 36 + tests/topotests/isis_sr_te_topo1/rt6/pathd.conf | 21 + .../rt6/step1/show_mpls_table_with_candidate.ref | 91 +++ .../step1/show_mpls_table_without_candidate.ref | 74 ++ .../rt6/step2/show_operational_data.ref | 13 + .../step2/show_operational_data_with_candidate.ref | 19 + ...show_operational_data_with_single_candidate.ref | 19 + .../show_operational_data_with_two_candidates.ref | 23 + .../isis_sr_te_topo1/rt6/step4/show_mpls_table.ref | 20 + tests/topotests/isis_sr_te_topo1/rt6/zebra.conf | 27 + .../isis_sr_te_topo1/test_isis_sr_te_topo1.py | 870 +++++++++++++++++++++ 39 files changed, 2028 insertions(+) create mode 100644 tests/topotests/isis_sr_te_topo1/dst/zebra.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/bgpd.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/isisd.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/pathd.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step1/show_mpls_table_with_candidate.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step1/show_mpls_table_without_candidate.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step2/show_operational_data.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step2/show_operational_data_with_candidate.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step3/show_operational_data_with_single_candidate.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step3/show_operational_data_with_two_candidates.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step4/show_mpls_table.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step4/show_mpls_table_add_segment.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step4/show_mpls_table_change_segment.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step5/show_ip_route_bgp_active_srte.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step5/show_ip_route_bgp_empty.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step5/show_ip_route_bgp_inactive_srte.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step5/show_operational_data_active.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/step5/show_operational_data_inactive.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt1/zebra.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt2/isisd.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt2/zebra.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt3/isisd.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt3/zebra.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt4/isisd.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt4/zebra.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt5/isisd.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt5/zebra.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt6/bgpd.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt6/isisd.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt6/pathd.conf create mode 100644 tests/topotests/isis_sr_te_topo1/rt6/step1/show_mpls_table_with_candidate.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt6/step1/show_mpls_table_without_candidate.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt6/step2/show_operational_data.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt6/step2/show_operational_data_with_candidate.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt6/step3/show_operational_data_with_single_candidate.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt6/step3/show_operational_data_with_two_candidates.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt6/step4/show_mpls_table.ref create mode 100644 tests/topotests/isis_sr_te_topo1/rt6/zebra.conf create mode 100755 tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py (limited to 'tests/topotests/isis_sr_te_topo1') diff --git a/tests/topotests/isis_sr_te_topo1/dst/zebra.conf b/tests/topotests/isis_sr_te_topo1/dst/zebra.conf new file mode 100644 index 0000000..0c7937b --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/dst/zebra.conf @@ -0,0 +1,19 @@ +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 2001:db8:1066::2/128 +! +interface eth-rt6 + ip address 10.0.11.2/24 +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/isis_sr_te_topo1/rt1/bgpd.conf b/tests/topotests/isis_sr_te_topo1/rt1/bgpd.conf new file mode 100644 index 0000000..efc0370 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/bgpd.conf @@ -0,0 +1,16 @@ +log file bgpd.log +! +router bgp 1 + bgp router-id 1.1.1.1 + neighbor 6.6.6.6 remote-as 1 + neighbor 6.6.6.6 update-source lo + ! + address-family ipv4 unicast + redistribute static + neighbor 6.6.6.6 next-hop-self + neighbor 6.6.6.6 route-map SET_SR_POLICY in + exit-address-family +! +route-map SET_SR_POLICY permit 10 + set sr-te color 1 +! diff --git a/tests/topotests/isis_sr_te_topo1/rt1/isisd.conf b/tests/topotests/isis_sr_te_topo1/rt1/isisd.conf new file mode 100644 index 0000000..3d5ac20 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/isisd.conf @@ -0,0 +1,30 @@ +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-multiplier 3 +! +router isis 1 + net 49.0000.0000.0000.0001.00 + is-type level-1 + topology ipv6-unicast + segment-routing on + segment-routing global-block 16000 23999 + segment-routing node-msd 8 + segment-routing prefix 1.1.1.1/32 index 10 + segment-routing prefix 2001:db8:1000::1/128 index 11 +! diff --git a/tests/topotests/isis_sr_te_topo1/rt1/pathd.conf b/tests/topotests/isis_sr_te_topo1/rt1/pathd.conf new file mode 100644 index 0000000..9119714 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/pathd.conf @@ -0,0 +1,21 @@ +log file pathd.log +! +hostname rt1 +! +segment-routing + traffic-eng + segment-list default + index 10 mpls label 16050 + index 20 mpls label 16060 + ! + segment-list test + index 10 mpls label 16020 + index 20 mpls label 16040 + index 30 mpls label 16060 + ! + policy color 1 endpoint 6.6.6.6 + name default + binding-sid 1111 + ! + ! +! \ No newline at end of file diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step1/show_mpls_table_with_candidate.ref b/tests/topotests/isis_sr_te_topo1/rt1/step1/show_mpls_table_with_candidate.ref new file mode 100644 index 0000000..d4b27d1 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step1/show_mpls_table_with_candidate.ref @@ -0,0 +1,91 @@ +{ + "1111":{ + "inLabel":1111, + "installed":true, + "nexthops":[ + { + "type":"SR-TE", + "outLabel":16050, + "outLabelStack":[ + 16050, + 16060 + ], + "distance":150, + "installed":true, + "nexthop":"10.0.1.3" + } + ] + }, + "16020":{ + "inLabel":16020, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16020, + "distance":150, + "installed":true, + "nexthop":"10.0.1.2" + } + ] + }, + "16030":{ + "inLabel":16030, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16030, + "distance":150, + "installed":true, + "nexthop":"10.0.1.3" + } + ] + }, + "16040":{ + "inLabel":16040, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16040, + "distance":150, + "installed":true, + "nexthop":"10.0.1.2" + } + ] + }, + "16050":{ + "inLabel":16050, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16050, + "distance":150, + "installed":true, + "nexthop":"10.0.1.3" + } + ] + }, + "16060":{ + "inLabel":16060, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16060, + "distance":150, + "installed":true, + "nexthop":"10.0.1.3" + }, + { + "type":"SR (IS-IS)", + "outLabel":16060, + "distance":150, + "installed":true, + "nexthop":"10.0.1.2" + } + ] + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step1/show_mpls_table_without_candidate.ref b/tests/topotests/isis_sr_te_topo1/rt1/step1/show_mpls_table_without_candidate.ref new file mode 100644 index 0000000..5fe58d0 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step1/show_mpls_table_without_candidate.ref @@ -0,0 +1,74 @@ +{ + "16020":{ + "inLabel":16020, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16020, + "distance":150, + "installed":true, + "nexthop":"10.0.1.2" + } + ] + }, + "16030":{ + "inLabel":16030, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16030, + "distance":150, + "installed":true, + "nexthop":"10.0.1.3" + } + ] + }, + "16040":{ + "inLabel":16040, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16040, + "distance":150, + "installed":true, + "nexthop":"10.0.1.2" + } + ] + }, + "16050":{ + "inLabel":16050, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16050, + "distance":150, + "installed":true, + "nexthop":"10.0.1.3" + } + ] + }, + "16060":{ + "inLabel":16060, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16060, + "distance":150, + "installed":true, + "nexthop":"10.0.1.3" + }, + { + "type":"SR (IS-IS)", + "outLabel":16060, + "distance":150, + "installed":true, + "nexthop":"10.0.1.2" + } + ] + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step2/show_operational_data.ref b/tests/topotests/isis_sr_te_topo1/rt1/step2/show_operational_data.ref new file mode 100644 index 0000000..4ef8d94 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step2/show_operational_data.ref @@ -0,0 +1,13 @@ +{ + "frr-pathd:pathd": { + "srte": { + "policy": [ + { + "color": 1, + "endpoint": "6.6.6.6", + "is-operational": false + } + ] + } + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step2/show_operational_data_with_candidate.ref b/tests/topotests/isis_sr_te_topo1/rt1/step2/show_operational_data_with_candidate.ref new file mode 100644 index 0000000..9b28f6a --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step2/show_operational_data_with_candidate.ref @@ -0,0 +1,20 @@ +{ + "frr-pathd:pathd": { + "srte": { + "policy": [ + { + "color": 1, + "endpoint": "6.6.6.6", + "is-operational": true, + "candidate-path": [ + { + "preference": 100, + "discriminator": "*", + "is-best-candidate-path": true + } + ] + } + ] + } + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step3/show_operational_data_with_single_candidate.ref b/tests/topotests/isis_sr_te_topo1/rt1/step3/show_operational_data_with_single_candidate.ref new file mode 100644 index 0000000..9b28f6a --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step3/show_operational_data_with_single_candidate.ref @@ -0,0 +1,20 @@ +{ + "frr-pathd:pathd": { + "srte": { + "policy": [ + { + "color": 1, + "endpoint": "6.6.6.6", + "is-operational": true, + "candidate-path": [ + { + "preference": 100, + "discriminator": "*", + "is-best-candidate-path": true + } + ] + } + ] + } + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step3/show_operational_data_with_two_candidates.ref b/tests/topotests/isis_sr_te_topo1/rt1/step3/show_operational_data_with_two_candidates.ref new file mode 100644 index 0000000..2491171 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step3/show_operational_data_with_two_candidates.ref @@ -0,0 +1,25 @@ +{ + "frr-pathd:pathd": { + "srte": { + "policy": [ + { + "color": 1, + "endpoint": "6.6.6.6", + "is-operational": true, + "candidate-path": [ + { + "preference": 100, + "discriminator": "*", + "is-best-candidate-path": false + }, + { + "preference": 200, + "discriminator": "*", + "is-best-candidate-path": true + } + ] + } + ] + } + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step4/show_mpls_table.ref b/tests/topotests/isis_sr_te_topo1/rt1/step4/show_mpls_table.ref new file mode 100644 index 0000000..21f71f1 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step4/show_mpls_table.ref @@ -0,0 +1,20 @@ +{ + "1111":{ + "inLabel":1111, + "installed":true, + "nexthops":[ + { + "type":"SR-TE", + "outLabel":16020, + "outLabelStack":[ + 16020, + 16040, + 16060 + ], + "distance":150, + "installed":true, + "nexthop":"10.0.1.2" + } + ] + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step4/show_mpls_table_add_segment.ref b/tests/topotests/isis_sr_te_topo1/rt1/step4/show_mpls_table_add_segment.ref new file mode 100644 index 0000000..3635c89 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step4/show_mpls_table_add_segment.ref @@ -0,0 +1,21 @@ +{ + "1111":{ + "inLabel":1111, + "installed":true, + "nexthops":[ + { + "type":"SR-TE", + "outLabel":16020, + "outLabelStack":[ + 16020, + 16040, + 16050, + 16060 + ], + "distance":150, + "installed":true, + "nexthop":"10.0.1.2" + } + ] + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step4/show_mpls_table_change_segment.ref b/tests/topotests/isis_sr_te_topo1/rt1/step4/show_mpls_table_change_segment.ref new file mode 100644 index 0000000..5712d21 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step4/show_mpls_table_change_segment.ref @@ -0,0 +1,21 @@ +{ + "1111":{ + "inLabel":1111, + "installed":true, + "nexthops":[ + { + "type":"SR-TE", + "outLabel":16020, + "outLabelStack":[ + 16020, + 16040, + 16030, + 16060 + ], + "distance":150, + "installed":true, + "nexthop":"10.0.1.2" + } + ] + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step5/show_ip_route_bgp_active_srte.ref b/tests/topotests/isis_sr_te_topo1/rt1/step5/show_ip_route_bgp_active_srte.ref new file mode 100644 index 0000000..5a76246 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step5/show_ip_route_bgp_active_srte.ref @@ -0,0 +1,29 @@ +{ + "9.9.9.2\/32":[ + { + "prefix":"9.9.9.2\/32", + "protocol":"bgp", + "installed":true, + "nexthops":[ + { + "ip":"6.6.6.6", + "afi":"ipv4", + "active":true, + "recursive":true, + "srteColor":1 + }, + { + "fib":true, + "ip":"10.0.1.3", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true, + "labels":[ + 16050, + 16060 + ] + } + ] + } + ] +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step5/show_ip_route_bgp_empty.ref b/tests/topotests/isis_sr_te_topo1/rt1/step5/show_ip_route_bgp_empty.ref new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step5/show_ip_route_bgp_empty.ref @@ -0,0 +1,2 @@ +{ +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step5/show_ip_route_bgp_inactive_srte.ref b/tests/topotests/isis_sr_te_topo1/rt1/step5/show_ip_route_bgp_inactive_srte.ref new file mode 100644 index 0000000..09d5958 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step5/show_ip_route_bgp_inactive_srte.ref @@ -0,0 +1,38 @@ +{ + "9.9.9.2\/32":[ + { + "prefix":"9.9.9.2\/32", + "protocol":"bgp", + "installed":true, + "nexthops":[ + { + "ip":"6.6.6.6", + "afi":"ipv4", + "active":true, + "recursive":true, + "srteColor":1 + }, + { + "fib":true, + "ip":"10.0.1.2", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true, + "labels":[ + 16060 + ] + }, + { + "fib":true, + "ip":"10.0.1.3", + "afi":"ipv4", + "interfaceName":"eth-sw1", + "active":true, + "labels":[ + 16060 + ] + } + ] + } + ] +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step5/show_operational_data_active.ref b/tests/topotests/isis_sr_te_topo1/rt1/step5/show_operational_data_active.ref new file mode 100644 index 0000000..e26039b --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step5/show_operational_data_active.ref @@ -0,0 +1,20 @@ +{ + "frr-pathd:pathd": { + "srte": { + "policy": [ + { + "color": 1, + "endpoint": "6.6.6.6", + "is-operational": true, + "candidate-path": [ + { + "preference": 100, + "discriminator": "*", + "is-best-candidate-path": true + } + ] + } + ] + } + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/step5/show_operational_data_inactive.ref b/tests/topotests/isis_sr_te_topo1/rt1/step5/show_operational_data_inactive.ref new file mode 100644 index 0000000..01505c0 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/step5/show_operational_data_inactive.ref @@ -0,0 +1,20 @@ +{ + "frr-pathd:pathd": { + "srte": { + "policy": [ + { + "color": 1, + "endpoint": "6.6.6.6", + "is-operational": false, + "candidate-path": [ + { + "preference": 100, + "discriminator": "*", + "is-best-candidate-path": true + } + ] + } + ] + } + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt1/zebra.conf b/tests/topotests/isis_sr_te_topo1/rt1/zebra.conf new file mode 100644 index 0000000..37b3f27 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt1/zebra.conf @@ -0,0 +1,19 @@ +log file zebra.log +! +hostname rt1 +! +! debug zebra kernel +! debug zebra packet +! debug zebra mpls +! +interface lo + ip address 1.1.1.1/32 + ipv6 address 2001:db8:1000::1/128 +! +interface eth-sw1 + ip address 10.0.1.1/24 +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/isis_sr_te_topo1/rt2/isisd.conf b/tests/topotests/isis_sr_te_topo1/rt2/isisd.conf new file mode 100644 index 0000000..ba214c9 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt2/isisd.conf @@ -0,0 +1,41 @@ +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-multiplier 3 +! +interface eth-rt4-1 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-multiplier 3 +! +interface eth-rt4-2 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-multiplier 3 +! +router isis 1 + net 49.0000.0000.0000.0002.00 + is-type level-1 + topology ipv6-unicast + segment-routing on + segment-routing global-block 16000 23999 + segment-routing node-msd 8 + segment-routing prefix 2.2.2.2/32 index 20 no-php-flag + segment-routing prefix 2001:db8:1000::2/128 index 21 no-php-flag +! diff --git a/tests/topotests/isis_sr_te_topo1/rt2/zebra.conf b/tests/topotests/isis_sr_te_topo1/rt2/zebra.conf new file mode 100644 index 0000000..f9ac098 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt2/zebra.conf @@ -0,0 +1,25 @@ +log file zebra.log +! +hostname rt2 +! +! debug zebra kernel +! debug zebra packet +! debug zebra mpls +! +interface lo + ip address 2.2.2.2/32 + ipv6 address 2001:db8:1000::2/128 +! +interface eth-sw1 + ip address 10.0.1.2/24 +! +interface eth-rt4-1 + ip address 10.0.2.2/24 +! +interface eth-rt4-2 + ip address 10.0.3.2/24 +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/isis_sr_te_topo1/rt3/isisd.conf b/tests/topotests/isis_sr_te_topo1/rt3/isisd.conf new file mode 100644 index 0000000..482d815 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt3/isisd.conf @@ -0,0 +1,41 @@ +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-multiplier 3 +! +interface eth-rt5-1 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-multiplier 3 +! +interface eth-rt5-2 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-multiplier 3 +! +router isis 1 + net 49.0000.0000.0000.0003.00 + is-type level-1 + topology ipv6-unicast + segment-routing on + segment-routing global-block 16000 23999 + segment-routing node-msd 8 + segment-routing prefix 3.3.3.3/32 index 30 no-php-flag + segment-routing prefix 2001:db8:1000::3/128 index 31 no-php-flag +! diff --git a/tests/topotests/isis_sr_te_topo1/rt3/zebra.conf b/tests/topotests/isis_sr_te_topo1/rt3/zebra.conf new file mode 100644 index 0000000..441c9a3 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt3/zebra.conf @@ -0,0 +1,25 @@ +log file zebra.log +! +hostname rt3 +! +! debug zebra kernel +! debug zebra packet +! debug zebra mpls +! +interface lo + ip address 3.3.3.3/32 + ipv6 address 2001:db8:1000::3/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 +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/isis_sr_te_topo1/rt4/isisd.conf b/tests/topotests/isis_sr_te_topo1/rt4/isisd.conf new file mode 100644 index 0000000..851c6da --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt4/isisd.conf @@ -0,0 +1,48 @@ +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-multiplier 3 +! +interface eth-rt2-2 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-multiplier 3 +! +interface eth-rt5 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-multiplier 3 +! +interface eth-rt6 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-multiplier 3 +! +router isis 1 + net 49.0000.0000.0000.0004.00 + is-type level-1 + topology ipv6-unicast + segment-routing on + segment-routing global-block 16000 23999 + segment-routing node-msd 8 + segment-routing prefix 4.4.4.4/32 index 40 no-php-flag + segment-routing prefix 2001:db8:1000::4/128 index 41 no-php-flag +! diff --git a/tests/topotests/isis_sr_te_topo1/rt4/zebra.conf b/tests/topotests/isis_sr_te_topo1/rt4/zebra.conf new file mode 100644 index 0000000..a2569aa --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt4/zebra.conf @@ -0,0 +1,28 @@ +log file zebra.log +! +hostname rt4 +! +! debug zebra kernel +! debug zebra packet +! debug zebra mpls +! +interface lo + ip address 4.4.4.4/32 + ipv6 address 2001:db8:1000::4/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 +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/isis_sr_te_topo1/rt5/isisd.conf b/tests/topotests/isis_sr_te_topo1/rt5/isisd.conf new file mode 100644 index 0000000..4cc54f3 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt5/isisd.conf @@ -0,0 +1,48 @@ +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-multiplier 3 +! +interface eth-rt3-2 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-multiplier 3 +! +interface eth-rt4 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-multiplier 3 +! +interface eth-rt6 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-multiplier 3 +! +router isis 1 + net 49.0000.0000.0000.0005.00 + is-type level-1 + topology ipv6-unicast + segment-routing on + segment-routing global-block 16000 23999 + segment-routing node-msd 8 + segment-routing prefix 5.5.5.5/32 index 50 no-php-flag + segment-routing prefix 2001:db8:1000::5/128 index 51 no-php-flag +! diff --git a/tests/topotests/isis_sr_te_topo1/rt5/zebra.conf b/tests/topotests/isis_sr_te_topo1/rt5/zebra.conf new file mode 100644 index 0000000..f62cc8f --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt5/zebra.conf @@ -0,0 +1,28 @@ +log file zebra.log +! +hostname rt5 +! +! debug zebra kernel +! debug zebra packet +! debug zebra mpls +! +interface lo + ip address 5.5.5.5/32 + ipv6 address 2001:db8:1000::5/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 +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/isis_sr_te_topo1/rt6/bgpd.conf b/tests/topotests/isis_sr_te_topo1/rt6/bgpd.conf new file mode 100644 index 0000000..e72ee52 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt6/bgpd.conf @@ -0,0 +1,12 @@ +log file bgpd.log +! +router bgp 1 + bgp router-id 6.6.6.6 + neighbor 1.1.1.1 remote-as 1 + neighbor 1.1.1.1 update-source lo + ! + address-family ipv4 unicast + redistribute static + neighbor 1.1.1.1 next-hop-self + exit-address-family +! diff --git a/tests/topotests/isis_sr_te_topo1/rt6/isisd.conf b/tests/topotests/isis_sr_te_topo1/rt6/isisd.conf new file mode 100644 index 0000000..8fec87b --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt6/isisd.conf @@ -0,0 +1,36 @@ +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-multiplier 3 +! +interface eth-rt5 + ip router isis 1 + ipv6 router isis 1 + isis network point-to-point + isis hello-multiplier 3 +! +router isis 1 + net 49.0000.0000.0000.0006.00 + is-type level-1 + topology ipv6-unicast + segment-routing on + segment-routing global-block 16000 23999 + segment-routing node-msd 8 + segment-routing prefix 6.6.6.6/32 index 60 + segment-routing prefix 2001:db8:1000::6/128 index 61 +! diff --git a/tests/topotests/isis_sr_te_topo1/rt6/pathd.conf b/tests/topotests/isis_sr_te_topo1/rt6/pathd.conf new file mode 100644 index 0000000..3bada71 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt6/pathd.conf @@ -0,0 +1,21 @@ +log file pathd.log +! +hostname rt6 +! +segment-routing + traffic-eng + segment-list default + index 10 mpls label 16020 + index 20 mpls label 16010 + ! + segment-list test + index 10 mpls label 16050 + index 20 mpls label 16030 + index 30 mpls label 16010 + ! + policy color 1 endpoint 1.1.1.1 + name default + binding-sid 6666 + ! + ! +! diff --git a/tests/topotests/isis_sr_te_topo1/rt6/step1/show_mpls_table_with_candidate.ref b/tests/topotests/isis_sr_te_topo1/rt6/step1/show_mpls_table_with_candidate.ref new file mode 100644 index 0000000..2bb0003 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt6/step1/show_mpls_table_with_candidate.ref @@ -0,0 +1,91 @@ +{ + "6666":{ + "inLabel":6666, + "installed":true, + "nexthops":[ + { + "type":"SR-TE", + "outLabel":16020, + "outLabelStack":[ + 16020, + 16010 + ], + "distance":150, + "installed":true, + "nexthop":"10.0.7.4" + } + ] + }, + "16010": { + "inLabel": 16010, + "installed": true, + "nexthops": [ + { + "distance": 150, + "installed": true, + "nexthop": "10.0.7.4", + "outLabel": 16010, + "type": "SR (IS-IS)" + }, + { + "distance": 150, + "installed": true, + "nexthop": "10.0.8.5", + "outLabel": 16010, + "type": "SR (IS-IS)" + } + ] + }, + "16020":{ + "inLabel":16020, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16020, + "distance":150, + "installed":true, + "nexthop":"10.0.7.4" + } + ] + }, + "16030":{ + "inLabel":16030, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16030, + "distance":150, + "installed":true, + "nexthop":"10.0.8.5" + } + ] + }, + "16040":{ + "inLabel":16040, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16040, + "distance":150, + "installed":true, + "nexthop":"10.0.7.4" + } + ] + }, + "16050":{ + "inLabel":16050, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16050, + "distance":150, + "installed":true, + "nexthop":"10.0.8.5" + } + ] + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt6/step1/show_mpls_table_without_candidate.ref b/tests/topotests/isis_sr_te_topo1/rt6/step1/show_mpls_table_without_candidate.ref new file mode 100644 index 0000000..348f776 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt6/step1/show_mpls_table_without_candidate.ref @@ -0,0 +1,74 @@ +{ + "16010": { + "inLabel": 16010, + "installed": true, + "nexthops": [ + { + "distance": 150, + "installed": true, + "nexthop": "10.0.7.4", + "outLabel": 16010, + "type": "SR (IS-IS)" + }, + { + "distance": 150, + "installed": true, + "nexthop": "10.0.8.5", + "outLabel": 16010, + "type": "SR (IS-IS)" + } + ] + }, + "16020":{ + "inLabel":16020, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16020, + "distance":150, + "installed":true, + "nexthop":"10.0.7.4" + } + ] + }, + "16030":{ + "inLabel":16030, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16030, + "distance":150, + "installed":true, + "nexthop":"10.0.8.5" + } + ] + }, + "16040":{ + "inLabel":16040, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16040, + "distance":150, + "installed":true, + "nexthop":"10.0.7.4" + } + ] + }, + "16050":{ + "inLabel":16050, + "installed":true, + "nexthops":[ + { + "type":"SR (IS-IS)", + "outLabel":16050, + "distance":150, + "installed":true, + "nexthop":"10.0.8.5" + } + ] + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt6/step2/show_operational_data.ref b/tests/topotests/isis_sr_te_topo1/rt6/step2/show_operational_data.ref new file mode 100644 index 0000000..241c80b --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt6/step2/show_operational_data.ref @@ -0,0 +1,13 @@ +{ + "frr-pathd:pathd": { + "srte": { + "policy": [ + { + "color": 1, + "endpoint": "1.1.1.1", + "is-operational": false + } + ] + } + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt6/step2/show_operational_data_with_candidate.ref b/tests/topotests/isis_sr_te_topo1/rt6/step2/show_operational_data_with_candidate.ref new file mode 100644 index 0000000..20ea69e --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt6/step2/show_operational_data_with_candidate.ref @@ -0,0 +1,19 @@ +{ + "frr-pathd:pathd": { + "srte": { + "policy": [ + { + "color": 1, + "endpoint": "1.1.1.1", + "is-operational": true, + "candidate-path": [ + { + "preference": 100, + "is-best-candidate-path": true + } + ] + } + ] + } + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt6/step3/show_operational_data_with_single_candidate.ref b/tests/topotests/isis_sr_te_topo1/rt6/step3/show_operational_data_with_single_candidate.ref new file mode 100644 index 0000000..20ea69e --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt6/step3/show_operational_data_with_single_candidate.ref @@ -0,0 +1,19 @@ +{ + "frr-pathd:pathd": { + "srte": { + "policy": [ + { + "color": 1, + "endpoint": "1.1.1.1", + "is-operational": true, + "candidate-path": [ + { + "preference": 100, + "is-best-candidate-path": true + } + ] + } + ] + } + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt6/step3/show_operational_data_with_two_candidates.ref b/tests/topotests/isis_sr_te_topo1/rt6/step3/show_operational_data_with_two_candidates.ref new file mode 100644 index 0000000..10cafe9 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt6/step3/show_operational_data_with_two_candidates.ref @@ -0,0 +1,23 @@ +{ + "frr-pathd:pathd": { + "srte": { + "policy": [ + { + "color": 1, + "endpoint": "1.1.1.1", + "is-operational": true, + "candidate-path": [ + { + "preference": 100, + "is-best-candidate-path": false + }, + { + "preference": 200, + "is-best-candidate-path": true + } + ] + } + ] + } + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt6/step4/show_mpls_table.ref b/tests/topotests/isis_sr_te_topo1/rt6/step4/show_mpls_table.ref new file mode 100644 index 0000000..95bf995 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt6/step4/show_mpls_table.ref @@ -0,0 +1,20 @@ +{ + "6666":{ + "inLabel":6666, + "installed":true, + "nexthops":[ + { + "type":"SR-TE", + "outLabel":16050, + "outLabelStack":[ + 16050, + 16030, + 16010 + ], + "distance":150, + "installed":true, + "nexthop":"10.0.8.5" + } + ] + } +} diff --git a/tests/topotests/isis_sr_te_topo1/rt6/zebra.conf b/tests/topotests/isis_sr_te_topo1/rt6/zebra.conf new file mode 100644 index 0000000..f2f1a3e --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/rt6/zebra.conf @@ -0,0 +1,27 @@ +log file zebra.log +! +hostname rt6 +! +! debug zebra kernel +! debug zebra packet +! debug zebra mpls +! +interface lo + ip address 6.6.6.6/32 + ipv6 address 2001:db8:1000::6/128 +! +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.11.1/24 +! +ip forwarding +! +ip route 9.9.9.2/32 10.0.11.2 +! +line vty +! diff --git a/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py b/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py new file mode 100755 index 0000000..b3b14b5 --- /dev/null +++ b/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py @@ -0,0 +1,870 @@ +#!/usr/bin/env python + +# +# test_isis_sr_topo1.py +# Part of NetDEF Topology Tests +# +# Copyright (c) 2019 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_isis_sr_te_topo1.py: + + +---------+ + | | + | 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.11.0/24 + | + |eth-rt6 (.2) + +---------+ + | | + | DST | + | 9.9.9.2 | + | | + +---------+ + +""" + +import os +import sys +import pytest +import json +from functools import partial + +# Save the Current Working Directory to find configuration files. +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 + +# Required to instantiate the topology builder class. + +pytestmark = [pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.pathd] + + +def build_topo(tgen): + "Build function" + + # + # Define FRR Routers + # + for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "dst"]: + tgen.add_router(router) + + # + # 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") + + +def setup_module(mod): + "Sets up the pytest environment" + + tgen = Topogen(build_topo, mod.__name__) + + frrdir = tgen.config.get(tgen.CONFIG_SECTION, "frrdir") + if not os.path.isfile(os.path.join(frrdir, "pathd")): + pytest.skip("pathd daemon wasn't built") + + tgen.start_topology() + + router_list = tgen.routers() + + # For all registered routers, load the zebra configuration file + for rname, router in router_list.items(): + router.load_config( + TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) + ) + router.load_config( + TopoRouter.RD_ISIS, os.path.join(CWD, "{}/isisd.conf".format(rname)) + ) + router.load_config( + TopoRouter.RD_PATH, os.path.join(CWD, "{}/pathd.conf".format(rname)) + ) + router.load_config( + TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname)) + ) + + tgen.start_router() + + +def teardown_module(mod): + "Teardown the pytest environment" + tgen = get_topogen() + + # This function tears down the whole topology. + tgen.stop_topology() + + +def setup_testcase(msg): + logger.info(msg) + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + return tgen + + +def print_cmd_result(rname, command): + print(get_topogen().gears[rname].vtysh_cmd(command, isjson=False)) + + +def compare_json_test(router, command, reference, exact): + output = router.vtysh_cmd(command, isjson=True) + result = topotest.json_cmp(output, reference) + + # Note: topotest.json_cmp() just checks on inclusion of keys. + # For exact matching also compare the other way around. + if not result and exact: + return topotest.json_cmp(reference, output) + else: + return result + + +def cmp_json_output(rname, command, reference, exact=False): + "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 = partial(compare_json_test, tgen.gears[rname], command, expected, exact) + _, 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 cmp_json_output_exact(rname, command, reference): + return cmp_json_output(rname, command, reference, True) + + +def compare_json_test_inverted(router, command, reference, exact): + "logically inverts result of compare_json_test" + + # None vs something else + result = compare_json_test(router, command, reference, exact) + if result is None: + return "Some" + return None + + +def cmp_json_output_doesnt(rname, command, reference): + "Compare router JSON output, shouldn't include reference" + + logger.info('Comparing (anti) 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 = partial( + compare_json_test_inverted, tgen.gears[rname], command, expected, exact=False + ) + _, 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 dump_json(v): + if isinstance(v, (dict, list)): + return "\t" + "\t".join( + json.dumps(v, indent=4, separators=(",", ": ")).splitlines(True) + ) + else: + return "'{}'".format(v) + + +def add_candidate_path(rname, endpoint, pref, name, segment_list="default", color=1): + get_topogen().net[rname].cmd( + """ \ + vtysh -c "conf t" \ + -c "segment-routing" \ + -c "traffic-eng" \ + -c "policy color """ + + str(color) + + " endpoint " + + endpoint + + """" \ + -c "candidate-path preference """ + + str(pref) + + """ name """ + + name + + """ explicit segment-list """ + + segment_list + + '''"''' + ) + + +def delete_candidate_path(rname, endpoint, pref, color=1): + get_topogen().net[rname].cmd( + """ \ + vtysh -c "conf t" \ + -c "segment-routing" \ + -c "traffic-eng" \ + -c "policy color """ + + str(color) + + " endpoint " + + endpoint + + """" \ + -c "no candidate-path preference """ + + str(pref) + + '''"''' + ) + + +def add_segment(rname, name, index, label): + get_topogen().net[rname].cmd( + """ \ + vtysh -c "conf t" \ + -c "segment-routing" \ + -c "traffic-eng" \ + -c "segment-list """ + + name + + """" \ + -c "index """ + + str(index) + + """ mpls label """ + + str(label) + + '''"''' + ) + + +def delete_segment(rname, name, index): + get_topogen().net[rname].cmd( + """ \ + vtysh -c "conf t" \ + -c "segment-routing" \ + -c "traffic-eng" \ + -c "segment-list """ + + name + + """" \ + -c "no index """ + + str(index) + + '''"''' + ) + + +def create_sr_policy(rname, endpoint, bsid): + get_topogen().net[rname].cmd( + """ \ + vtysh -c "conf t" \ + -c "segment-routing" \ + -c "traffic-eng" \ + -c "policy color 1 endpoint """ + + endpoint + + """" \ + -c "name default" \ + -c "binding-sid """ + + str(bsid) + + '''"''' + ) + + +def delete_sr_policy(rname, endpoint): + get_topogen().net[rname].cmd( + """ \ + vtysh -c "conf t" \ + -c "segment-routing" \ + -c "traffic-eng" \ + -c "no policy color 1 endpoint """ + + endpoint + + '''"''' + ) + + +def create_prefix_sid(rname, prefix, sid): + get_topogen().net[rname].cmd( + """ \ + vtysh -c "conf t" \ + -c "router isis 1" \ + -c "segment-routing prefix """ + + prefix + + " index " + + str(sid) + + '''"''' + ) + + +def delete_prefix_sid(rname, prefix): + get_topogen().net[rname].cmd( + ''' \ + vtysh -c "conf t" \ + -c "router isis 1" \ + -c "no segment-routing prefix "''' + + prefix + ) + + +def set_route_map_color(rname, color): + get_topogen().net[rname].cmd( + ''' \ + vtysh -c "conf t" \ + -c "route-map SET_SR_POLICY permit 10" \ + -c "set sr-te color "''' + + str(color) + ) + + +def router_bgp_shutdown_neighbor(rname, neighbor): + get_topogen().net[rname].cmd( + """ \ + vtysh -c "conf t" \ + -c "router bgp 1" \ + -c " neighbor """ + + neighbor + + ' shutdown"' + ) + + +def router_bgp_no_shutdown_neighbor(rname, neighbor): + get_topogen().net[rname].cmd( + """ \ + vtysh -c "conf t" \ + -c "router bgp 1" \ + -c " no neighbor """ + + neighbor + + ' shutdown"' + ) + + +def show_running_cfg(rname): + output = ( + get_topogen() + .net[rname] + .cmd( + """ \ + vtysh -c "show run" """ + ) + ) + logger.info(output) + + +# +# Step 1 +# +# Checking the MPLS table using a single SR Policy and a single Candidate Path +# +def test_srte_init_step1(): + setup_testcase("Test (step 1): wait for IS-IS convergence / label distribution") + + for rname in ["rt1", "rt6"]: + cmp_json_output( + rname, "show mpls table json", "step1/show_mpls_table_without_candidate.ref" + ) + + +def test_srte_add_candidate_check_mpls_table_step1(): + setup_testcase("Test (step 1): check MPLS table regarding the added Candidate Path") + + for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]: + add_candidate_path(rname, endpoint, 100, "default") + cmp_json_output( + rname, "show mpls table json", "step1/show_mpls_table_with_candidate.ref" + ) + delete_candidate_path(rname, endpoint, 100) + + +def test_srte_reinstall_sr_policy_check_mpls_table_step1(): + setup_testcase( + "Test (step 1): check MPLS table after the SR Policy was removed and reinstalled" + ) + + for rname, endpoint, bsid in [("rt1", "6.6.6.6", 1111), ("rt6", "1.1.1.1", 6666)]: + add_candidate_path(rname, endpoint, 100, "default") + delete_sr_policy(rname, endpoint) + cmp_json_output( + rname, "show mpls table json", "step1/show_mpls_table_without_candidate.ref" + ) + create_sr_policy(rname, endpoint, bsid) + add_candidate_path(rname, endpoint, 100, "default") + cmp_json_output( + rname, "show mpls table json", "step1/show_mpls_table_with_candidate.ref" + ) + delete_candidate_path(rname, endpoint, 100) + + +# +# Step 2 +# +# Checking pathd operational data using a single SR Policy and a single Candidate Path +# +def test_srte_bare_policy_step2(): + setup_testcase("Test (step 2): bare SR Policy should not be operational") + + for rname in ["rt1", "rt6"]: + cmp_json_output_exact( + rname, + "show yang operational-data /frr-pathd:pathd pathd", + "step2/show_operational_data.ref", + ) + + +def test_srte_add_candidate_check_operational_data_step2(): + setup_testcase( + "Test (step 2): add single Candidate Path, SR Policy should be operational" + ) + + for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]: + add_candidate_path(rname, endpoint, 100, "default") + cmp_json_output( + rname, + "show yang operational-data /frr-pathd:pathd pathd", + "step2/show_operational_data_with_candidate.ref", + ) + + +def test_srte_config_remove_candidate_check_operational_data_step2(): + setup_testcase( + "Test (step 2): remove single Candidate Path, SR Policy should not be operational anymore" + ) + + for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]: + delete_candidate_path(rname, endpoint, 100) + cmp_json_output_exact( + rname, + "show yang operational-data /frr-pathd:pathd pathd", + "step2/show_operational_data.ref", + ) + + +# +# Step 3 +# +# Testing the Candidate Path selection +# +def test_srte_add_two_candidates_step3(): + setup_testcase("Test (step 3): second Candidate Path has higher Priority") + + for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]: + for pref, cand_name in [("100", "first"), ("200", "second")]: + add_candidate_path(rname, endpoint, pref, cand_name) + cmp_json_output( + rname, + "show yang operational-data /frr-pathd:pathd pathd", + "step3/show_operational_data_with_two_candidates.ref", + ) + + # cleanup + for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]: + for pref in ["100", "200"]: + delete_candidate_path(rname, endpoint, pref) + + +def test_srte_add_two_candidates_with_reverse_priority_step3(): + setup_testcase("Test (step 3): second Candidate Path has lower Priority") + + # Use reversed priorities here + for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]: + for pref, cand_name in [("200", "first"), ("100", "second")]: + add_candidate_path(rname, endpoint, pref, cand_name) + cmp_json_output( + rname, + "show yang operational-data /frr-pathd:pathd pathd", + "step3/show_operational_data_with_two_candidates.ref", + ) + + # cleanup + for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]: + for pref in ["100", "200"]: + delete_candidate_path(rname, endpoint, pref) + + +def test_srte_remove_best_candidate_step3(): + setup_testcase("Test (step 3): delete the Candidate Path with higher priority") + + for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]: + for pref, cand_name in [("100", "first"), ("200", "second")]: + add_candidate_path(rname, endpoint, pref, cand_name) + + # Delete candidate with higher priority + for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]: + delete_candidate_path(rname, endpoint, 200) + + # Candidate with lower priority should get active now + for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]: + cmp_json_output( + rname, + "show yang operational-data /frr-pathd:pathd pathd", + "step3/show_operational_data_with_single_candidate.ref", + ) + # cleanup + delete_candidate_path(rname, endpoint, 100) + + +# +# Step 4 +# +# Checking MPLS table with a single SR Policy and a Candidate Path with different Segment Lists and other modifications +# +def test_srte_change_segment_list_check_mpls_table_step4(): + setup_testcase("Test (step 4): check MPLS table for changed Segment List") + + for rname, endpoint in [("rt1", "6.6.6.6"), ("rt6", "1.1.1.1")]: + add_candidate_path(rname, endpoint, 100, "default") + # now change the segment list name + add_candidate_path(rname, endpoint, 100, "default", "test") + cmp_json_output(rname, "show mpls table json", "step4/show_mpls_table.ref") + delete_candidate_path(rname, endpoint, 100) + + +def test_srte_segment_list_add_segment_check_mpls_table_step4(): + setup_testcase( + "Test (step 4): check MPLS table for added (then changed and finally deleted) segment" + ) + + add_candidate_path("rt1", "6.6.6.6", 100, "default", "test") + + # first add a new segment + add_segment("rt1", "test", 25, 16050) + cmp_json_output( + "rt1", "show mpls table json", "step4/show_mpls_table_add_segment.ref" + ) + + # ... then change it ... + add_segment("rt1", "test", 25, 16030) + cmp_json_output( + "rt1", "show mpls table json", "step4/show_mpls_table_change_segment.ref" + ) + + # ... and finally delete it + delete_segment("rt1", "test", 25) + cmp_json_output("rt1", "show mpls table json", "step4/show_mpls_table.ref") + delete_candidate_path("rt1", "6.6.6.6", 100) + + +def save_rt(routername, filename): + save_filename = routername + "/" + filename + tgen = get_topogen() + router = tgen.gears[routername] + + config_output = router.vtysh_cmd("sh run") + + route_output_json = json.loads(router.vtysh_cmd("show ip route bgp json")) + route_output = dump_json(route_output_json) + + f = open(save_filename, "w") + f.write(config_output) + f.write(route_output) + f.close() + + +# +# Step 5 +# +# Checking the nexthop using a single SR Policy and a Candidate Path with configured route-map +# +def test_srte_route_map_with_sr_policy_check_nextop_step5(): + setup_testcase( + "Test (step 5): recursive nexthop learned through BGP neighbour should be aligned with SR Policy from route-map" + ) + + # (re-)build the SR Policy two times to ensure that reinstalling still works + for i in [1, 2]: + cmp_json_output( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_inactive_srte.ref" + ) + + delete_sr_policy("rt1", "6.6.6.6") + cmp_json_output( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_inactive_srte.ref" + ) + + create_sr_policy("rt1", "6.6.6.6", 1111) + cmp_json_output( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_inactive_srte.ref" + ) + + add_candidate_path("rt1", "6.6.6.6", 100, "default") + cmp_json_output( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_active_srte.ref" + ) + + delete_candidate_path("rt1", "6.6.6.6", 100) + + +def test_srte_route_map_sr_policy_vs_route_order_step5(): + setup_testcase( + "Test (step 5): Config policy first, add route after and check route validity" + ) + + # + # BGP route and route-map are already configured. + # route-map sets color 1 on BGP routes + + # Developer: to force pause here + # tgen = get_topogen() + # tgen.mininet_cli() + + # + # Configure policy/path + # + add_candidate_path("rt1", "6.6.6.6", 100, "default", "default", 1) + + # + # Route should be valid + # + logger.info( + "BGP route and route-map are already configured, SR candidate path added after. Route should be valid" + ) + cmp_json_output( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_active_srte.ref" + ) + + # + # shutdown/no-shutdown on BGP neighbor to delete/re-add BGP route + # + router_bgp_shutdown_neighbor("rt1", "6.6.6.6") + router_bgp_no_shutdown_neighbor("rt1", "6.6.6.6") + + # + # Route should be valid (but isn't) + # + logger.info( + "After shutdown + no-shutdown neighbor. Route should be valid, but isn't" + ) + cmp_json_output( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_active_srte.ref" + ) + + # + # delete and re-add policy/path + # + delete_candidate_path("rt1", "6.6.6.6", 100, 1) + add_candidate_path("rt1", "6.6.6.6", 100, "default", "default", 1) + + # + # Route should be valid + # + logger.info("After re-add candidate path. Route should be valid") + cmp_json_output( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_active_srte.ref" + ) + + # Developer: to force pause here + # tgen = get_topogen() + # tgen.mininet_cli() + + # clean up + delete_candidate_path("rt1", "6.6.6.6", 100, 2) + + +def test_srte_route_map_sr_policy_vs_routemap_order_step5(): + setup_testcase( + "Test (step 5): Config policy first, set route-map after and check route validity" + ) + + # + # BGP route and route-map are already configured. + # route-map sets color 1 on BGP routes + # + + # + # Configure policy/path + # + add_candidate_path("rt1", "6.6.6.6", 100, "default", "default", 1) + + # + # Route should be valid + # + logger.info("After add candidate path. Route should be valid") + cmp_json_output( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_active_srte.ref" + ) + + # Developer: to force pause here + # tgen = get_topogen() + # tgen.mininet_cli() + + # + # change route-map color to someting else and back again + # + set_route_map_color("rt1", 2) + logger.info("route-map color was set to 2") + # show_running_cfg("rt1") + # 220625 nexthop no longer becomes empty. Colored routes without + # matching SR policies now fall back to their non-colored equivalent + # nexthops. So the route to 9.9.9.9/32 will now be valid, but with + # different nexthop values. + logger.info("now route table will lose policy-mapped route") + cmp_json_output_doesnt( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_active_srte.ref" + ) + set_route_map_color("rt1", 1) + logger.info("route-map color was set to 1") + # show_running_cfg("rt1") + + # + # Route should be valid (but isn't) + # + logger.info("After change route-map color. Route should be valid, but isn't") + cmp_json_output( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_active_srte.ref" + ) + + # + # delete and re-add policy/path + # + delete_candidate_path("rt1", "6.6.6.6", 100, 1) + add_candidate_path("rt1", "6.6.6.6", 100, "default", "default", 1) + + # + # Route should be valid + # + logger.info("After delete/re-add candidate path. Route should be valid") + cmp_json_output( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_active_srte.ref" + ) + + # Developer: force pause + # tgen = get_topogen() + # tgen.mininet_cli() + + # clean up + delete_candidate_path("rt1", "6.6.6.6", 100, 2) + + +def test_srte_route_map_with_sr_policy_reinstall_prefix_sid_check_nextop_step5(): + setup_testcase( + "Test (step 5): remove and re-install prefix SID on fist path element and check SR Policy activity" + ) + + # first add a candidate path so the SR Policy is active + add_candidate_path("rt1", "6.6.6.6", 100, "default") + cmp_json_output( + "rt1", + "show yang operational-data /frr-pathd:pathd pathd", + "step5/show_operational_data_active.ref", + ) + + # delete prefix SID from first element of the configured path and check + # if the SR Policy is inactive since the label can't be resolved anymore + delete_prefix_sid("rt5", "5.5.5.5/32") + cmp_json_output( + "rt1", + "show yang operational-data /frr-pathd:pathd pathd", + "step5/show_operational_data_inactive.ref", + ) + cmp_json_output( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_inactive_srte.ref" + ) + + # re-create the prefix SID and check if the SR Policy is active + create_prefix_sid("rt5", "5.5.5.5/32", 50) + cmp_json_output( + "rt1", + "show yang operational-data /frr-pathd:pathd pathd", + "step5/show_operational_data_active.ref", + ) + cmp_json_output( + "rt1", "show ip route bgp json", "step5/show_ip_route_bgp_active_srte.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)) -- cgit v1.2.3