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/ldp_topo1/r1/ip_mpls_route.ref | 6 + tests/topotests/ldp_topo1/r1/ldpd.conf | 23 + tests/topotests/ldp_topo1/r1/ospfd.conf | 11 + .../ldp_topo1/r1/show_ip_ospf_neighbor.json | 14 + tests/topotests/ldp_topo1/r1/show_ipv4_route.ref | 7 + .../ldp_topo1/r1/show_mpls_ldp_binding.ref | 8 + .../ldp_topo1/r1/show_mpls_ldp_discovery.ref | 2 + .../ldp_topo1/r1/show_mpls_ldp_interface.ref | 2 + .../ldp_topo1/r1/show_mpls_ldp_neighbor.ref | 2 + tests/topotests/ldp_topo1/r1/show_mpls_table.ref | 8 + tests/topotests/ldp_topo1/r1/zebra.conf | 17 + tests/topotests/ldp_topo1/r2/ip_mpls_route.ref | 3 + tests/topotests/ldp_topo1/r2/ldpd.conf | 25 + tests/topotests/ldp_topo1/r2/ospfd.conf | 19 + .../ldp_topo1/r2/show_ip_ospf_neighbor.json | 42 + tests/topotests/ldp_topo1/r2/show_ipv4_route.ref | 7 + .../ldp_topo1/r2/show_mpls_ldp_binding.ref | 22 + .../ldp_topo1/r2/show_mpls_ldp_discovery.ref | 4 + .../ldp_topo1/r2/show_mpls_ldp_interface.ref | 3 + .../ldp_topo1/r2/show_mpls_ldp_neighbor.ref | 4 + tests/topotests/ldp_topo1/r2/show_mpls_table.ref | 7 + tests/topotests/ldp_topo1/r2/zebra.conf | 27 + tests/topotests/ldp_topo1/r3/ip_mpls_route.ref | 4 + tests/topotests/ldp_topo1/r3/ldpd.conf | 23 + tests/topotests/ldp_topo1/r3/ospfd.conf | 16 + .../ldp_topo1/r3/show_ip_ospf_neighbor.json | 32 + tests/topotests/ldp_topo1/r3/show_ipv4_route.ref | 7 + .../ldp_topo1/r3/show_mpls_ldp_binding.ref | 15 + .../ldp_topo1/r3/show_mpls_ldp_discovery.ref | 3 + .../ldp_topo1/r3/show_mpls_ldp_interface.ref | 2 + .../ldp_topo1/r3/show_mpls_ldp_neighbor.ref | 3 + tests/topotests/ldp_topo1/r3/show_mpls_table.ref | 10 + tests/topotests/ldp_topo1/r3/zebra.conf | 22 + tests/topotests/ldp_topo1/r4/ip_mpls_route.ref | 5 + tests/topotests/ldp_topo1/r4/ldpd.conf | 23 + tests/topotests/ldp_topo1/r4/ospfd.conf | 11 + .../ldp_topo1/r4/show_ip_ospf_neighbor.json | 24 + tests/topotests/ldp_topo1/r4/show_ipv4_route.ref | 7 + .../ldp_topo1/r4/show_mpls_ldp_binding.ref | 15 + .../ldp_topo1/r4/show_mpls_ldp_discovery.ref | 3 + .../ldp_topo1/r4/show_mpls_ldp_interface.ref | 2 + .../ldp_topo1/r4/show_mpls_ldp_neighbor.ref | 3 + tests/topotests/ldp_topo1/r4/show_mpls_table.ref | 9 + tests/topotests/ldp_topo1/r4/zebra.conf | 17 + tests/topotests/ldp_topo1/test_ldp_topo1.py | 857 +++++++++++++++++++++ 45 files changed, 1376 insertions(+) create mode 100644 tests/topotests/ldp_topo1/r1/ip_mpls_route.ref create mode 100644 tests/topotests/ldp_topo1/r1/ldpd.conf create mode 100644 tests/topotests/ldp_topo1/r1/ospfd.conf create mode 100644 tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json create mode 100644 tests/topotests/ldp_topo1/r1/show_ipv4_route.ref create mode 100644 tests/topotests/ldp_topo1/r1/show_mpls_ldp_binding.ref create mode 100644 tests/topotests/ldp_topo1/r1/show_mpls_ldp_discovery.ref create mode 100644 tests/topotests/ldp_topo1/r1/show_mpls_ldp_interface.ref create mode 100644 tests/topotests/ldp_topo1/r1/show_mpls_ldp_neighbor.ref create mode 100644 tests/topotests/ldp_topo1/r1/show_mpls_table.ref create mode 100644 tests/topotests/ldp_topo1/r1/zebra.conf create mode 100644 tests/topotests/ldp_topo1/r2/ip_mpls_route.ref create mode 100644 tests/topotests/ldp_topo1/r2/ldpd.conf create mode 100644 tests/topotests/ldp_topo1/r2/ospfd.conf create mode 100644 tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json create mode 100644 tests/topotests/ldp_topo1/r2/show_ipv4_route.ref create mode 100644 tests/topotests/ldp_topo1/r2/show_mpls_ldp_binding.ref create mode 100644 tests/topotests/ldp_topo1/r2/show_mpls_ldp_discovery.ref create mode 100644 tests/topotests/ldp_topo1/r2/show_mpls_ldp_interface.ref create mode 100644 tests/topotests/ldp_topo1/r2/show_mpls_ldp_neighbor.ref create mode 100644 tests/topotests/ldp_topo1/r2/show_mpls_table.ref create mode 100644 tests/topotests/ldp_topo1/r2/zebra.conf create mode 100644 tests/topotests/ldp_topo1/r3/ip_mpls_route.ref create mode 100644 tests/topotests/ldp_topo1/r3/ldpd.conf create mode 100644 tests/topotests/ldp_topo1/r3/ospfd.conf create mode 100644 tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json create mode 100644 tests/topotests/ldp_topo1/r3/show_ipv4_route.ref create mode 100644 tests/topotests/ldp_topo1/r3/show_mpls_ldp_binding.ref create mode 100644 tests/topotests/ldp_topo1/r3/show_mpls_ldp_discovery.ref create mode 100644 tests/topotests/ldp_topo1/r3/show_mpls_ldp_interface.ref create mode 100644 tests/topotests/ldp_topo1/r3/show_mpls_ldp_neighbor.ref create mode 100644 tests/topotests/ldp_topo1/r3/show_mpls_table.ref create mode 100644 tests/topotests/ldp_topo1/r3/zebra.conf create mode 100644 tests/topotests/ldp_topo1/r4/ip_mpls_route.ref create mode 100644 tests/topotests/ldp_topo1/r4/ldpd.conf create mode 100644 tests/topotests/ldp_topo1/r4/ospfd.conf create mode 100644 tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json create mode 100644 tests/topotests/ldp_topo1/r4/show_ipv4_route.ref create mode 100644 tests/topotests/ldp_topo1/r4/show_mpls_ldp_binding.ref create mode 100644 tests/topotests/ldp_topo1/r4/show_mpls_ldp_discovery.ref create mode 100644 tests/topotests/ldp_topo1/r4/show_mpls_ldp_interface.ref create mode 100644 tests/topotests/ldp_topo1/r4/show_mpls_ldp_neighbor.ref create mode 100644 tests/topotests/ldp_topo1/r4/show_mpls_table.ref create mode 100644 tests/topotests/ldp_topo1/r4/zebra.conf create mode 100644 tests/topotests/ldp_topo1/test_ldp_topo1.py (limited to 'tests/topotests/ldp_topo1') diff --git a/tests/topotests/ldp_topo1/r1/ip_mpls_route.ref b/tests/topotests/ldp_topo1/r1/ip_mpls_route.ref new file mode 100644 index 0000000..a13c1d4 --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/ip_mpls_route.ref @@ -0,0 +1,6 @@ +xx as to xx via inet 10.0.1.2 dev r1-eth0 proto xx +xx as to xx via inet 10.0.1.2 dev r1-eth0 proto xx +xx via inet 10.0.1.2 dev r1-eth0 proto xx +xx via inet 10.0.1.2 dev r1-eth0 proto xx +xx via inet 10.0.1.2 dev r1-eth0 proto xx + diff --git a/tests/topotests/ldp_topo1/r1/ldpd.conf b/tests/topotests/ldp_topo1/r1/ldpd.conf new file mode 100644 index 0000000..f7f2714 --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/ldpd.conf @@ -0,0 +1,23 @@ +hostname r1 +log file ldpd.log +! +! debug mpls ldp zebra +! debug mpls ldp event +! debug mpls ldp errors +! debug mpls ldp messages recv +! debug mpls ldp messages sent +! debug mpls ldp discovery hello recv +! debug mpls ldp discovery hello sent +! +mpls ldp + router-id 1.1.1.1 + ! + address-family ipv4 + discovery transport-address 1.1.1.1 + ! + interface r1-eth0 + ! + ! +! +line vty +! diff --git a/tests/topotests/ldp_topo1/r1/ospfd.conf b/tests/topotests/ldp_topo1/r1/ospfd.conf new file mode 100644 index 0000000..87d5703 --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/ospfd.conf @@ -0,0 +1,11 @@ +hostname r1 +log file ospfd.log +! +router ospf + router-id 1.1.1.1 + network 0.0.0.0/0 area 0 +! +int r1-eth0 + ip ospf hello-interval 2 + ip ospf dead-interval 10 +! diff --git a/tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json new file mode 100644 index 0000000..d9192f1 --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json @@ -0,0 +1,14 @@ +{ + "neighbors": { + "2.2.2.2": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.1.2", + "requestCounter": 0 + } + ] + } +} diff --git a/tests/topotests/ldp_topo1/r1/show_ipv4_route.ref b/tests/topotests/ldp_topo1/r1/show_ipv4_route.ref new file mode 100644 index 0000000..7d39888 --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/show_ipv4_route.ref @@ -0,0 +1,7 @@ +O 1.1.1.1/32 [110/0] is directly connected, lo, weight 1 +O>* 2.2.2.2/32 [110/10] via 10.0.1.2, r1-eth0, label implicit-null, weight 1 +O>* 3.3.3.3/32 [110/20] via 10.0.1.2, r1-eth0, label xxx, weight 1 +O>* 4.4.4.4/32 [110/20] via 10.0.1.2, r1-eth0, label xxx, weight 1 +O 10.0.1.0/24 [110/10] is directly connected, r1-eth0, weight 1 +O>* 10.0.2.0/24 [110/20] via 10.0.1.2, r1-eth0, label implicit-null, weight 1 +O>* 10.0.3.0/24 [110/20] via 10.0.1.2, r1-eth0, label implicit-null, weight 1 diff --git a/tests/topotests/ldp_topo1/r1/show_mpls_ldp_binding.ref b/tests/topotests/ldp_topo1/r1/show_mpls_ldp_binding.ref new file mode 100644 index 0000000..32aa60c --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/show_mpls_ldp_binding.ref @@ -0,0 +1,8 @@ +AF Destination Nexthop Local Label Remote Label In Use +ipv4 1.1.1.1/32 2.2.2.2 imp-null xxx no +ipv4 2.2.2.2/32 2.2.2.2 xxx imp-null yes +ipv4 3.3.3.3/32 2.2.2.2 xxx xxx yes +ipv4 4.4.4.4/32 2.2.2.2 xxx xxx yes +ipv4 10.0.1.0/24 2.2.2.2 imp-null imp-null no +ipv4 10.0.2.0/24 2.2.2.2 xxx imp-null yes +ipv4 10.0.3.0/24 2.2.2.2 xxx imp-null yes diff --git a/tests/topotests/ldp_topo1/r1/show_mpls_ldp_discovery.ref b/tests/topotests/ldp_topo1/r1/show_mpls_ldp_discovery.ref new file mode 100644 index 0000000..373755a --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/show_mpls_ldp_discovery.ref @@ -0,0 +1,2 @@ +AF ID Type Source Holdtime +ipv4 2.2.2.2 Link r1-eth0 15 diff --git a/tests/topotests/ldp_topo1/r1/show_mpls_ldp_interface.ref b/tests/topotests/ldp_topo1/r1/show_mpls_ldp_interface.ref new file mode 100644 index 0000000..0fb15d2 --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/show_mpls_ldp_interface.ref @@ -0,0 +1,2 @@ +AF Interface State Uptime Hello Timers ac +ipv4 r1-eth0 ACTIVE xx:xx:xx 5/15 1 diff --git a/tests/topotests/ldp_topo1/r1/show_mpls_ldp_neighbor.ref b/tests/topotests/ldp_topo1/r1/show_mpls_ldp_neighbor.ref new file mode 100644 index 0000000..29e264f --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/show_mpls_ldp_neighbor.ref @@ -0,0 +1,2 @@ +AF ID State Remote Address Uptime +ipv4 2.2.2.2 OPERATIONAL 2.2.2.2 xx:xx:xx diff --git a/tests/topotests/ldp_topo1/r1/show_mpls_table.ref b/tests/topotests/ldp_topo1/r1/show_mpls_table.ref new file mode 100644 index 0000000..7e24359 --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/show_mpls_table.ref @@ -0,0 +1,8 @@ + Inbound Label Type Nexthop Outbound Label + ----------------------------------------------- + XX LDP 10.0.1.2 XX + XX LDP 10.0.1.2 XX + XX LDP 10.0.1.2 implicit-null + XX LDP 10.0.1.2 implicit-null + XX LDP 10.0.1.2 implicit-null + diff --git a/tests/topotests/ldp_topo1/r1/zebra.conf b/tests/topotests/ldp_topo1/r1/zebra.conf new file mode 100644 index 0000000..55b4b0e --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/zebra.conf @@ -0,0 +1,17 @@ +log file zebra.log +! +hostname r1 +! +interface lo + ip address 1.1.1.1/32 +! +interface r1-eth0 + description to sw0 + ip address 10.0.1.1/24 + no link-detect +! +ip forwarding +! +! +line vty +! diff --git a/tests/topotests/ldp_topo1/r2/ip_mpls_route.ref b/tests/topotests/ldp_topo1/r2/ip_mpls_route.ref new file mode 100644 index 0000000..f962070 --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/ip_mpls_route.ref @@ -0,0 +1,3 @@ +xx proto xx nexthopvia inet 10.0.2.3 dev r2-eth1 nexthopvia inet 10.0.3.3 dev r2-eth2 +xx via inet 10.0.1.1 dev r2-eth0 proto xx +xx via inet 10.0.2.4 dev r2-eth1 proto xx diff --git a/tests/topotests/ldp_topo1/r2/ldpd.conf b/tests/topotests/ldp_topo1/r2/ldpd.conf new file mode 100644 index 0000000..c4056e0 --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/ldpd.conf @@ -0,0 +1,25 @@ +hostname r2 +log file ldpd.log +! +! debug mpls ldp zebra +! debug mpls ldp event +! debug mpls ldp errors +! debug mpls ldp messages recv +! debug mpls ldp messages sent +! debug mpls ldp discovery hello recv +! debug mpls ldp discovery hello sent +! +mpls ldp + router-id 2.2.2.2 + ! + address-family ipv4 + discovery transport-address 2.2.2.2 + ! + interface r2-eth0 + ! + interface r2-eth1 + ! + ! +! +line vty +! diff --git a/tests/topotests/ldp_topo1/r2/ospfd.conf b/tests/topotests/ldp_topo1/r2/ospfd.conf new file mode 100644 index 0000000..dbed618 --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/ospfd.conf @@ -0,0 +1,19 @@ +hostname r2 +log file ospfd.log +! +router ospf + router-id 2.2.2.2 + network 0.0.0.0/0 area 0 +! +int r2-eth0 + ip ospf hello-interval 2 + ip ospf dead-interval 10 +! +int r2-eth1 + ip ospf hello-interval 2 + ip ospf dead-interval 10 +! +int r2-eth2 + ip ospf hello-interval 2 + ip ospf dead-interval 10 +! diff --git a/tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json new file mode 100644 index 0000000..ea78592 --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json @@ -0,0 +1,42 @@ +{ + "neighbors": { + "1.1.1.1": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.1.1", + "requestCounter": 0 + } + ], + "3.3.3.3": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.2.3", + "requestCounter": 0 + }, + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.3.3", + "requestCounter": 0 + } + ], + "4.4.4.4": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.2.4", + "requestCounter": 0 + } + ] + } +} diff --git a/tests/topotests/ldp_topo1/r2/show_ipv4_route.ref b/tests/topotests/ldp_topo1/r2/show_ipv4_route.ref new file mode 100644 index 0000000..90e1896 --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/show_ipv4_route.ref @@ -0,0 +1,7 @@ +O>* 1.1.1.1/32 [110/10] via 10.0.1.1, r2-eth0, label implicit-null, weight 1 +O 2.2.2.2/32 [110/0] is directly connected, lo, weight 1 +O>* 3.3.3.3/32 [110/10] via 10.0.2.3, r2-eth1, label implicit-null, weight 1 +O>* 4.4.4.4/32 [110/10] via 10.0.2.4, r2-eth1, label implicit-null, weight 1 +O 10.0.1.0/24 [110/10] is directly connected, r2-eth0, weight 1 +O 10.0.2.0/24 [110/10] is directly connected, r2-eth1, weight 1 +O 10.0.3.0/24 [110/10] is directly connected, r2-eth2, weight 1 diff --git a/tests/topotests/ldp_topo1/r2/show_mpls_ldp_binding.ref b/tests/topotests/ldp_topo1/r2/show_mpls_ldp_binding.ref new file mode 100644 index 0000000..d7df72e --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/show_mpls_ldp_binding.ref @@ -0,0 +1,22 @@ +AF Destination Nexthop Local Label Remote Label In Use +ipv4 1.1.1.1/32 1.1.1.1 xxx imp-null yes +ipv4 1.1.1.1/32 3.3.3.3 xxx xxx no +ipv4 1.1.1.1/32 4.4.4.4 xxx xxx no +ipv4 2.2.2.2/32 1.1.1.1 imp-null xxx no +ipv4 2.2.2.2/32 3.3.3.3 imp-null xxx no +ipv4 2.2.2.2/32 4.4.4.4 imp-null xxx no +ipv4 3.3.3.3/32 1.1.1.1 xxx xxx no +ipv4 3.3.3.3/32 3.3.3.3 xxx imp-null yes +ipv4 3.3.3.3/32 4.4.4.4 xxx xxx no +ipv4 4.4.4.4/32 1.1.1.1 xxx xxx no +ipv4 4.4.4.4/32 3.3.3.3 xxx xxx no +ipv4 4.4.4.4/32 4.4.4.4 xxx imp-null yes +ipv4 10.0.1.0/24 1.1.1.1 imp-null imp-null no +ipv4 10.0.1.0/24 3.3.3.3 imp-null xxx no +ipv4 10.0.1.0/24 4.4.4.4 imp-null xxx no +ipv4 10.0.2.0/24 1.1.1.1 imp-null xxx no +ipv4 10.0.2.0/24 3.3.3.3 imp-null imp-null no +ipv4 10.0.2.0/24 4.4.4.4 imp-null imp-null no +ipv4 10.0.3.0/24 1.1.1.1 imp-null xxx no +ipv4 10.0.3.0/24 3.3.3.3 imp-null imp-null no +ipv4 10.0.3.0/24 4.4.4.4 imp-null xxx no diff --git a/tests/topotests/ldp_topo1/r2/show_mpls_ldp_discovery.ref b/tests/topotests/ldp_topo1/r2/show_mpls_ldp_discovery.ref new file mode 100644 index 0000000..6405b5e --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/show_mpls_ldp_discovery.ref @@ -0,0 +1,4 @@ +AF ID Type Source Holdtime +ipv4 1.1.1.1 Link r2-eth0 15 +ipv4 3.3.3.3 Link r2-eth1 15 +ipv4 4.4.4.4 Link r2-eth1 15 diff --git a/tests/topotests/ldp_topo1/r2/show_mpls_ldp_interface.ref b/tests/topotests/ldp_topo1/r2/show_mpls_ldp_interface.ref new file mode 100644 index 0000000..f9fc984 --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/show_mpls_ldp_interface.ref @@ -0,0 +1,3 @@ +AF Interface State Uptime Hello Timers ac +ipv4 r2-eth0 ACTIVE xx:xx:xx 5/15 1 +ipv4 r2-eth1 ACTIVE xx:xx:xx 5/15 2 diff --git a/tests/topotests/ldp_topo1/r2/show_mpls_ldp_neighbor.ref b/tests/topotests/ldp_topo1/r2/show_mpls_ldp_neighbor.ref new file mode 100644 index 0000000..1172cbf --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/show_mpls_ldp_neighbor.ref @@ -0,0 +1,4 @@ +AF ID State Remote Address Uptime +ipv4 1.1.1.1 OPERATIONAL 1.1.1.1 xx:xx:xx +ipv4 3.3.3.3 OPERATIONAL 3.3.3.3 xx:xx:xx +ipv4 4.4.4.4 OPERATIONAL 4.4.4.4 xx:xx:xx diff --git a/tests/topotests/ldp_topo1/r2/show_mpls_table.ref b/tests/topotests/ldp_topo1/r2/show_mpls_table.ref new file mode 100644 index 0000000..df05a6b --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/show_mpls_table.ref @@ -0,0 +1,7 @@ + Inbound Label Type Nexthop Outbound Label + ----------------------------------------------- + XX LDP 10.0.1.1 implicit-null + XX LDP 10.0.2.3 implicit-null + XX LDP 10.0.2.4 implicit-null + XX LDP 10.0.3.3 implicit-null + diff --git a/tests/topotests/ldp_topo1/r2/zebra.conf b/tests/topotests/ldp_topo1/r2/zebra.conf new file mode 100644 index 0000000..dd1dbac --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/zebra.conf @@ -0,0 +1,27 @@ +log file zebra.log +! +hostname r2 +! +interface lo + ip address 2.2.2.2/32 +! +interface r2-eth0 + description to sw0 + ip address 10.0.1.2/24 + no link-detect +! +interface r2-eth1 + description to sw1 + ip address 10.0.2.2/24 + no link-detect +! +interface r2-eth2 + description to sw2 + ip address 10.0.3.2/24 + no link-detect +! +ip forwarding +! +! +line vty +! diff --git a/tests/topotests/ldp_topo1/r3/ip_mpls_route.ref b/tests/topotests/ldp_topo1/r3/ip_mpls_route.ref new file mode 100644 index 0000000..21750b4 --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/ip_mpls_route.ref @@ -0,0 +1,4 @@ +xx proto xx nexthopvia inet 10.0.2.2 dev r3-eth0 nexthopvia inet 10.0.3.2 dev r3-eth1 +xx proto xx nexthopvia inet 10.0.2.2 dev r3-eth0 nexthopvia inet 10.0.3.2 dev r3-eth1 +xx proto xx nexthopvia inet 10.0.2.2 dev r3-eth0 nexthopvia inet 10.0.3.2 dev r3-eth1 +xx via inet 10.0.2.4 dev r3-eth0 proto xx diff --git a/tests/topotests/ldp_topo1/r3/ldpd.conf b/tests/topotests/ldp_topo1/r3/ldpd.conf new file mode 100644 index 0000000..48956cb --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/ldpd.conf @@ -0,0 +1,23 @@ +hostname r3 +log file ldpd.log +! +! debug mpls ldp zebra +! debug mpls ldp event +! debug mpls ldp errors +! debug mpls ldp messages recv +! debug mpls ldp messages sent +! debug mpls ldp discovery hello recv +! debug mpls ldp discovery hello sent +! +mpls ldp + router-id 3.3.3.3 + ! + address-family ipv4 + discovery transport-address 3.3.3.3 + ! + interface r3-eth0 + ! + ! +! +line vty +! diff --git a/tests/topotests/ldp_topo1/r3/ospfd.conf b/tests/topotests/ldp_topo1/r3/ospfd.conf new file mode 100644 index 0000000..bd86fe4 --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/ospfd.conf @@ -0,0 +1,16 @@ +hostname r3 +password 1 +log file ospfd.log +! +router ospf + router-id 3.3.3.3 + network 0.0.0.0/0 area 0 +! +int r3-eth0 + ip ospf hello-interval 2 + ip ospf dead-interval 10 +! +int r3-eth1 + ip ospf hello-interval 2 + ip ospf dead-interval 10 +! diff --git a/tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json new file mode 100644 index 0000000..d3c5024 --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json @@ -0,0 +1,32 @@ +{ + "neighbors": { + "2.2.2.2": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.2.2", + "requestCounter": 0 + }, + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.3.2", + "requestCounter": 0 + } + ], + "4.4.4.4": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.2.4", + "requestCounter": 0 + } + ] + } +} diff --git a/tests/topotests/ldp_topo1/r3/show_ipv4_route.ref b/tests/topotests/ldp_topo1/r3/show_ipv4_route.ref new file mode 100644 index 0000000..9b9c763 --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/show_ipv4_route.ref @@ -0,0 +1,7 @@ +O>* 1.1.1.1/32 [110/20] via 10.0.2.2, r3-eth0, label xxx, weight 1 +O>* 2.2.2.2/32 [110/10] via 10.0.2.2, r3-eth0, label implicit-null, weight 1 +O 3.3.3.3/32 [110/0] is directly connected, lo, weight 1 +O>* 4.4.4.4/32 [110/10] via 10.0.2.4, r3-eth0, label implicit-null, weight 1 +O>* 10.0.1.0/24 [110/20] via 10.0.2.2, r3-eth0, label implicit-null, weight 1 +O 10.0.2.0/24 [110/10] is directly connected, r3-eth0, weight 1 +O 10.0.3.0/24 [110/10] is directly connected, r3-eth1, weight 1 diff --git a/tests/topotests/ldp_topo1/r3/show_mpls_ldp_binding.ref b/tests/topotests/ldp_topo1/r3/show_mpls_ldp_binding.ref new file mode 100644 index 0000000..058a245 --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/show_mpls_ldp_binding.ref @@ -0,0 +1,15 @@ +AF Destination Nexthop Local Label Remote Label In Use +ipv4 1.1.1.1/32 2.2.2.2 xxx xxx yes +ipv4 1.1.1.1/32 4.4.4.4 xxx xxx no +ipv4 2.2.2.2/32 2.2.2.2 xxx imp-null yes +ipv4 2.2.2.2/32 4.4.4.4 xxx xxx no +ipv4 3.3.3.3/32 2.2.2.2 imp-null xxx no +ipv4 3.3.3.3/32 4.4.4.4 imp-null xxx no +ipv4 4.4.4.4/32 2.2.2.2 xxx xxx no +ipv4 4.4.4.4/32 4.4.4.4 xxx imp-null yes +ipv4 10.0.1.0/24 2.2.2.2 xxx imp-null yes +ipv4 10.0.1.0/24 4.4.4.4 xxx xxx no +ipv4 10.0.2.0/24 2.2.2.2 imp-null imp-null no +ipv4 10.0.2.0/24 4.4.4.4 imp-null imp-null no +ipv4 10.0.3.0/24 2.2.2.2 imp-null imp-null no +ipv4 10.0.3.0/24 4.4.4.4 imp-null xxx no diff --git a/tests/topotests/ldp_topo1/r3/show_mpls_ldp_discovery.ref b/tests/topotests/ldp_topo1/r3/show_mpls_ldp_discovery.ref new file mode 100644 index 0000000..e3dbf06 --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/show_mpls_ldp_discovery.ref @@ -0,0 +1,3 @@ +AF ID Type Source Holdtime +ipv4 2.2.2.2 Link r3-eth0 15 +ipv4 4.4.4.4 Link r3-eth0 15 diff --git a/tests/topotests/ldp_topo1/r3/show_mpls_ldp_interface.ref b/tests/topotests/ldp_topo1/r3/show_mpls_ldp_interface.ref new file mode 100644 index 0000000..243811e --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/show_mpls_ldp_interface.ref @@ -0,0 +1,2 @@ +AF Interface State Uptime Hello Timers ac +ipv4 r3-eth0 ACTIVE xx:xx:xx 5/15 2 diff --git a/tests/topotests/ldp_topo1/r3/show_mpls_ldp_neighbor.ref b/tests/topotests/ldp_topo1/r3/show_mpls_ldp_neighbor.ref new file mode 100644 index 0000000..769f782 --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/show_mpls_ldp_neighbor.ref @@ -0,0 +1,3 @@ +AF ID State Remote Address Uptime +ipv4 2.2.2.2 OPERATIONAL 2.2.2.2 xx:xx:xx +ipv4 4.4.4.4 OPERATIONAL 4.4.4.4 xx:xx:xx diff --git a/tests/topotests/ldp_topo1/r3/show_mpls_table.ref b/tests/topotests/ldp_topo1/r3/show_mpls_table.ref new file mode 100644 index 0000000..3978895 --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/show_mpls_table.ref @@ -0,0 +1,10 @@ + Inbound Label Type Nexthop Outbound Label + ----------------------------------------------- + XX LDP 10.0.2.2 XX + XX LDP 10.0.2.2 implicit-null + XX LDP 10.0.2.2 implicit-null + XX LDP 10.0.2.4 implicit-null + XX LDP 10.0.3.2 XX + XX LDP 10.0.3.2 implicit-null + XX LDP 10.0.3.2 implicit-null + diff --git a/tests/topotests/ldp_topo1/r3/zebra.conf b/tests/topotests/ldp_topo1/r3/zebra.conf new file mode 100644 index 0000000..456820f --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/zebra.conf @@ -0,0 +1,22 @@ +log file zebra.log +! +hostname r3 +! +interface lo + ip address 3.3.3.3/32 +! +interface r3-eth0 + description to sw1 + ip address 10.0.2.3/24 + no link-detect +! +interface r3-eth1 + description to sw2 + ip address 10.0.3.3/24 + no link-detect +! +ip forwarding +! +! +line vty +! diff --git a/tests/topotests/ldp_topo1/r4/ip_mpls_route.ref b/tests/topotests/ldp_topo1/r4/ip_mpls_route.ref new file mode 100644 index 0000000..aef2fef --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/ip_mpls_route.ref @@ -0,0 +1,5 @@ +xx proto xx nexthopvia inet 10.0.2.2 dev r4-eth0 nexthopvia inet 10.0.2.3 dev r4-eth0 +xx as to xx via inet 10.0.2.2 dev r4-eth0 proto xx +xx via inet 10.0.2.2 dev r4-eth0 proto xx +xx via inet 10.0.2.2 dev r4-eth0 proto xx +xx via inet 10.0.2.3 dev r4-eth0 proto xx diff --git a/tests/topotests/ldp_topo1/r4/ldpd.conf b/tests/topotests/ldp_topo1/r4/ldpd.conf new file mode 100644 index 0000000..1d04aa0 --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/ldpd.conf @@ -0,0 +1,23 @@ +hostname r4 +log file ldpd.log +! +! debug mpls ldp zebra +! debug mpls ldp event +! debug mpls ldp errors +! debug mpls ldp messages recv +! debug mpls ldp messages sent +! debug mpls ldp discovery hello recv +! debug mpls ldp discovery hello sent +! +mpls ldp + router-id 4.4.4.4 + ! + address-family ipv4 + discovery transport-address 4.4.4.4 + ! + interface r4-eth0 + ! + ! +! +line vty +! diff --git a/tests/topotests/ldp_topo1/r4/ospfd.conf b/tests/topotests/ldp_topo1/r4/ospfd.conf new file mode 100644 index 0000000..5aae885 --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/ospfd.conf @@ -0,0 +1,11 @@ +hostname r4 +log file ospfd.log +! +router ospf + router-id 4.4.4.4 + network 0.0.0.0/0 area 0 +! +int r4-eth0 + ip ospf hello-interval 2 + ip ospf dead-interval 10 +! diff --git a/tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json new file mode 100644 index 0000000..20751a2 --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json @@ -0,0 +1,24 @@ +{ + "neighbors": { + "2.2.2.2": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.2.2", + "requestCounter": 0 + } + ], + "3.3.3.3": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.2.3", + "requestCounter": 0 + } + ] + } +} diff --git a/tests/topotests/ldp_topo1/r4/show_ipv4_route.ref b/tests/topotests/ldp_topo1/r4/show_ipv4_route.ref new file mode 100644 index 0000000..7444cc9 --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/show_ipv4_route.ref @@ -0,0 +1,7 @@ +O>* 1.1.1.1/32 [110/20] via 10.0.2.2, r4-eth0, label xxx, weight 1 +O>* 2.2.2.2/32 [110/10] via 10.0.2.2, r4-eth0, label implicit-null, weight 1 +O>* 3.3.3.3/32 [110/10] via 10.0.2.3, r4-eth0, label implicit-null, weight 1 +O 4.4.4.4/32 [110/0] is directly connected, lo, weight 1 +O>* 10.0.1.0/24 [110/20] via 10.0.2.2, r4-eth0, label implicit-null, weight 1 +O 10.0.2.0/24 [110/10] is directly connected, r4-eth0, weight 1 +O>* 10.0.3.0/24 [110/20] via 10.0.2.2, r4-eth0, label implicit-null, weight 1 diff --git a/tests/topotests/ldp_topo1/r4/show_mpls_ldp_binding.ref b/tests/topotests/ldp_topo1/r4/show_mpls_ldp_binding.ref new file mode 100644 index 0000000..1e9dfa3 --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/show_mpls_ldp_binding.ref @@ -0,0 +1,15 @@ +AF Destination Nexthop Local Label Remote Label In Use +ipv4 1.1.1.1/32 2.2.2.2 xxx xxx yes +ipv4 1.1.1.1/32 3.3.3.3 xxx xxx no +ipv4 2.2.2.2/32 2.2.2.2 xxx imp-null yes +ipv4 2.2.2.2/32 3.3.3.3 xxx xxx no +ipv4 3.3.3.3/32 2.2.2.2 xxx xxx no +ipv4 3.3.3.3/32 3.3.3.3 xxx imp-null yes +ipv4 4.4.4.4/32 2.2.2.2 imp-null xxx no +ipv4 4.4.4.4/32 3.3.3.3 imp-null xxx no +ipv4 10.0.1.0/24 2.2.2.2 xxx imp-null yes +ipv4 10.0.1.0/24 3.3.3.3 xxx xxx no +ipv4 10.0.2.0/24 2.2.2.2 imp-null imp-null no +ipv4 10.0.2.0/24 3.3.3.3 imp-null imp-null no +ipv4 10.0.3.0/24 2.2.2.2 xxx imp-null yes +ipv4 10.0.3.0/24 3.3.3.3 xxx imp-null yes diff --git a/tests/topotests/ldp_topo1/r4/show_mpls_ldp_discovery.ref b/tests/topotests/ldp_topo1/r4/show_mpls_ldp_discovery.ref new file mode 100644 index 0000000..a702657 --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/show_mpls_ldp_discovery.ref @@ -0,0 +1,3 @@ +AF ID Type Source Holdtime +ipv4 2.2.2.2 Link r4-eth0 15 +ipv4 3.3.3.3 Link r4-eth0 15 diff --git a/tests/topotests/ldp_topo1/r4/show_mpls_ldp_interface.ref b/tests/topotests/ldp_topo1/r4/show_mpls_ldp_interface.ref new file mode 100644 index 0000000..dd57656 --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/show_mpls_ldp_interface.ref @@ -0,0 +1,2 @@ +AF Interface State Uptime Hello Timers ac +ipv4 r4-eth0 ACTIVE xx:xx:xx 5/15 2 diff --git a/tests/topotests/ldp_topo1/r4/show_mpls_ldp_neighbor.ref b/tests/topotests/ldp_topo1/r4/show_mpls_ldp_neighbor.ref new file mode 100644 index 0000000..7c60522 --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/show_mpls_ldp_neighbor.ref @@ -0,0 +1,3 @@ +AF ID State Remote Address Uptime +ipv4 2.2.2.2 OPERATIONAL 2.2.2.2 xx:xx:xx +ipv4 3.3.3.3 OPERATIONAL 3.3.3.3 xx:xx:xx diff --git a/tests/topotests/ldp_topo1/r4/show_mpls_table.ref b/tests/topotests/ldp_topo1/r4/show_mpls_table.ref new file mode 100644 index 0000000..174dceb --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/show_mpls_table.ref @@ -0,0 +1,9 @@ + Inbound Label Type Nexthop Outbound Label + ----------------------------------------------- + XX LDP 10.0.2.2 XX + XX LDP 10.0.2.2 implicit-null + XX LDP 10.0.2.2 implicit-null + XX LDP 10.0.2.2 implicit-null + XX LDP 10.0.2.3 implicit-null + XX LDP 10.0.2.3 implicit-null + diff --git a/tests/topotests/ldp_topo1/r4/zebra.conf b/tests/topotests/ldp_topo1/r4/zebra.conf new file mode 100644 index 0000000..4a270af --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/zebra.conf @@ -0,0 +1,17 @@ +log file zebra.log +! +hostname r4 +! +interface lo + ip address 4.4.4.4/32 +! +interface r4-eth0 + description to sw1 + ip address 10.0.2.4/24 + no link-detect +! +ip forwarding +! +! +line vty +! diff --git a/tests/topotests/ldp_topo1/test_ldp_topo1.py b/tests/topotests/ldp_topo1/test_ldp_topo1.py new file mode 100644 index 0000000..cb8adfb --- /dev/null +++ b/tests/topotests/ldp_topo1/test_ldp_topo1.py @@ -0,0 +1,857 @@ +#!/usr/bin/env python + +# +# test_bgp_multiview_topo1.py +# Part of NetDEF Topology Tests +# +# Copyright (c) 2016 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. +# + +r""" +test_ldp_topo1.py: Simple FRR LDP Test + + +---------+ + | r1 | + | 1.1.1.1 | + +----+----+ + | .1 r1-eth0 + | + ~~~~~~~~~~~~~ + ~~ sw0 ~~ + ~~ 10.0.1.0/24 ~~ + ~~~~~~~~~~~~~ + |10.0.1.0/24 + | + | .2 r2-eth0 + +----+----+ + | r2 | + | 2.2.2.2 | + +--+---+--+ + r2-eth2 .2 | | .2 r2-eth1 + ______/ \______ + / \ + ~~~~~~~~~~~~~ ~~~~~~~~~~~~~ +~~ sw2 ~~ ~~ sw1 ~~ +~~ 10.0.3.0/24 ~~ ~~ 10.0.2.0/24 ~~ + ~~~~~~~~~~~~~ ~~~~~~~~~~~~~ + | / | + \ _________/ | + \ / \ +r3-eth1 .3 | | .3 r3-eth0 | .4 r4-eth0 + +----+--+---+ +----+----+ + | r3 | | r4 | + | 3.3.3.3 | | 4.4.4.4 | + +-----------+ +---------+ +""" + +import os +import re +import sys +import pytest +import json +from functools import partial +from time import sleep +from lib.topolog import logger + +# Save the Current Working Directory to find configuration files. +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, "../")) + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from lib import topotest +from lib.topogen import Topogen, get_topogen + +fatal_error = "" + +pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd] + +##################################################### +## +## Network Topology Definition +## +##################################################### + + +def build_topo(tgen): + + # Setup Routers + for i in range(1, 5): + tgen.add_router("r%s" % i) + + # First switch + switch = tgen.add_switch("sw0") + switch.add_link(tgen.gears["r1"]) + switch.add_link(tgen.gears["r2"]) + # Second switch + switch = tgen.add_switch("sw1") + switch.add_link(tgen.gears["r2"]) + switch.add_link(tgen.gears["r3"]) + switch.add_link(tgen.gears["r4"]) + # Third switch + switch = tgen.add_switch("sw2") + switch.add_link(tgen.gears["r2"]) + switch.add_link(tgen.gears["r3"]) + + +##################################################### +## +## Helper functions +## +##################################################### + + +def router_compare_json_output(rname, command, reference, count=60, wait=1): + "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. + test_func = partial(topotest.router_json_cmp, tgen.gears[rname], command, expected) + _, diff = topotest.run_and_expect(test_func, None, count, wait) + assertmsg = '"{}" JSON output mismatches the expected result'.format(rname) + assert diff is None, assertmsg + + +##################################################### +## +## Tests starting +## +##################################################### + + +def setup_module(module): + print("\n\n** %s: Setup Topology" % module.__name__) + print("******************************************\n") + + thisDir = os.path.dirname(os.path.realpath(__file__)) + tgen = Topogen(build_topo, module.__name__) + tgen.start_topology() + + net = tgen.net + + # Starting Routers + for i in range(1, 5): + net["r%s" % i].loadConf("zebra", "%s/r%s/zebra.conf" % (thisDir, i)) + net["r%s" % i].loadConf("ospfd", "%s/r%s/ospfd.conf" % (thisDir, i)) + net["r%s" % i].loadConf("ldpd", "%s/r%s/ldpd.conf" % (thisDir, i)) + tgen.gears["r%s" % i].start() + + # For debugging after starting FRR daemons, uncomment the next line + # tgen.mininet_cli() + + +def teardown_module(module): + print("\n\n** %s: Shutdown Topology" % module.__name__) + print("******************************************\n") + tgen = get_topogen() + tgen.stop_topology() + + +def test_router_running(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + print("\n\n** Check if FRR is running on each Router node") + print("******************************************\n") + sleep(5) + + # Starting Routers + for i in range(1, 5): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_mpls_interfaces(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + # Verify MPLS Interfaces + print("\n\n** Verifying MPLS Interfaces") + print("******************************************\n") + failures = 0 + for i in range(1, 5): + refTableFile = "%s/r%s/show_mpls_ldp_interface.ref" + if os.path.isfile(refTableFile): + # Read expected result from file + expected = open(refTableFile).read().rstrip() + # Fix newlines (make them all the same) + expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1) + + # Actual output from router + actual = ( + net["r%s" % i] + .cmd('vtysh -c "show mpls ldp interface" 2> /dev/null') + .rstrip() + ) + # Mask out Timer in Uptime + actual = re.sub(r" [0-9][0-9]:[0-9][0-9]:[0-9][0-9] ", " xx:xx:xx ", actual) + # Fix newlines (make them all the same) + actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1) + + # Generate Diff + diff = topotest.get_textdiff( + actual, + expected, + title1="actual MPLS LDP interface status", + title2="expected MPLS LDP interface status", + ) + + # Empty string if it matches, otherwise diff contains unified diff + if diff: + sys.stderr.write( + "r%s failed MPLS LDP Interface status Check:\n%s\n" % (i, diff) + ) + failures += 1 + else: + print("r%s ok" % i) + + if failures > 0: + fatal_error = "MPLS LDP Interface status failed" + + assert ( + failures == 0 + ), "MPLS LDP Interface status failed for router r%s:\n%s" % (i, diff) + + # Make sure that all daemons are running + for i in range(1, 5): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_ospf_convergence(): + logger.info("Test: check OSPF adjacencies") + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + for rname in ["r1", "r2", "r3", "r4"]: + router_compare_json_output( + rname, "show ip ospf neighbor json", "show_ip_ospf_neighbor.json" + ) + + +def test_mpls_ldp_neighbor_establish(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + neighbors_operational = { + 1: 1, + 2: 3, + 3: 2, + 4: 2, + } + + # Wait for MPLS LDP neighbors to establish. + print("\n\n** Verify MPLS LDP neighbors to establish") + print("******************************************\n") + timeout = 90 + while timeout > 0: + print("Timeout in %s: " % timeout), + sys.stdout.flush() + # Look for any node not yet converged + for i in range(1, 5): + established = ( + net["r%s" % i] + .cmd('vtysh -c "show mpls ldp neighbor" 2> /dev/null') + .rstrip() + ) + + # On current version, we need to make sure they all turn to OPERATIONAL on all lines + # + lines = ("\n".join(established.splitlines()) + "\n").splitlines(1) + # Check all lines to be either table header (starting with ^AF or show OPERATIONAL) + header = r"^AF.*" + operational = r"^ip.*OPERATIONAL.*" + found_operational = 0 + for j in range(1, len(lines)): + if (not re.search(header, lines[j])) and ( + not re.search(operational, lines[j]) + ): + established = "" # Empty string shows NOT established + if re.search(operational, lines[j]): + found_operational += 1 + + logger.info("Found operational %d" % found_operational) + if found_operational < 1: + # Need at least one operational neighbor + established = "" # Empty string shows NOT established + else: + if found_operational != neighbors_operational[i]: + established = "" + if not established: + print("Waiting for r%s" % i) + sys.stdout.flush() + break + if not established: + sleep(5) + timeout -= 5 + else: + print("Done") + break + else: + # Bail out with error if a router fails to converge + fatal_error = "MPLS LDP neighbors did not establish" + assert False, "MPLS LDP neighbors did not establish" + + print("MPLS LDP neighbors established.") + + if timeout < 60: + # Only wait if we actually went through a convergence + print("\nwaiting 15s for LDP sessions to establish") + sleep(15) + + # Make sure that all daemons are running + for i in range(1, 5): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_mpls_ldp_discovery(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + # Verify MPLS LDP discovery + print("\n\n** Verifying MPLS LDP discovery") + print("******************************************\n") + failures = 0 + for i in range(1, 5): + refTableFile = "%s/r%s/show_mpls_ldp_discovery.ref" % (thisDir, i) + if os.path.isfile(refTableFile): + # Actual output from router + actual = ( + net["r%s" % i] + .cmd('vtysh -c "show mpls ldp discovery" 2> /dev/null') + .rstrip() + ) + + # Read expected result from file + expected = open(refTableFile).read().rstrip() + # Fix newlines (make them all the same) + expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1) + + # Actual output from router + actual = ( + net["r%s" % i] + .cmd('vtysh -c "show mpls ldp discovery" 2> /dev/null') + .rstrip() + ) + + # Fix newlines (make them all the same) + actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1) + + # Generate Diff + diff = topotest.get_textdiff( + actual, + expected, + title1="actual MPLS LDP discovery output", + title2="expected MPLS LDP discovery output", + ) + + # Empty string if it matches, otherwise diff contains unified diff + if diff: + sys.stderr.write( + "r%s failed MPLS LDP discovery output Check:\n%s\n" % (i, diff) + ) + failures += 1 + else: + print("r%s ok" % i) + + assert ( + failures == 0 + ), "MPLS LDP Interface discovery output for router r%s:\n%s" % (i, diff) + + # Make sure that all daemons are running + for i in range(1, 5): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_mpls_ldp_neighbor(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + # Verify MPLS LDP neighbor + print("\n\n** Verifying MPLS LDP neighbor") + print("******************************************\n") + failures = 0 + for i in range(1, 5): + refTableFile = "%s/r%s/show_mpls_ldp_neighbor.ref" % (thisDir, i) + if os.path.isfile(refTableFile): + # Read expected result from file + expected = open(refTableFile).read().rstrip() + # Fix newlines (make them all the same) + expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1) + + # Actual output from router + actual = ( + net["r%s" % i] + .cmd('vtysh -c "show mpls ldp neighbor" 2> /dev/null') + .rstrip() + ) + + # Mask out changing parts in output + # Mask out Timer in Uptime + actual = re.sub( + r"(ipv4 [0-9\.]+ +OPERATIONAL [0-9\.]+ +)[0-9][0-9]:[0-9][0-9]:[0-9][0-9]", + r"\1xx:xx:xx", + actual, + ) + + # Fix newlines (make them all the same) + actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1) + + # Generate Diff + diff = topotest.get_textdiff( + actual, + expected, + title1="actual MPLS LDP neighbor output", + title2="expected MPLS LDP neighbor output", + ) + + # Empty string if it matches, otherwise diff contains unified diff + if diff: + sys.stderr.write( + "r%s failed MPLS LDP neighbor output Check:\n%s\n" % (i, diff) + ) + failures += 1 + else: + print("r%s ok" % i) + + assert ( + failures == 0 + ), "MPLS LDP Interface neighbor output for router r%s:\n%s" % (i, diff) + + # Make sure that all daemons are running + for i in range(1, 5): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_mpls_ldp_binding(): + global fatal_error + net = get_topogen().net + + # Skip this test for now until proper sorting of the output + # is implemented + # pytest.skip("Skipping test_mpls_ldp_binding") + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + # Verify MPLS LDP binding + print("\n\n** Verifying MPLS LDP binding") + print("******************************************\n") + failures = 0 + for i in range(1, 5): + refTableFile = "%s/r%s/show_mpls_ldp_binding.ref" % (thisDir, i) + if os.path.isfile(refTableFile): + # Read expected result from file + expected = open(refTableFile).read().rstrip() + # Fix newlines (make them all the same) + expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1) + + # Actual output from router + actual = ( + net["r%s" % i] + .cmd('vtysh -c "show mpls ldp binding" 2> /dev/null') + .rstrip() + ) + + # Mask out changing parts in output + # Mask out label + actual = re.sub( + r"(ipv4 [0-9\./]+ +[0-9\.]+ +)[0-9][0-9] (.*)", r"\1xxx\2", actual + ) + actual = re.sub( + r"(ipv4 [0-9\./]+ +[0-9\.]+ +[a-z\-]+ +)[0-9][0-9] (.*)", + r"\1xxx\2", + actual, + ) + + # Fix newlines (make them all the same) + actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1) + + # Sort lines which start with "xx via inet " + pattern = r"^\s+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s+" + swapped = True + while swapped: + swapped = False + for j in range(1, len(actual)): + if re.search(pattern, actual[j]) and re.search( + pattern, actual[j - 1] + ): + if actual[j - 1] > actual[j]: + temp = actual[j - 1] + actual[j - 1] = actual[j] + actual[j] = temp + swapped = True + + # Generate Diff + diff = topotest.get_textdiff( + actual, + expected, + title1="actual MPLS LDP binding output", + title2="expected MPLS LDP binding output", + ) + + # Empty string if it matches, otherwise diff contains unified diff + if diff: + sys.stderr.write( + "r%s failed MPLS LDP binding output Check:\n%s\n" % (i, diff) + ) + failures += 1 + else: + print("r%s ok" % i) + + assert failures == 0, "MPLS LDP binding output for router r%s:\n%s" % ( + i, + diff, + ) + + # Make sure that all daemons are running + for i in range(1, 5): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_zebra_ipv4_routingTable(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + # Verify Zebra IPv4 Routing Table + print("\n\n** Verifying Zebra IPv4 Routing Table") + print("******************************************\n") + failures = 0 + for i in range(1, 5): + refTableFile = "%s/r%s/show_ipv4_route.ref" % (thisDir, i) + if os.path.isfile(refTableFile): + # Read expected result from file + expected = open(refTableFile).read().rstrip() + + # Actual output from router + actual = ( + net["r%s" % i] + .cmd('vtysh -c "show ip route" 2> /dev/null | grep "^O"') + .rstrip() + ) + # Drop timers on end of line + actual = re.sub(r", [0-2][0-9]:[0-5][0-9]:[0-5][0-9]", "", actual) + + # Mask out label - all LDP labels should be >= 10 (2-digit) + # leaving the implicit labels unmasked + actual = re.sub(r" label [0-9][0-9]+", " label xxx", actual) + # and translating remaining implicit (single-digit) labels to label implicit-null + actual = re.sub(r" label [0-9]+", " label implicit-null", actual) + # Check if we have implicit labels - if not, then remove them from reference + if not re.search(r" label implicit-null", actual): + expected = re.sub(r", label implicit-null", "", expected) + + # now fix newlines of expected (make them all the same) + expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1) + + # Fix newlines (make them all the same) + actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1) + + # Generate Diff + diff = topotest.get_textdiff( + actual, + expected, + title1="actual IPv4 zebra routing table", + title2="expected IPv4 zebra routing table", + ) + + # Empty string if it matches, otherwise diff contains unified diff + if diff: + sys.stderr.write( + "r%s failed IPv4 Zebra Routing Table Check:\n%s\n" % (i, diff) + ) + failures += 1 + else: + print("r%s ok" % i) + + assert ( + failures == 0 + ), "IPv4 Zebra Routing Table verification failed for router r%s:\n%s" % ( + i, + diff, + ) + + # Make sure that all daemons are running + for i in range(1, 5): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_mpls_table(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + # Verify MPLS table + print("\n\n** Verifying MPLS table") + print("******************************************\n") + failures = 0 + + for i in range(1, 5): + refTableFile = "%s/r%s/show_mpls_table.ref" % (thisDir, i) + if os.path.isfile(refTableFile): + # Read expected result from file + expected = open(refTableFile).read() + # Fix newlines (make them all the same) + expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1) + + # Actual output from router + actual = net["r%s" % i].cmd('vtysh -c "show mpls table" 2> /dev/null') + + # Fix inconsistent Label numbers at beginning of line + actual = re.sub(r"(\s+)[0-9]+(\s+LDP)", r"\1XX\2", actual) + # Fix inconsistent Label numbers at end of line + actual = re.sub( + r"(\s+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s+)[0-9][0-9]", r"\1XX", actual + ) + + # Fix newlines (make them all the same) + actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1) + + # Sort lines which start with " XX LDP" + pattern = r"^\s+[0-9X]+\s+LDP" + swapped = True + while swapped: + swapped = False + for j in range(1, len(actual)): + if re.search(pattern, actual[j]) and re.search( + pattern, actual[j - 1] + ): + if actual[j - 1] > actual[j]: + temp = actual[j - 1] + actual[j - 1] = actual[j] + actual[j] = temp + swapped = True + + # Generate Diff + diff = topotest.get_textdiff( + actual, + expected, + title1="actual MPLS table output", + title2="expected MPLS table output", + ) + + # Empty string if it matches, otherwise diff contains unified diff + if diff: + sys.stderr.write( + "r%s failed MPLS table output Check:\n%s\n" % (i, diff) + ) + failures += 1 + else: + print("r%s ok" % i) + + assert failures == 0, "MPLS table output for router r%s:\n%s" % (i, diff) + + # Make sure that all daemons are running + for i in range(1, 5): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_linux_mpls_routes(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + # Verify Linux Kernel MPLS routes + print("\n\n** Verifying Linux Kernel MPLS routes") + print("******************************************\n") + failures = 0 + for i in range(1, 5): + refTableFile = "%s/r%s/ip_mpls_route.ref" % (thisDir, i) + if os.path.isfile(refTableFile): + # Read expected result from file + expected = open(refTableFile).read().rstrip() + # Fix newlines (make them all the same) + expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1) + + # Actual output from router + actual = ( + net["r%s" % i].cmd("ip -o -family mpls route 2> /dev/null").rstrip() + ) + + # Mask out label and protocol + actual = re.sub(r"[0-9][0-9] via inet ", "xx via inet ", actual) + actual = re.sub(r"[0-9][0-9] +proto", "xx proto", actual) + actual = re.sub(r"[0-9][0-9] as to ", "xx as to ", actual) + actual = re.sub(r"[ ]+proto \w+", " proto xx", actual) + + # Sort nexthops + nexthop_sorted = [] + for line in actual.splitlines(): + tokens = re.split(r"\\\t", line.strip()) + nexthop_sorted.append( + "{} {}".format( + tokens[0].strip(), + " ".join([token.strip() for token in sorted(tokens[1:])]), + ).strip() + ) + + # Sort lines and fixup differences between old and new iproute + actual = "\n".join(sorted(nexthop_sorted)) + actual = re.sub(r"nexthop via", "nexthopvia", actual) + actual = re.sub(r" nexthop as to xx via inet ", " nexthopvia inet ", actual) + actual = re.sub(r" weight 1", "", actual) + actual = re.sub(r" [ ]+", " ", actual) + + # put \n back at line ends + actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1) + + # Generate Diff + diff = topotest.get_textdiff( + actual, + expected, + title1="actual Linux Kernel MPLS route", + title2="expected Linux Kernel MPLS route", + ) + + # Empty string if it matches, otherwise diff contains unified diff + if diff: + sys.stderr.write( + "r%s failed Linux Kernel MPLS route output Check:\n%s\n" % (i, diff) + ) + failures += 1 + else: + print("r%s ok" % i) + + assert ( + failures == 0 + ), "Linux Kernel MPLS route output for router r%s:\n%s" % (i, diff) + + # Make sure that all daemons are running + for i in range(1, 5): + fatal_error = net["r%s" % i].checkRouterRunning() + assert fatal_error == "", fatal_error + + +def test_shutdown_check_stderr(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + if os.environ.get("TOPOTESTS_CHECK_STDERR") is None: + print( + "SKIPPED final check on StdErr output: Disabled (TOPOTESTS_CHECK_STDERR undefined)\n" + ) + pytest.skip("Skipping test for Stderr output") + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + print("\n\n** Verifying unexpected STDERR output from daemons") + print("******************************************\n") + + for i in range(1, 5): + net["r%s" % i].stopRouter() + log = net["r%s" % i].getStdErr("ldpd") + if log: + print("\nRouter r%s LDPd StdErr Log:\n%s" % (i, log)) + log = net["r%s" % i].getStdErr("ospfd") + if log: + print("\nRouter r%s OSPFd StdErr Log:\n%s" % (i, log)) + log = net["r%s" % i].getStdErr("zebra") + if log: + print("\nRouter r%s Zebra StdErr Log:\n%s" % (i, log)) + + +def test_shutdown_check_memleak(): + global fatal_error + net = get_topogen().net + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + if os.environ.get("TOPOTESTS_CHECK_MEMLEAK") is None: + print( + "SKIPPED final check on Memory leaks: Disabled (TOPOTESTS_CHECK_MEMLEAK undefined)\n" + ) + pytest.skip("Skipping test for memory leaks") + + thisDir = os.path.dirname(os.path.realpath(__file__)) + + for i in range(1, 5): + net["r%s" % i].stopRouter() + net["r%s" % i].report_memory_leaks( + os.environ.get("TOPOTESTS_CHECK_MEMLEAK"), os.path.basename(__file__) + ) + + +if __name__ == "__main__": + + # To suppress tracebacks, either use the following pytest call or add "--tb=no" to cli + # retval = pytest.main(["-s", "--tb=no"]) + retval = pytest.main(["-s"]) + sys.exit(retval) -- cgit v1.2.3