summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-01-06 13:10:01 +0100
committerChristian Poessinger <christian@poessinger.com>2021-01-06 13:10:01 +0100
commit9f33a14ac2a2e85da16b3169465155ca6114d09e (patch)
tree5aeea67b3f6e5850ca1c368bc34097ab28763014
parent216b4511329f96c2a9287e0caade0a4c76a9ba69 (diff)
downloadvyos-1x-9f33a14ac2a2e85da16b3169465155ca6114d09e.tar.gz
vyos-1x-9f33a14ac2a2e85da16b3169465155ca6114d09e.zip
smoketest: bgp: add ipv4/ipv6 address-family tests
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_bgp.py93
1 files changed, 93 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_protocols_bgp.py b/smoketest/scripts/cli/test_protocols_bgp.py
index 540ef2ec4..1d93aeda4 100755
--- a/smoketest/scripts/cli/test_protocols_bgp.py
+++ b/smoketest/scripts/cli/test_protocols_bgp.py
@@ -245,5 +245,98 @@ class TestProtocolsBGP(unittest.TestCase):
self.assertIn(f' neighbor {peer_group} peer-group', frrconfig)
self.verify_frr_config(peer, peer_config, frrconfig)
+
+ def test_bgp_04_afi_ipv4(self):
+ networks = {
+ '10.0.0.0/8' : {
+ 'as_set' : '',
+ },
+ '100.64.0.0/10' : {
+ 'as_set' : '',
+ },
+ '192.168.0.0/16' : {
+ 'summary_only' : '',
+ },
+ }
+
+ # We want to redistribute ...
+ redistributes = ['connected', 'kernel', 'ospf', 'rip', 'static']
+ for redistribute in redistributes:
+ self.session.set(base_path + ['address-family', 'ipv4-unicast',
+ 'redistribute', redistribute])
+
+ for network, network_config in networks.items():
+ self.session.set(base_path + ['address-family', 'ipv4-unicast',
+ 'network', network])
+ if 'as_set' in network_config:
+ self.session.set(base_path + ['address-family', 'ipv4-unicast',
+ 'aggregate-address', network, 'as-set'])
+ if 'summary_only' in network_config:
+ self.session.set(base_path + ['address-family', 'ipv4-unicast',
+ 'aggregate-address', network, 'summary-only'])
+
+ # commit changes
+ self.session.commit()
+
+ # Verify FRR bgpd configuration
+ frrconfig = getFRRBGPconfig()
+ self.assertIn(f'router bgp {ASN}', frrconfig)
+ self.assertIn(f' address-family ipv4 unicast', frrconfig)
+
+ for redistribute in redistributes:
+ self.assertIn(f' redistribute {redistribute}', frrconfig)
+
+ for network, network_config in networks.items():
+ self.assertIn(f' network {network}', frrconfig)
+ if 'as_set' in network_config:
+ self.assertIn(f' aggregate-address {network} as-set', frrconfig)
+ if 'summary_only' in network_config:
+ self.assertIn(f' aggregate-address {network} summary-only', frrconfig)
+
+
+ def test_bgp_05_afi_ipv6(self):
+ networks = {
+ '2001:db8:100::/48' : {
+ },
+ '2001:db8:200::/48' : {
+ },
+ '2001:db8:300::/48' : {
+ 'summary_only' : '',
+ },
+ }
+
+ # We want to redistribute ...
+ redistributes = ['connected', 'kernel', 'ospfv3', 'ripng', 'static']
+ for redistribute in redistributes:
+ self.session.set(base_path + ['address-family', 'ipv6-unicast',
+ 'redistribute', redistribute])
+
+ for network, network_config in networks.items():
+ self.session.set(base_path + ['address-family', 'ipv6-unicast',
+ 'network', network])
+ if 'summary_only' in network_config:
+ self.session.set(base_path + ['address-family', 'ipv6-unicast',
+ 'aggregate-address', network, 'summary-only'])
+
+ # commit changes
+ self.session.commit()
+
+ # Verify FRR bgpd configuration
+ frrconfig = getFRRBGPconfig()
+ self.assertIn(f'router bgp {ASN}', frrconfig)
+ self.assertIn(f' address-family ipv6 unicast', frrconfig)
+
+ for redistribute in redistributes:
+ # FRR calls this OSPF6
+ if redistribute == 'ospfv3':
+ redistribute = 'ospf6'
+ self.assertIn(f' redistribute {redistribute}', frrconfig)
+
+ for network, network_config in networks.items():
+ self.assertIn(f' network {network}', frrconfig)
+ if 'as_set' in network_config:
+ self.assertIn(f' aggregate-address {network} summary-only', frrconfig)
+
+
if __name__ == '__main__':
unittest.main(verbosity=2)