summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-03-14 14:57:13 +0100
committerGitHub <noreply@github.com>2021-03-14 14:57:13 +0100
commit2785a486f798c5e36d59c58720334f7bdffcbb3e (patch)
tree1510d0c47d32b6fd5153c8d7a1775cf367cb6022 /smoketest/scripts/cli
parent0f24c5b25bc277e0604608710cf81225d765b3be (diff)
parent7d67e8609471b6a5c9761a99301f368bd6747e13 (diff)
downloadvyos-1x-2785a486f798c5e36d59c58720334f7bdffcbb3e.tar.gz
vyos-1x-2785a486f798c5e36d59c58720334f7bdffcbb3e.zip
Merge pull request #770 from c-po/vrf-dynamic-routing
VRF: support for dynamic routing protocols OSPF and BGP
Diffstat (limited to 'smoketest/scripts/cli')
-rw-r--r--smoketest/scripts/cli/base_interfaces_test.py4
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_erspan.py6
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_geneve.py4
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_macsec.py4
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_tunnel.py12
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_vxlan.py4
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_bgp.py34
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_ospf.py64
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_static.py54
-rwxr-xr-xsmoketest/scripts/cli/test_vrf.py6
10 files changed, 131 insertions, 61 deletions
diff --git a/smoketest/scripts/cli/base_interfaces_test.py b/smoketest/scripts/cli/base_interfaces_test.py
index d038e9cb8..50cfa2607 100644
--- a/smoketest/scripts/cli/base_interfaces_test.py
+++ b/smoketest/scripts/cli/base_interfaces_test.py
@@ -29,7 +29,7 @@ from vyos.util import read_file
from vyos.util import cmd
from vyos.util import dict_search
from vyos.util import process_named_running
-from vyos.util import get_json_iface_options
+from vyos.util import get_interface_config
from vyos.validate import is_intf_addr_assigned
from vyos.validate import is_ipv6_link_local
@@ -353,7 +353,7 @@ class BasicInterfaceTest:
for interface in self._interfaces:
for vif_s in self._qinq_range:
- tmp = get_json_iface_options(f'{interface}.{vif_s}')
+ tmp = get_interface_config(f'{interface}.{vif_s}')
self.assertEqual(dict_search('linkinfo.info_data.protocol', tmp), '802.1ad')
for vif_c in self._vlan_range:
diff --git a/smoketest/scripts/cli/test_interfaces_erspan.py b/smoketest/scripts/cli/test_interfaces_erspan.py
index cbb41d0c9..4575c61ce 100755
--- a/smoketest/scripts/cli/test_interfaces_erspan.py
+++ b/smoketest/scripts/cli/test_interfaces_erspan.py
@@ -18,7 +18,7 @@ import unittest
from vyos.configsession import ConfigSession
from vyos.configsession import ConfigSessionError
-from vyos.util import get_json_iface_options
+from vyos.util import get_interface_config
from base_interfaces_test import BasicInterfaceTest
@@ -52,7 +52,7 @@ class ERSPanTunnelInterfaceTest(BasicInterfaceTest.BaseTest):
self.session.commit()
- conf = get_json_iface_options(interface)
+ conf = get_interface_config(interface)
self.assertEqual(interface, conf['ifname'])
self.assertEqual(encapsulation, conf['linkinfo']['info_kind'])
self.assertEqual(mtu, conf['mtu'])
@@ -73,7 +73,7 @@ class ERSPanTunnelInterfaceTest(BasicInterfaceTest.BaseTest):
self.session.commit()
- conf = get_json_iface_options(interface)
+ conf = get_interface_config(interface)
self.assertEqual(interface, conf['ifname'])
self.assertEqual(encapsulation, conf['linkinfo']['info_kind'])
self.assertEqual(mtu, conf['mtu'])
diff --git a/smoketest/scripts/cli/test_interfaces_geneve.py b/smoketest/scripts/cli/test_interfaces_geneve.py
index 7edd4528e..e8e8e5a2c 100755
--- a/smoketest/scripts/cli/test_interfaces_geneve.py
+++ b/smoketest/scripts/cli/test_interfaces_geneve.py
@@ -18,7 +18,7 @@ import unittest
from vyos.configsession import ConfigSession
from vyos.ifconfig import Interface
-from vyos.util import get_json_iface_options
+from vyos.util import get_interface_config
from base_interfaces_test import BasicInterfaceTest
@@ -51,7 +51,7 @@ class GeneveInterfaceTest(BasicInterfaceTest.BaseTest):
ttl = 20
for interface in self._interfaces:
- options = get_json_iface_options(interface)
+ options = get_interface_config(interface)
vni = options['linkinfo']['info_data']['id']
self.assertIn(f'vni {vni}', self._options[interface])
diff --git a/smoketest/scripts/cli/test_interfaces_macsec.py b/smoketest/scripts/cli/test_interfaces_macsec.py
index 2f1898b6f..31071a0f7 100755
--- a/smoketest/scripts/cli/test_interfaces_macsec.py
+++ b/smoketest/scripts/cli/test_interfaces_macsec.py
@@ -25,7 +25,7 @@ from vyos.configsession import ConfigSessionError
from vyos.ifconfig import Section
from vyos.util import cmd
from vyos.util import read_file
-from vyos.util import get_json_iface_options
+from vyos.util import get_interface_config
from vyos.util import process_named_running
def get_config_value(interface, key):
@@ -34,7 +34,7 @@ def get_config_value(interface, key):
return tmp[0]
def get_cipher(interface):
- tmp = get_json_iface_options(interface)
+ tmp = get_interface_config(interface)
return tmp['linkinfo']['info_data']['cipher_suite'].lower()
class MACsecInterfaceTest(BasicInterfaceTest.BaseTest):
diff --git a/smoketest/scripts/cli/test_interfaces_tunnel.py b/smoketest/scripts/cli/test_interfaces_tunnel.py
index cad6764e6..3dddb5ef0 100755
--- a/smoketest/scripts/cli/test_interfaces_tunnel.py
+++ b/smoketest/scripts/cli/test_interfaces_tunnel.py
@@ -18,7 +18,7 @@ import unittest
from vyos.configsession import ConfigSession
from vyos.configsession import ConfigSessionError
-from vyos.util import get_json_iface_options
+from vyos.util import get_interface_config
from vyos.template import inc_ip
from base_interfaces_test import BasicInterfaceTest
@@ -84,7 +84,7 @@ class TunnelInterfaceTest(BasicInterfaceTest.BaseTest):
# Check if commit is ok
self.session.commit()
- conf = get_json_iface_options(interface)
+ conf = get_interface_config(interface)
if encapsulation not in ['sit', 'gretap']:
self.assertEqual(source_if, conf['link'])
@@ -132,7 +132,7 @@ class TunnelInterfaceTest(BasicInterfaceTest.BaseTest):
# Check if commit is ok
self.session.commit()
- conf = get_json_iface_options(interface)
+ conf = get_interface_config(interface)
if encapsulation not in ['ip6gretap']:
self.assertEqual(source_if, conf['link'])
@@ -192,7 +192,7 @@ class TunnelInterfaceTest(BasicInterfaceTest.BaseTest):
# Check if commit is ok
self.session.commit()
- conf = get_json_iface_options(interface)
+ conf = get_interface_config(interface)
self.assertEqual(mtu, conf['mtu'])
self.assertEqual(interface, conf['ifname'])
self.assertEqual(encapsulation, conf['linkinfo']['info_kind'])
@@ -214,7 +214,7 @@ class TunnelInterfaceTest(BasicInterfaceTest.BaseTest):
# Check if commit is ok
self.session.commit()
- conf = get_json_iface_options(interface)
+ conf = get_interface_config(interface)
self.assertEqual(mtu, conf['mtu'])
self.assertEqual(interface, conf['ifname'])
self.assertEqual(encapsulation, conf['linkinfo']['info_kind'])
@@ -228,7 +228,7 @@ class TunnelInterfaceTest(BasicInterfaceTest.BaseTest):
# Check if commit is ok
self.session.commit()
- conf = get_json_iface_options(interface)
+ conf = get_interface_config(interface)
self.assertEqual(new_remote, conf['linkinfo']['info_data']['remote'])
if __name__ == '__main__':
diff --git a/smoketest/scripts/cli/test_interfaces_vxlan.py b/smoketest/scripts/cli/test_interfaces_vxlan.py
index b66315c5e..2a04b0477 100755
--- a/smoketest/scripts/cli/test_interfaces_vxlan.py
+++ b/smoketest/scripts/cli/test_interfaces_vxlan.py
@@ -18,7 +18,7 @@ import unittest
from vyos.configsession import ConfigSession
from vyos.ifconfig import Interface
-from vyos.util import get_json_iface_options
+from vyos.util import get_interface_config
from base_interfaces_test import BasicInterfaceTest
@@ -52,7 +52,7 @@ class VXLANInterfaceTest(BasicInterfaceTest.BaseTest):
ttl = 20
for interface in self._interfaces:
- options = get_json_iface_options(interface)
+ options = get_interface_config(interface)
vni = options['linkinfo']['info_data']['id']
self.assertIn(f'vni {vni}', self._options[interface])
diff --git a/smoketest/scripts/cli/test_protocols_bgp.py b/smoketest/scripts/cli/test_protocols_bgp.py
index 9aa1541cf..7d397b55e 100755
--- a/smoketest/scripts/cli/test_protocols_bgp.py
+++ b/smoketest/scripts/cli/test_protocols_bgp.py
@@ -128,17 +128,19 @@ peer_group_config = {
},
}
-def getFRRBGPconfig():
- return cmd(f'vtysh -c "show run" | sed -n "/^router bgp {ASN}/,/^!/p"')
+def getFRRBGPconfig(vrf=None):
+ if vrf:
+ return cmd(f'vtysh -c "show run" | sed -n "/^router bgp {ASN} vrf {vrf}$/,/^!/p"')
+ return cmd(f'vtysh -c "show run" | sed -n "/^router bgp {ASN}$/,/^!/p"')
def getFRRBgpAfiConfig(afi):
- return cmd(f'vtysh -c "show run" | sed -n "/^router bgp {ASN}/,/^!/p" | sed -n "/^ address-family {afi} unicast/,/^ exit-address-family/p"')
+ return cmd(f'vtysh -c "show run" | sed -n "/^router bgp {ASN}$/,/^!/p" | sed -n "/^ address-family {afi} unicast/,/^ exit-address-family/p"')
def getFRRBGPVNIconfig(vni):
- return cmd(f'vtysh -c "show run" | sed -n "/^ vni {vni}/,/^!/p"')
+ return cmd(f'vtysh -c "show run" | sed -n "/^ vni {vni}$/,/^!/p"')
def getFRRRPKIconfig():
- return cmd(f'vtysh -c "show run" | sed -n "/^rpki/,/^!/p"')
+ return cmd(f'vtysh -c "show run" | sed -n "/^rpki$/,/^!/p"')
class TestProtocolsBGP(unittest.TestCase):
def setUp(self):
@@ -551,5 +553,27 @@ class TestProtocolsBGP(unittest.TestCase):
self.assertIn(f' advertise-default-gw', vniconfig)
self.assertIn(f' advertise-svi-ip', vniconfig)
+ def test_bgp_08_vrf_simple(self):
+ router_id = '127.0.0.3'
+ vrfs = ['red', 'green', 'blue']
+ # It is safe to assume that when the basic VRF test works, all
+ # other OSPF related features work, as we entirely inherit the CLI
+ # templates and Jinja2 FRR template.
+ table = '1000'
+ for vrf in vrfs:
+ vrf_base = ['vrf', 'name', vrf]
+ self.session.set(vrf_base + ['table', table])
+ self.session.set(vrf_base + ['protocols', 'bgp', ASN, 'parameters', 'router-id', router_id])
+ table = str(int(table) + 1000)
+
+ self.session.commit()
+
+ for vrf in vrfs:
+ # Verify FRR bgpd configuration
+ frrconfig = getFRRBGPconfig(vrf)
+
+ self.assertIn(f'router bgp {ASN} vrf {vrf}', frrconfig)
+ self.assertIn(f' bgp router-id {router_id}', frrconfig)
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/smoketest/scripts/cli/test_protocols_ospf.py b/smoketest/scripts/cli/test_protocols_ospf.py
index d9a6c17e4..532d84cc8 100755
--- a/smoketest/scripts/cli/test_protocols_ospf.py
+++ b/smoketest/scripts/cli/test_protocols_ospf.py
@@ -27,8 +27,10 @@ base_path = ['protocols', 'ospf']
route_map = 'foo-bar-baz10'
-def getFRROSPFconfig():
- return cmd('vtysh -c "show run" | sed -n "/^router ospf/,/^!/p"')
+def getFRRconfig(vrf=None):
+ if vrf:
+ return cmd(f'vtysh -c "show run" | sed -n "/^router ospf vrf {vrf}$/,/^!/p"')
+ return cmd('vtysh -c "show run" | sed -n "/^router ospf$/,/^!/p"')
def getFRRInterfaceConfig(interface):
return cmd(f'vtysh -c "show run" | sed -n "/^interface {interface}$/,/^!/p"')
@@ -45,6 +47,7 @@ class TestProtocolsOSPF(unittest.TestCase):
self.session.delete(['policy', 'route-map', route_map])
self.session.delete(base_path)
+
self.session.commit()
del self.session
@@ -54,12 +57,11 @@ class TestProtocolsOSPF(unittest.TestCase):
self.session.commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = getFRRconfig()
self.assertIn(f'router ospf', frrconfig)
self.assertIn(f' auto-cost reference-bandwidth 100', frrconfig)
self.assertIn(f' timers throttle spf 200 1000 10000', frrconfig) # defaults
-
def test_ospf_02_simple(self):
router_id = '127.0.0.1'
abr_type = 'ibm'
@@ -76,7 +78,7 @@ class TestProtocolsOSPF(unittest.TestCase):
self.session.commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = getFRRconfig()
self.assertIn(f'router ospf', frrconfig)
self.assertIn(f' auto-cost reference-bandwidth {bandwidth}', frrconfig)
self.assertIn(f' ospf router-id {router_id}', frrconfig)
@@ -100,7 +102,7 @@ class TestProtocolsOSPF(unittest.TestCase):
self.session.commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = getFRRconfig()
self.assertIn(f'router ospf', frrconfig)
self.assertIn(f' timers throttle spf 200 1000 10000', frrconfig) # defaults
for ptotocol in protocols:
@@ -121,7 +123,7 @@ class TestProtocolsOSPF(unittest.TestCase):
self.session.commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = getFRRconfig()
self.assertIn(f'router ospf', frrconfig)
self.assertIn(f' timers throttle spf 200 1000 10000', frrconfig) # defaults
self.assertIn(f' default-information originate metric {metric} metric-type {metric_type} route-map {route_map}', frrconfig)
@@ -131,7 +133,7 @@ class TestProtocolsOSPF(unittest.TestCase):
self.session.commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = getFRRconfig()
self.assertIn(f' default-information originate always metric {metric} metric-type {metric_type} route-map {route_map}', frrconfig)
@@ -158,7 +160,7 @@ class TestProtocolsOSPF(unittest.TestCase):
self.session.commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = getFRRconfig()
self.assertIn(f'router ospf', frrconfig)
self.assertIn(f' mpls-te on', frrconfig)
self.assertIn(f' mpls-te router-address 0.0.0.0', frrconfig) # default
@@ -173,7 +175,7 @@ class TestProtocolsOSPF(unittest.TestCase):
self.session.set(base_path + ['distance', 'ospf', 'inter-area', inter_area])
self.session.commit()
- frrconfig = getFRROSPFconfig()
+ frrconfig = getFRRconfig()
self.assertIn(f' distance ospf intra-area {intra_area} inter-area {inter_area} external {external}', frrconfig)
@@ -189,7 +191,7 @@ class TestProtocolsOSPF(unittest.TestCase):
self.session.commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = getFRRconfig()
self.assertIn(f'router ospf', frrconfig)
for neighbor in neighbors:
self.assertIn(f' neighbor {neighbor} priority {priority} poll-interval {poll_interval}', frrconfig) # default
@@ -205,7 +207,7 @@ class TestProtocolsOSPF(unittest.TestCase):
self.session.commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = getFRRconfig()
self.assertIn(f'router ospf', frrconfig)
self.assertIn(f' passive-interface default', frrconfig) # default
for interface in interfaces:
@@ -227,7 +229,7 @@ class TestProtocolsOSPF(unittest.TestCase):
self.session.commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = getFRRconfig()
self.assertIn(f'router ospf', frrconfig)
for protocol in redistribute:
if protocol in ['kernel', 'static']:
@@ -235,6 +237,7 @@ class TestProtocolsOSPF(unittest.TestCase):
else:
self.assertIn(f' redistribute {protocol} metric {metric} metric-type {metric_type} route-map {route_map}', frrconfig)
+
def test_ospf_09_virtual_link(self):
networks = ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16']
area = '10'
@@ -257,7 +260,7 @@ class TestProtocolsOSPF(unittest.TestCase):
self.session.commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = getFRRconfig()
import pprint
# From time to time the CI fails with an error like:
# ======================================================================
@@ -277,6 +280,7 @@ class TestProtocolsOSPF(unittest.TestCase):
for network in networks:
self.assertIn(f' network {network} area {area}', frrconfig)
+
def test_ospf_10_interface_configureation(self):
interfaces = Section.interfaces('ethernet')
password = 'vyos1234'
@@ -308,5 +312,37 @@ class TestProtocolsOSPF(unittest.TestCase):
self.assertIn(f' ip ospf priority {priority}', config)
self.assertIn(f' bandwidth {bandwidth}', config)
+
+ def test_ospf_11_vrfs(self):
+ vrfs = ['red', 'green', 'blue']
+ # It is safe to assume that when the basic VRF test works, all
+ # other OSPF related features work, as we entirely inherit the CLI
+ # templates and Jinja2 FRR template.
+ table = '1000'
+ for vrf in vrfs:
+ vrf_base = ['vrf', 'name', vrf]
+ self.session.set(vrf_base + ['table', table])
+ self.session.set(vrf_base + ['protocols', 'ospf'])
+ table = str(int(table) + 1000)
+
+ # Also set a default VRF OSPF config
+ self.session.set(base_path)
+ self.session.commit()
+
+ # Verify FRR ospfd configuration
+ frrconfig = getFRRconfig()
+ self.assertIn(f'router ospf', frrconfig)
+ self.assertIn(f' auto-cost reference-bandwidth 100', frrconfig)
+ self.assertIn(f' timers throttle spf 200 1000 10000', frrconfig) # defaults
+
+ for vrf in vrfs:
+ frrconfig = getFRRconfig(vrf)
+ self.assertIn(f'router ospf vrf {vrf}', frrconfig)
+ self.assertIn(f' auto-cost reference-bandwidth 100', frrconfig)
+ self.assertIn(f' timers throttle spf 200 1000 10000', frrconfig) # defaults
+
+ self.session.delete(['vrf', 'name', vrf])
+
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/smoketest/scripts/cli/test_protocols_static.py b/smoketest/scripts/cli/test_protocols_static.py
index cf591f060..28ae5e2dd 100755
--- a/smoketest/scripts/cli/test_protocols_static.py
+++ b/smoketest/scripts/cli/test_protocols_static.py
@@ -21,6 +21,7 @@ from vyos.configsession import ConfigSession
from vyos.configsession import ConfigSessionError
from vyos.template import is_ipv6
from vyos.util import cmd
+from vyos.util import get_interface_config
base_path = ['protocols', 'static']
vrf_path = ['protocols', 'vrf']
@@ -85,7 +86,6 @@ routes = {
},
}
-vrfs = ['red', 'green', 'blue']
tables = ['80', '81', '82']
class StaticRouteTest(unittest.TestCase):
@@ -99,9 +99,6 @@ class StaticRouteTest(unittest.TestCase):
route_type = 'route6'
self.session.delete(base_path + [route_type, route])
- for vrf in vrfs:
- self.session.delete(vrf_path + [vrf])
-
for table in tables:
self.session.delete(base_path + ['table', table])
@@ -290,47 +287,65 @@ class StaticRouteTest(unittest.TestCase):
def test_protocols_vrf_static(self):
- for vrf in vrfs:
+ # Create VRF instances and apply the static routes from above to FRR.
+ # Re-read the configured routes and match them if they are programmed
+ # properly. This also includes VRF leaking
+ vrfs = {
+ 'red' : { 'table' : '1000' },
+ 'green' : { 'table' : '2000' },
+ 'blue' : { 'table' : '3000' },
+ }
+
+ for vrf, vrf_config in vrfs.items():
+ vrf_base_path = ['vrf', 'name', vrf]
+ self.session.set(vrf_base_path + ['table', vrf_config['table']])
+
for route, route_config in routes.items():
route_type = 'route'
if is_ipv6(route):
route_type = 'route6'
- base = vrf_path + [vrf, 'static', route_type, route]
+ route_base_path = vrf_base_path + ['protocols', 'static', route_type, route]
if 'next_hop' in route_config:
for next_hop, next_hop_config in route_config['next_hop'].items():
- self.session.set(base + ['next-hop', next_hop])
+ self.session.set(route_base_path + ['next-hop', next_hop])
if 'disable' in next_hop_config:
- self.session.set(base + ['next-hop', next_hop, 'disable'])
+ self.session.set(route_base_path + ['next-hop', next_hop, 'disable'])
if 'distance' in next_hop_config:
- self.session.set(base + ['next-hop', next_hop, 'distance', next_hop_config['distance']])
+ self.session.set(route_base_path + ['next-hop', next_hop, 'distance', next_hop_config['distance']])
if 'interface' in next_hop_config:
- self.session.set(base + ['next-hop', next_hop, 'interface', next_hop_config['interface']])
+ self.session.set(route_base_path + ['next-hop', next_hop, 'interface', next_hop_config['interface']])
if 'vrf' in next_hop_config:
- self.session.set(base + ['next-hop', next_hop, 'vrf', next_hop_config['vrf']])
+ self.session.set(route_base_path + ['next-hop', next_hop, 'vrf', next_hop_config['vrf']])
if 'interface' in route_config:
for interface, interface_config in route_config['interface'].items():
- self.session.set(base + ['interface', interface])
+ self.session.set(route_base_path + ['interface', interface])
if 'disable' in interface_config:
- self.session.set(base + ['interface', interface, 'disable'])
+ self.session.set(route_base_path + ['interface', interface, 'disable'])
if 'distance' in interface_config:
- self.session.set(base + ['interface', interface, 'distance', interface_config['distance']])
+ self.session.set(route_base_path + ['interface', interface, 'distance', interface_config['distance']])
if 'vrf' in interface_config:
- self.session.set(base + ['interface', interface, 'vrf', interface_config['vrf']])
+ self.session.set(route_base_path + ['interface', interface, 'vrf', interface_config['vrf']])
if 'blackhole' in route_config:
- self.session.set(base + ['blackhole'])
+ self.session.set(route_base_path + ['blackhole'])
if 'distance' in route_config['blackhole']:
- self.session.set(base + ['blackhole', 'distance', route_config['blackhole']['distance']])
+ self.session.set(route_base_path + ['blackhole', 'distance', route_config['blackhole']['distance']])
if 'tag' in route_config['blackhole']:
- self.session.set(base + ['blackhole', 'tag', route_config['blackhole']['tag']])
+ self.session.set(route_base_path + ['blackhole', 'tag', route_config['blackhole']['tag']])
# commit changes
self.session.commit()
- for vrf in vrfs:
+ for vrf, vrf_config in vrfs.items():
+ tmp = get_interface_config(vrf)
+
+ # Compare VRF table ID
+ self.assertEqual(tmp['linkinfo']['info_data']['table'], int(vrf_config['table']))
+ self.assertEqual(tmp['linkinfo']['info_kind'], 'vrf')
+
# Verify FRR bgpd configuration
frrconfig = getFRRCconfig(vrf)
self.assertIn(f'vrf {vrf}', frrconfig)
@@ -380,6 +395,7 @@ class StaticRouteTest(unittest.TestCase):
self.assertIn(tmp, frrconfig)
+ self.session.delete(['vrf'])
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/smoketest/scripts/cli/test_vrf.py b/smoketest/scripts/cli/test_vrf.py
index 8e977d407..aac115663 100755
--- a/smoketest/scripts/cli/test_vrf.py
+++ b/smoketest/scripts/cli/test_vrf.py
@@ -33,12 +33,6 @@ from vyos.validate import is_intf_addr_assigned
base_path = ['vrf']
vrfs = ['red', 'green', 'blue', 'foo-bar', 'baz_foo']
-def get_vrf_ipv4_routes(vrf):
- return json.loads(cmd(f'ip -4 -j route show vrf {vrf}'))
-
-def get_vrf_ipv6_routes(vrf):
- return json.loads(cmd(f'ip -6 -j route show vrf {vrf}'))
-
class VRFTest(unittest.TestCase):
_interfaces = []