diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-02-06 12:45:56 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-02-08 14:00:07 +0100 |
commit | 804b6cd26b60dfb0b4a919111823a8d105fde761 (patch) | |
tree | c1939c35810040e7d8f85de521e7cd2f43aa5214 /test | |
parent | networkd: Allow to retain configs even if carrier is lost (diff) | |
download | systemd-804b6cd26b60dfb0b4a919111823a8d105fde761.tar.xz systemd-804b6cd26b60dfb0b4a919111823a8d105fde761.zip |
test-network: add testcases for IgnoreCarrierLoss=
Diffstat (limited to 'test')
-rw-r--r-- | test/test-network/conf/bridge99-ignore-carrier-loss.network | 7 | ||||
-rwxr-xr-x | test/test-network/systemd-networkd-tests.py | 37 |
2 files changed, 44 insertions, 0 deletions
diff --git a/test/test-network/conf/bridge99-ignore-carrier-loss.network b/test/test-network/conf/bridge99-ignore-carrier-loss.network new file mode 100644 index 0000000000..922d57091e --- /dev/null +++ b/test/test-network/conf/bridge99-ignore-carrier-loss.network @@ -0,0 +1,7 @@ +[Match] +Name=bridge99 + +[Network] +Address=192.168.0.15/24 +Gateway=192.168.0.1 +IgnoreCarrierLoss=true diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 29bd08906c..29a6c44ee1 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -914,6 +914,7 @@ class NetworkdNetWorkBridgeTests(unittest.TestCase, Utilities): '26-bridge.netdev', '26-bridge-slave-interface-1.network', '26-bridge-slave-interface-2.network', + 'bridge99-ignore-carrier-loss.network', 'bridge99.network'] def setUp(self): @@ -959,6 +960,42 @@ class NetworkdNetWorkBridgeTests(unittest.TestCase, Utilities): if (os.path.exists('/sys/devices/virtual/net/bridge00/lower_dummy98/brport/multicast_to_unicast')): self.assertEqual(self.read_bridge_port_attr('bridge99', 'dummy98', 'multicast_to_unicast'), '1') + self.assertEqual(subprocess.call(['ip', 'address', 'add', '192.168.0.16/24', 'dev', 'bridge99']), 0) + time.sleep(1) + + self.assertEqual(subprocess.call(['ip', 'link', 'del', 'test1']), 0) + self.assertEqual(subprocess.call(['ip', 'link', 'del', 'dummy98']), 0) + time.sleep(3) + + output = subprocess.check_output(['ip', 'address', 'show', 'bridge99']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, 'NO-CARRIER') + self.assertNotRegex(output, '192.168.0.15/24') + self.assertNotRegex(output, '192.168.0.16/24') + + def test_bridge_ignore_carrier_loss(self): + self.copy_unit_to_networkd_unit_path('11-dummy.netdev', '12-dummy.netdev', '26-bridge.netdev', + '26-bridge-slave-interface-1.network', '26-bridge-slave-interface-2.network', + 'bridge99-ignore-carrier-loss.network') + self.start_networkd() + + self.assertTrue(self.link_exits('dummy98')) + self.assertTrue(self.link_exits('test1')) + self.assertTrue(self.link_exits('bridge99')) + + self.assertEqual(subprocess.call(['ip', 'address', 'add', '192.168.0.16/24', 'dev', 'bridge99']), 0) + time.sleep(1) + + self.assertEqual(subprocess.call(['ip', 'link', 'del', 'test1']), 0) + self.assertEqual(subprocess.call(['ip', 'link', 'del', 'dummy98']), 0) + time.sleep(3) + + output = subprocess.check_output(['ip', 'address', 'show', 'bridge99']).rstrip().decode('utf-8') + print(output) + self.assertRegex(output, 'NO-CARRIER') + self.assertRegex(output, 'inet 192.168.0.15/24 brd 192.168.0.255 scope global bridge99') + self.assertRegex(output, 'inet 192.168.0.16/24 scope global secondary bridge99') + class NetworkdNetWorkLLDPTests(unittest.TestCase, Utilities): links = ['veth99'] |