summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_protocols_ospfv3.py
diff options
context:
space:
mode:
Diffstat (limited to 'smoketest/scripts/cli/test_protocols_ospfv3.py')
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_ospfv3.py88
1 files changed, 38 insertions, 50 deletions
diff --git a/smoketest/scripts/cli/test_protocols_ospfv3.py b/smoketest/scripts/cli/test_protocols_ospfv3.py
index 754c4488f..6bb551642 100755
--- a/smoketest/scripts/cli/test_protocols_ospfv3.py
+++ b/smoketest/scripts/cli/test_protocols_ospfv3.py
@@ -14,12 +14,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import os
import unittest
+from base_vyostest_shim import VyOSUnitTestSHIM
+
from vyos.configsession import ConfigSession
from vyos.ifconfig import Section
-from vyos.util import cmd
from vyos.util import process_named_running
PROCESS_NAME = 'ospf6d'
@@ -28,47 +28,35 @@ base_path = ['protocols', 'ospfv3']
router_id = '192.0.2.1'
default_area = '0'
-def getFRROSPFconfig():
- return cmd('vtysh -c "show run" | sed -n "/router ospf6/,/^!/p"')
-
-def getFRRIFconfig(iface):
- return cmd(f'vtysh -c "show run" | sed -n "/^interface {iface}/,/^!/p"')
-
-class TestProtocolsOSPFv3(unittest.TestCase):
- def setUp(self):
- self.session = ConfigSession(os.getpid())
-
+class TestProtocolsOSPFv3(VyOSUnitTestSHIM.TestCase):
def tearDown(self):
# Check for running process
self.assertTrue(process_named_running(PROCESS_NAME))
-
- self.session.delete(base_path)
- self.session.commit()
- del self.session
-
+ self.cli_delete(base_path)
+ self.cli_commit()
def test_ospfv3_01_basic(self):
seq = '10'
prefix = '2001:db8::/32'
acl_name = 'foo-acl-100'
- self.session.set(['policy', 'access-list6', acl_name, 'rule', seq, 'action', 'permit'])
- self.session.set(['policy', 'access-list6', acl_name, 'rule', seq, 'source', 'any'])
+ self.cli_set(['policy', 'access-list6', acl_name, 'rule', seq, 'action', 'permit'])
+ self.cli_set(['policy', 'access-list6', acl_name, 'rule', seq, 'source', 'any'])
- self.session.set(base_path + ['parameters', 'router-id', router_id])
- self.session.set(base_path + ['area', default_area, 'range', prefix, 'advertise'])
- self.session.set(base_path + ['area', default_area, 'export-list', acl_name])
- self.session.set(base_path + ['area', default_area, 'import-list', acl_name])
+ self.cli_set(base_path + ['parameters', 'router-id', router_id])
+ self.cli_set(base_path + ['area', default_area, 'range', prefix, 'advertise'])
+ self.cli_set(base_path + ['area', default_area, 'export-list', acl_name])
+ self.cli_set(base_path + ['area', default_area, 'import-list', acl_name])
interfaces = Section.interfaces('ethernet')
for interface in interfaces:
- self.session.set(base_path + ['area', default_area, 'interface', interface])
+ self.cli_set(base_path + ['area', default_area, 'interface', interface])
# commit changes
- self.session.commit()
+ self.cli_commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = self.getFRRconfig('router ospf6')
self.assertIn(f'router ospf6', frrconfig)
self.assertIn(f' area {default_area} range {prefix}', frrconfig)
self.assertIn(f' ospf6 router-id {router_id}', frrconfig)
@@ -78,7 +66,7 @@ class TestProtocolsOSPFv3(unittest.TestCase):
for interface in interfaces:
self.assertIn(f' interface {interface} area {default_area}', frrconfig)
- self.session.delete(['policy', 'access-list6', acl_name])
+ self.cli_delete(['policy', 'access-list6', acl_name])
def test_ospfv3_02_distance(self):
@@ -87,16 +75,16 @@ class TestProtocolsOSPFv3(unittest.TestCase):
dist_inter_area = '120'
dist_intra_area = '130'
- self.session.set(base_path + ['distance', 'global', dist_global])
- self.session.set(base_path + ['distance', 'ospfv3', 'external', dist_external])
- self.session.set(base_path + ['distance', 'ospfv3', 'inter-area', dist_inter_area])
- self.session.set(base_path + ['distance', 'ospfv3', 'intra-area', dist_intra_area])
+ self.cli_set(base_path + ['distance', 'global', dist_global])
+ self.cli_set(base_path + ['distance', 'ospfv3', 'external', dist_external])
+ self.cli_set(base_path + ['distance', 'ospfv3', 'inter-area', dist_inter_area])
+ self.cli_set(base_path + ['distance', 'ospfv3', 'intra-area', dist_intra_area])
# commit changes
- self.session.commit()
+ self.cli_commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = self.getFRRconfig('router ospf6')
self.assertIn(f'router ospf6', frrconfig)
self.assertIn(f' distance {dist_global}', frrconfig)
self.assertIn(f' distance ospf6 intra-area {dist_intra_area} inter-area {dist_inter_area} external {dist_external}', frrconfig)
@@ -107,51 +95,51 @@ class TestProtocolsOSPFv3(unittest.TestCase):
route_map_seq = '10'
redistribute = ['bgp', 'connected', 'kernel', 'ripng', 'static']
- self.session.set(['policy', 'route-map', route_map, 'rule', route_map_seq, 'action', 'permit'])
+ self.cli_set(['policy', 'route-map', route_map, 'rule', route_map_seq, 'action', 'permit'])
for protocol in redistribute:
- self.session.set(base_path + ['redistribute', protocol, 'route-map', route_map])
+ self.cli_set(base_path + ['redistribute', protocol, 'route-map', route_map])
# commit changes
- self.session.commit()
+ self.cli_commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = self.getFRRconfig('router ospf6')
self.assertIn(f'router ospf6', frrconfig)
for protocol in redistribute:
self.assertIn(f' redistribute {protocol} route-map {route_map}', frrconfig)
- def test_ospfv3_0104_interfaces(self):
+ def test_ospfv3_04_interfaces(self):
- self.session.set(base_path + ['parameters', 'router-id', router_id])
- self.session.set(base_path + ['area', default_area])
+ self.cli_set(base_path + ['parameters', 'router-id', router_id])
+ self.cli_set(base_path + ['area', default_area])
cost = '100'
priority = '10'
interfaces = Section.interfaces('ethernet')
for interface in interfaces:
if_base = base_path + ['interface', interface]
- self.session.set(if_base + ['bfd'])
- self.session.set(if_base + ['cost', cost])
- self.session.set(if_base + ['instance-id', '0'])
- self.session.set(if_base + ['mtu-ignore'])
- self.session.set(if_base + ['network', 'point-to-point'])
- self.session.set(if_base + ['passive'])
- self.session.set(if_base + ['priority', priority])
+ self.cli_set(if_base + ['bfd'])
+ self.cli_set(if_base + ['cost', cost])
+ self.cli_set(if_base + ['instance-id', '0'])
+ self.cli_set(if_base + ['mtu-ignore'])
+ self.cli_set(if_base + ['network', 'point-to-point'])
+ self.cli_set(if_base + ['passive'])
+ self.cli_set(if_base + ['priority', priority])
cost = str(int(cost) + 10)
priority = str(int(priority) + 5)
# commit changes
- self.session.commit()
+ self.cli_commit()
# Verify FRR ospfd configuration
- frrconfig = getFRROSPFconfig()
+ frrconfig = self.getFRRconfig('router ospf6')
self.assertIn(f'router ospf6', frrconfig)
cost = '100'
priority = '10'
for interface in interfaces:
- if_config = getFRRIFconfig(interface)
+ if_config = self.getFRRconfig(f'interface {interface}')
self.assertIn(f'interface {interface}', if_config)
self.assertIn(f' ipv6 ospf6 bfd', if_config)
self.assertIn(f' ipv6 ospf6 cost {cost}', if_config)