summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_interfaces_ethernet.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-03-03 20:24:46 +0100
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-03-04 14:04:44 +0000
commit09abfcbadc2ee664c674a4861d1d450de0be0c53 (patch)
tree5decc9c58254f64b26dbbee6bcce1d6fcb3f72cd /smoketest/scripts/cli/test_interfaces_ethernet.py
parent55f7ec899145279327e03c269bed89358285894b (diff)
downloadvyos-1x-09abfcbadc2ee664c674a4861d1d450de0be0c53.tar.gz
vyos-1x-09abfcbadc2ee664c674a4861d1d450de0be0c53.zip
vyos.ethtool: T6083: use JSON input data for ethernet interface flow-control settings
(cherry picked from commit 5ee89f46096626ca8aac37da9237635e3d17766a)
Diffstat (limited to 'smoketest/scripts/cli/test_interfaces_ethernet.py')
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_ethernet.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_interfaces_ethernet.py b/smoketest/scripts/cli/test_interfaces_ethernet.py
index 9bf6a1a61..8f387b23d 100755
--- a/smoketest/scripts/cli/test_interfaces_ethernet.py
+++ b/smoketest/scripts/cli/test_interfaces_ethernet.py
@@ -31,6 +31,7 @@ from vyos.ifconfig import Section
from vyos.pki import CERT_BEGIN
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
@@ -304,6 +305,8 @@ class EthernetInterfaceTest(BasicInterfaceTest.TestCase):
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'])
@@ -327,5 +330,29 @@ class EthernetInterfaceTest(BasicInterfaceTest.TestCase):
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)