summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli
diff options
context:
space:
mode:
Diffstat (limited to 'smoketest/scripts/cli')
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_segment-routing.py107
1 files changed, 92 insertions, 15 deletions
diff --git a/smoketest/scripts/cli/test_protocols_segment-routing.py b/smoketest/scripts/cli/test_protocols_segment-routing.py
index b1cac7483..af4ef2adf 100755
--- a/smoketest/scripts/cli/test_protocols_segment-routing.py
+++ b/smoketest/scripts/cli/test_protocols_segment-routing.py
@@ -26,6 +26,7 @@ from vyos.utils.system import sysctl_read
base_path = ['protocols', 'segment-routing']
+
class TestProtocolsSegmentRouting(VyOSUnitTestSHIM.TestCase):
@classmethod
def setUpClass(cls):
@@ -47,14 +48,64 @@ class TestProtocolsSegmentRouting(VyOSUnitTestSHIM.TestCase):
def test_srv6(self):
interfaces = Section.interfaces('ethernet', vlan=False)
locators = {
- 'foo' : { 'prefix' : '2001:a::/64' },
- 'foo' : { 'prefix' : '2001:b::/64', 'usid' : {} },
+ 'foo1': {'prefix': '2001:a::/64'},
+ 'foo2': {'prefix': '2001:b::/64', 'usid': {}},
+ 'foo3': {'prefix': '2001:c::/64', 'format': 'uncompressed-f4024'},
+ 'foo4': {
+ 'prefix': '2001:d::/48',
+ 'block-len': '32',
+ 'node-len': '16',
+ 'func-bits': '16',
+ 'usid': {},
+ 'format': 'usid-f3216',
+ },
}
for locator, locator_config in locators.items():
- self.cli_set(base_path + ['srv6', 'locator', locator, 'prefix', locator_config['prefix']])
+ self.cli_set(
+ base_path
+ + ['srv6', 'locator', locator, 'prefix', locator_config['prefix']]
+ )
+ if 'block-len' in locator_config:
+ self.cli_set(
+ base_path
+ + [
+ 'srv6',
+ 'locator',
+ locator,
+ 'block-len',
+ locator_config['block-len'],
+ ]
+ )
+ if 'node-len' in locator_config:
+ self.cli_set(
+ base_path
+ + [
+ 'srv6',
+ 'locator',
+ locator,
+ 'node-len',
+ locator_config['node-len'],
+ ]
+ )
+ if 'func-bits' in locator_config:
+ self.cli_set(
+ base_path
+ + [
+ 'srv6',
+ 'locator',
+ locator,
+ 'func-bits',
+ locator_config['func-bits'],
+ ]
+ )
if 'usid' in locator_config:
self.cli_set(base_path + ['srv6', 'locator', locator, 'behavior-usid'])
+ if 'format' in locator_config:
+ self.cli_set(
+ base_path
+ + ['srv6', 'locator', locator, 'format', locator_config['format']]
+ )
# verify() - SRv6 should be enabled on at least one interface!
with self.assertRaises(ConfigSessionError):
@@ -65,16 +116,33 @@ class TestProtocolsSegmentRouting(VyOSUnitTestSHIM.TestCase):
self.cli_commit()
for interface in interfaces:
- self.assertEqual(sysctl_read(f'net.ipv6.conf.{interface}.seg6_enabled'), '1')
- self.assertEqual(sysctl_read(f'net.ipv6.conf.{interface}.seg6_require_hmac'), '0') # default
-
- frrconfig = self.getFRRconfig(f'segment-routing', endsection='^exit')
- self.assertIn(f'segment-routing', frrconfig)
- self.assertIn(f' srv6', frrconfig)
- self.assertIn(f' locators', frrconfig)
+ self.assertEqual(
+ sysctl_read(f'net.ipv6.conf.{interface}.seg6_enabled'), '1'
+ )
+ self.assertEqual(
+ sysctl_read(f'net.ipv6.conf.{interface}.seg6_require_hmac'), '0'
+ ) # default
+
+ frrconfig = self.getFRRconfig('segment-routing', endsection='^exit')
+ self.assertIn('segment-routing', frrconfig)
+ self.assertIn(' srv6', frrconfig)
+ self.assertIn(' locators', frrconfig)
for locator, locator_config in locators.items():
+ prefix = locator_config['prefix']
+ block_len = locator_config.get('block-len', '40')
+ node_len = locator_config.get('node-len', '24')
+ func_bits = locator_config.get('func-bits', '16')
+
self.assertIn(f' locator {locator}', frrconfig)
- self.assertIn(f' prefix {locator_config["prefix"]} block-len 40 node-len 24 func-bits 16', frrconfig)
+ self.assertIn(
+ f' prefix {prefix} block-len {block_len} node-len {node_len} func-bits {func_bits}',
+ frrconfig,
+ )
+
+ if 'format' in locator_config:
+ self.assertIn(f' format {locator_config["format"]}', frrconfig)
+ if 'usid' in locator_config:
+ self.assertIn(' behavior usid', frrconfig)
def test_srv6_sysctl(self):
interfaces = Section.interfaces('ethernet', vlan=False)
@@ -86,8 +154,12 @@ class TestProtocolsSegmentRouting(VyOSUnitTestSHIM.TestCase):
self.cli_commit()
for interface in interfaces:
- self.assertEqual(sysctl_read(f'net.ipv6.conf.{interface}.seg6_enabled'), '1')
- self.assertEqual(sysctl_read(f'net.ipv6.conf.{interface}.seg6_require_hmac'), '-1') # ignore
+ self.assertEqual(
+ sysctl_read(f'net.ipv6.conf.{interface}.seg6_enabled'), '1'
+ )
+ self.assertEqual(
+ sysctl_read(f'net.ipv6.conf.{interface}.seg6_require_hmac'), '-1'
+ ) # ignore
# HMAC drop
for interface in interfaces:
@@ -96,8 +168,12 @@ class TestProtocolsSegmentRouting(VyOSUnitTestSHIM.TestCase):
self.cli_commit()
for interface in interfaces:
- self.assertEqual(sysctl_read(f'net.ipv6.conf.{interface}.seg6_enabled'), '1')
- self.assertEqual(sysctl_read(f'net.ipv6.conf.{interface}.seg6_require_hmac'), '1') # drop
+ self.assertEqual(
+ sysctl_read(f'net.ipv6.conf.{interface}.seg6_enabled'), '1'
+ )
+ self.assertEqual(
+ sysctl_read(f'net.ipv6.conf.{interface}.seg6_require_hmac'), '1'
+ ) # drop
# Disable SRv6 on first interface
first_if = interfaces[-1]
@@ -106,5 +182,6 @@ class TestProtocolsSegmentRouting(VyOSUnitTestSHIM.TestCase):
self.assertEqual(sysctl_read(f'net.ipv6.conf.{first_if}.seg6_enabled'), '0')
+
if __name__ == '__main__':
unittest.main(verbosity=2)