summaryrefslogtreecommitdiff
path: root/test/test-network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-07-12 23:06:36 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-07-13 02:36:14 +0200
commite11d0e3925f5252a8de52dbcdcd08eab56cd0779 (patch)
tree9ff4b967aedc5aa76c54b17653f77a0a3d251186 /test/test-network
parent278e815bfa3e4c2e3914e00121c37fc844cb2025 (diff)
downloadsystemd-e11d0e3925f5252a8de52dbcdcd08eab56cd0779.tar.gz
test-network: wait for L2TP tunnels being removed
Fixes #23985.
Diffstat (limited to 'test/test-network')
-rwxr-xr-xtest/test-network/systemd-networkd-tests.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py
index 7a791af003..bb9ca43585 100755
--- a/test/test-network/systemd-networkd-tests.py
+++ b/test/test-network/systemd-networkd-tests.py
@@ -447,12 +447,24 @@ def flush_fou_ports():
call(f'ip fou del port {port}')
def flush_l2tp_tunnels():
+ tids = []
output = check_output('ip l2tp show tunnel')
for line in output.splitlines():
words = line.split()
if words[0] == 'Tunnel':
tid = words[1].rstrip(',')
call(f'ip l2tp del tunnel tunnel_id {tid}')
+ tids.append(tid)
+
+ # Removing L2TP tunnel is asynchronous and slightly takes a time.
+ for tid in tids:
+ for _ in range(50):
+ r = run(f'ip l2tp show tunnel tunnel_id {tid}')
+ if r.returncode != 0 or len(r.stdout.rstrip()) == 0:
+ break
+ time.sleep(.2)
+ else:
+ print(f'Cannot remove L2TP tunnel {tid}, ignoring.')
def read_link_attr(*args):
with open(os.path.join('/sys/class/net', *args), encoding='utf-8') as f:
@@ -572,6 +584,7 @@ def tear_down_common():
call_quiet('ip netns del ns99')
# 4. remove links
+ flush_l2tp_tunnels()
flush_links()
# 5. stop networkd
@@ -583,7 +596,6 @@ def tear_down_common():
# 7. flush settings
flush_fou_ports()
- flush_l2tp_tunnels()
flush_nexthops()
flush_routing_policy_rules()
flush_routes()