From 66dc5d82b54744a053230dfc34b12b88f1521947 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 1 Jun 2022 04:01:10 +0900 Subject: [PATCH] test-network: call networkctl only when specified interface exists Otherwise, this easily trigger another exception: ``` ====================================================================== ERROR: test_erspan_tunnel_v0 (__main__.NetworkdNetDevTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "./test/test-network/systemd-networkd-tests.py", line 686, in wait_online check_output(*args, env=env) File "./test/test-network/systemd-networkd-tests.py", line 65, in check_output return subprocess.check_output(command, universal_newlines=True, **kwargs).rstrip() File "/usr/lib64/python3.6/subprocess.py", line 356, in check_output **kwargs).stdout File "/usr/lib64/python3.6/subprocess.py", line 438, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['/usr/lib/systemd/systemd-networkd-wait-online', '--timeout=20s', '--interface=erspan99:routable', '--interface=erspan98:routable', '--interface=dummy98:degraded']' returned non-zero exit status 1. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "./test/test-network/systemd-networkd-tests.py", line 1808, in test_erspan_tunnel_v0 self.wait_online(['erspan99:routable', 'erspan98:routable', 'dummy98:degraded']) File "./test/test-network/systemd-networkd-tests.py", line 689, in wait_online output = check_output(*networkctl_cmd, '-n', '0', 'status', link.split(':')[0], env=env) File "./test/test-network/systemd-networkd-tests.py", line 65, in check_output return subprocess.check_output(command, universal_newlines=True, **kwargs).rstrip() File "/usr/lib64/python3.6/subprocess.py", line 356, in check_output **kwargs).stdout File "/usr/lib64/python3.6/subprocess.py", line 438, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['/usr/bin/networkctl', '-n', '0', 'status', 'erspan99']' returned non-zero exit status 1. ``` --- test/test-network/systemd-networkd-tests.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 7be99f2509c..7a962ba7084 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -699,8 +699,10 @@ class Utilities(): check_output(*args, env=env) except subprocess.CalledProcessError: for link in links_with_operstate: - output = check_output(*networkctl_cmd, '-n', '0', 'status', link.split(':')[0], env=env) - print(output) + name = link.split(':')[0] + if link_exists(name): + output = check_output(*networkctl_cmd, '-n', '0', 'status', name, env=env) + print(output) raise if not bool_any and setup_state: for link in links_with_operstate: -- 2.47.3