]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test/networkd-test: in bridge test, wait for online after restart systemd-networkd
authorDan Streetman <ddstreet@canonical.com>
Mon, 24 May 2021 23:41:25 +0000 (19:41 -0400)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 28 May 2021 03:26:33 +0000 (12:26 +0900)
without waiting for online, there is a race condition between systemd-networkd
actually setting the new values and the test checking those values

This also sets the link down before restarting systemd-networkd, to avoid
the wait for online being a no-op

test/networkd-test.py

index c13a20dd7f0292fbb6e16aa558eaa591adfcc1d0..799df0877ffeeaab64c043d39116fece8a077e16 100755 (executable)
@@ -247,7 +247,10 @@ Gateway=192.168.250.1
 [Bridge]
 Priority=28
 ''')
+        subprocess.check_call(['ip', 'link', 'set', 'dev', 'port1', 'down'])
         subprocess.check_call(['systemctl', 'restart', 'systemd-networkd'])
+        subprocess.check_call([NETWORKD_WAIT_ONLINE, '--interface',
+                               'port1', '--timeout=5'])
         self.assertEqual(self.read_attr('port1', 'brport/priority'), '28')
 
     def test_bridge_port_priority_set_zero(self):
@@ -257,7 +260,10 @@ Priority=28
 [Bridge]
 Priority=0
 ''')
+        subprocess.check_call(['ip', 'link', 'set', 'dev', 'port2', 'down'])
         subprocess.check_call(['systemctl', 'restart', 'systemd-networkd'])
+        subprocess.check_call([NETWORKD_WAIT_ONLINE, '--interface',
+                               'port2', '--timeout=5'])
         self.assertEqual(self.read_attr('port2', 'brport/priority'), '0')
 
     def test_bridge_port_property(self):
@@ -273,7 +279,10 @@ AllowPortToBeRoot=true
 Cost=555
 Priority=23
 ''')
+        subprocess.check_call(['ip', 'link', 'set', 'dev', 'port2', 'down'])
         subprocess.check_call(['systemctl', 'restart', 'systemd-networkd'])
+        subprocess.check_call([NETWORKD_WAIT_ONLINE, '--interface',
+                               'port2', '--timeout=5'])
 
         self.assertEqual(self.read_attr('port2', 'brport/priority'), '23')
         self.assertEqual(self.read_attr('port2', 'brport/hairpin_mode'), '1')