summaryrefslogtreecommitdiff
path: root/smoketest/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'smoketest/scripts')
-rwxr-xr-xsmoketest/scripts/cli/test_firewall.py4
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_ethernet.py57
-rwxr-xr-xsmoketest/scripts/cli/test_nat.py17
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_ospf.py4
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_ospfv3.py10
-rwxr-xr-xsmoketest/scripts/cli/test_service_snmp.py17
6 files changed, 95 insertions, 14 deletions
diff --git a/smoketest/scripts/cli/test_firewall.py b/smoketest/scripts/cli/test_firewall.py
index be5960bbd..9e8473fa4 100755
--- a/smoketest/scripts/cli/test_firewall.py
+++ b/smoketest/scripts/cli/test_firewall.py
@@ -629,8 +629,8 @@ class TestFirewall(VyOSUnitTestSHIM.TestCase):
nftables_search = [
['ct state { established, related }', 'accept'],
['ct state invalid', 'reject'],
- ['ct state new', 'ct status == dnat', 'accept'],
- ['ct state { established, new }', 'ct status == snat', 'accept'],
+ ['ct state new', 'ct status dnat', 'accept'],
+ ['ct state { established, new }', 'ct status snat', 'accept'],
['ct state related', 'ct helper { "ftp", "pptp" }', 'accept'],
['drop', f'comment "{name} default-action drop"'],
['jump VYOS_STATE_POLICY'],
diff --git a/smoketest/scripts/cli/test_interfaces_ethernet.py b/smoketest/scripts/cli/test_interfaces_ethernet.py
index e414f18cb..8f387b23d 100755
--- a/smoketest/scripts/cli/test_interfaces_ethernet.py
+++ b/smoketest/scripts/cli/test_interfaces_ethernet.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2020-2022 VyOS maintainers and contributors
+# Copyright (C) 2020-2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -17,7 +17,9 @@
import os
import re
import unittest
+
from glob import glob
+from json import loads
from netifaces import AF_INET
from netifaces import AF_INET6
@@ -27,9 +29,9 @@ from base_interfaces_test import BasicInterfaceTest
from vyos.configsession import ConfigSessionError
from vyos.ifconfig import Section
from vyos.pki import CERT_BEGIN
-from vyos.template import is_ipv6
from vyos.utils.process import cmd
from vyos.utils.process import process_named_running
+from vyos.utils.process import popen
from vyos.utils.file import read_file
from vyos.utils.network import is_ipv6_link_local
@@ -301,5 +303,56 @@ class EthernetInterfaceTest(BasicInterfaceTest.TestCase):
self.cli_delete(['pki', 'ca', name])
self.cli_delete(['pki', 'certificate', cert_name])
+ def test_ethtool_ring_buffer(self):
+ for interface in self._interfaces:
+ # We do not use vyos.ethtool here to not have any chance
+ # for invalid testcases. Re-gain data by hand
+ tmp = cmd(f'sudo ethtool --json --show-ring {interface}')
+ tmp = loads(tmp)
+ max_rx = str(tmp[0]['rx-max'])
+ max_tx = str(tmp[0]['tx-max'])
+
+ self.cli_set(self._base_path + [interface, 'ring-buffer', 'rx', max_rx])
+ self.cli_set(self._base_path + [interface, 'ring-buffer', 'tx', max_tx])
+
+ self.cli_commit()
+
+ for interface in self._interfaces:
+ tmp = cmd(f'sudo ethtool --json --show-ring {interface}')
+ tmp = loads(tmp)
+ max_rx = str(tmp[0]['rx-max'])
+ max_tx = str(tmp[0]['tx-max'])
+ rx = str(tmp[0]['rx'])
+ tx = str(tmp[0]['tx'])
+
+ # validate if the above change was carried out properly and the
+ # ring-buffer size got increased
+ self.assertEqual(max_rx, rx)
+ self.assertEqual(max_tx, tx)
+
+ def test_ethtool_flow_control(self):
+ for interface in self._interfaces:
+ # Disable flow-control
+ self.cli_set(self._base_path + [interface, 'disable-flow-control'])
+ # Check current flow-control state on ethernet interface
+ out, err = popen(f'sudo ethtool --json --show-pause {interface}')
+ # Flow-control not supported - test if it bails out with a proper
+ # this is a dynamic path where err = 1 on VMware, but err = 0 on
+ # a physical box.
+ if bool(err):
+ with self.assertRaises(ConfigSessionError):
+ self.cli_commit()
+ else:
+ out = loads(out)
+ # Flow control is on
+ self.assertTrue(out[0]['autonegotiate'])
+
+ # commit change on CLI to disable-flow-control and re-test
+ self.cli_commit()
+
+ out, err = popen(f'sudo ethtool --json --show-pause {interface}')
+ out = loads(out)
+ self.assertFalse(out[0]['autonegotiate'])
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/smoketest/scripts/cli/test_nat.py b/smoketest/scripts/cli/test_nat.py
index 4f1c3cb4f..43e374398 100755
--- a/smoketest/scripts/cli/test_nat.py
+++ b/smoketest/scripts/cli/test_nat.py
@@ -87,21 +87,28 @@ class TestNAT(VyOSUnitTestSHIM.TestCase):
address_group_member = '192.0.2.1'
interface_group = 'smoketest_ifaces'
interface_group_member = 'bond.99'
- rule = '100'
self.cli_set(['firewall', 'group', 'address-group', address_group, 'address', address_group_member])
self.cli_set(['firewall', 'group', 'interface-group', interface_group, 'interface', interface_group_member])
- self.cli_set(src_path + ['rule', rule, 'source', 'group', 'address-group', address_group])
- self.cli_set(src_path + ['rule', rule, 'outbound-interface', 'group', interface_group])
- self.cli_set(src_path + ['rule', rule, 'translation', 'address', 'masquerade'])
+ self.cli_set(src_path + ['rule', '100', 'source', 'group', 'address-group', address_group])
+ self.cli_set(src_path + ['rule', '100', 'outbound-interface', 'group', interface_group])
+ self.cli_set(src_path + ['rule', '100', 'translation', 'address', 'masquerade'])
+
+ self.cli_set(src_path + ['rule', '110', 'source', 'group', 'address-group', address_group])
+ self.cli_set(src_path + ['rule', '110', 'translation', 'address', '203.0.113.1'])
+
+ self.cli_set(src_path + ['rule', '120', 'source', 'group', 'address-group', address_group])
+ self.cli_set(src_path + ['rule', '120', 'translation', 'address', '203.0.113.111/32'])
self.cli_commit()
nftables_search = [
[f'set A_{address_group}'],
[f'elements = {{ {address_group_member} }}'],
- [f'ip saddr @A_{address_group}', f'oifname @I_{interface_group}', 'masquerade']
+ [f'ip saddr @A_{address_group}', f'oifname @I_{interface_group}', 'masquerade'],
+ [f'ip saddr @A_{address_group}', 'snat to 203.0.113.1'],
+ [f'ip saddr @A_{address_group}', 'snat prefix to 203.0.113.111/32']
]
self.verify_nftables(nftables_search, 'ip vyos_nat')
diff --git a/smoketest/scripts/cli/test_protocols_ospf.py b/smoketest/scripts/cli/test_protocols_ospf.py
index 6bffc7c45..82fb96754 100755
--- a/smoketest/scripts/cli/test_protocols_ospf.py
+++ b/smoketest/scripts/cli/test_protocols_ospf.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2021-2023 VyOS maintainers and contributors
+# Copyright (C) 2021-2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -240,7 +240,7 @@ class TestProtocolsOSPF(VyOSUnitTestSHIM.TestCase):
def test_ospf_07_redistribute(self):
metric = '15'
metric_type = '1'
- redistribute = ['bgp', 'connected', 'isis', 'kernel', 'rip', 'static']
+ redistribute = ['babel', 'bgp', 'connected', 'isis', 'kernel', 'rip', 'static']
for protocol in redistribute:
self.cli_set(base_path + ['redistribute', protocol, 'metric', metric])
diff --git a/smoketest/scripts/cli/test_protocols_ospfv3.py b/smoketest/scripts/cli/test_protocols_ospfv3.py
index 4ae7f05d9..989e1552d 100755
--- a/smoketest/scripts/cli/test_protocols_ospfv3.py
+++ b/smoketest/scripts/cli/test_protocols_ospfv3.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2021-2023 VyOS maintainers and contributors
+# Copyright (C) 2021-2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -114,14 +114,18 @@ class TestProtocolsOSPFv3(VyOSUnitTestSHIM.TestCase):
def test_ospfv3_03_redistribute(self):
+ metric = '15'
+ metric_type = '1'
route_map = 'foo-bar'
route_map_seq = '10'
- redistribute = ['bgp', 'connected', 'kernel', 'ripng', 'static']
+ redistribute = ['babel', 'bgp', 'connected', 'isis', 'kernel', 'ripng', 'static']
self.cli_set(['policy', 'route-map', route_map, 'rule', route_map_seq, 'action', 'permit'])
for protocol in redistribute:
+ self.cli_set(base_path + ['redistribute', protocol, 'metric', metric])
self.cli_set(base_path + ['redistribute', protocol, 'route-map', route_map])
+ self.cli_set(base_path + ['redistribute', protocol, 'metric-type', metric_type])
# commit changes
self.cli_commit()
@@ -130,7 +134,7 @@ class TestProtocolsOSPFv3(VyOSUnitTestSHIM.TestCase):
frrconfig = self.getFRRconfig('router ospf6', daemon=PROCESS_NAME)
self.assertIn(f'router ospf6', frrconfig)
for protocol in redistribute:
- self.assertIn(f' redistribute {protocol} route-map {route_map}', frrconfig)
+ self.assertIn(f' redistribute {protocol} metric {metric} metric-type {metric_type} route-map {route_map}', frrconfig)
def test_ospfv3_04_interfaces(self):
diff --git a/smoketest/scripts/cli/test_service_snmp.py b/smoketest/scripts/cli/test_service_snmp.py
index 52a72ec4f..b3daa90d0 100755
--- a/smoketest/scripts/cli/test_service_snmp.py
+++ b/smoketest/scripts/cli/test_service_snmp.py
@@ -229,5 +229,22 @@ class TestSNMPService(VyOSUnitTestSHIM.TestCase):
tmp = call(f'snmpwalk -v 3 -u {snmpv3_user} -a MD5 -A {snmpv3_auth_pw} -x DES -X {snmpv3_priv_pw} -l authPriv 127.0.0.1', stdout=DEVNULL)
self.assertEqual(tmp, 0)
+ def test_snmpv3_view_exclude(self):
+ snmpv3_view_oid_exclude = ['1.3.6.1.2.1.4.21', '1.3.6.1.2.1.4.24']
+
+ self.cli_set(base_path + ['v3', 'group', snmpv3_group, 'view', snmpv3_view])
+ self.cli_set(base_path + ['v3', 'view', snmpv3_view, 'oid', snmpv3_view_oid])
+
+ for excluded in snmpv3_view_oid_exclude:
+ self.cli_set(base_path + ['v3', 'view', snmpv3_view, 'oid', snmpv3_view_oid, 'exclude', excluded])
+
+ self.cli_commit()
+
+ tmp = read_file(SNMPD_CONF)
+ # views
+ self.assertIn(f'view {snmpv3_view} included .{snmpv3_view_oid}', tmp)
+ for excluded in snmpv3_view_oid_exclude:
+ self.assertIn(f'view {snmpv3_view} excluded .{excluded}', tmp)
+
if __name__ == '__main__':
unittest.main(verbosity=2)