test-network: add more tests for IgnoreCarrierLoss=

Suggested by @amishmm in #9262.
This commit is contained in:
Yu Watanabe 2019-02-20 12:45:40 +09:00
parent 2be6c5d2ec
commit 6609924c32
2 changed files with 46 additions and 0 deletions

View File

@ -6,3 +6,7 @@ Address=192.168.0.15/24
Gateway=192.168.0.1
IPv6AcceptRA=no
IgnoreCarrierLoss=true
[RoutingPolicyRule]
To=8.8.8.8
Table=100

View File

@ -1271,6 +1271,48 @@ class NetworkdNetWorkBridgeTests(unittest.TestCase, Utilities):
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')
subprocess.call(['ip', 'rule', 'del', 'table', '100'])
def test_bridge_ignore_carrier_loss_frequent_loss_and_gain(self):
self.copy_unit_to_networkd_unit_path('26-bridge.netdev', '26-bridge-slave-interface-1.network',
'bridge99-ignore-carrier-loss.network')
self.start_networkd()
self.assertTrue(self.link_exits('bridge99'))
self.assertEqual(subprocess.call(['ip', 'link', 'add', 'dummy98', 'type', 'dummy']), 0)
self.assertEqual(subprocess.call(['ip', 'link', 'set', 'dummy98', 'up']), 0)
self.assertEqual(subprocess.call(['ip', 'link', 'del', 'dummy98']), 0)
self.assertEqual(subprocess.call(['ip', 'link', 'add', 'dummy98', 'type', 'dummy']), 0)
self.assertEqual(subprocess.call(['ip', 'link', 'set', 'dummy98', 'up']), 0)
self.assertEqual(subprocess.call(['ip', 'link', 'del', 'dummy98']), 0)
self.assertEqual(subprocess.call(['ip', 'link', 'add', 'dummy98', 'type', 'dummy']), 0)
self.assertEqual(subprocess.call(['ip', 'link', 'set', 'dummy98', 'up']), 0)
self.assertEqual(subprocess.call(['ip', 'link', 'del', 'dummy98']), 0)
self.assertEqual(subprocess.call(['ip', 'link', 'add', 'dummy98', 'type', 'dummy']), 0)
self.assertEqual(subprocess.call(['ip', 'link', 'set', 'dummy98', 'up']), 0)
time.sleep(3)
output = subprocess.check_output(['ip', 'address', 'show', 'bridge99']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, 'inet 192.168.0.15/24 brd 192.168.0.255 scope global bridge99')
output = subprocess.check_output(['networkctl', 'status', 'bridge99']).rstrip().decode('utf-8')
self.assertRegex(output, 'State: routable \(configured\)')
output = subprocess.check_output(['networkctl', 'status', 'dummy98']).rstrip().decode('utf-8')
self.assertRegex(output, 'State: enslaved \(configured\)')
output = subprocess.check_output(['ip', 'rule', 'list', 'table', '100']).rstrip().decode('utf-8')
print(output)
self.assertEqual(output, '0: from all to 8.8.8.8 lookup 100')
subprocess.call(['ip', 'rule', 'del', 'table', '100'])
class NetworkdNetWorkLLDPTests(unittest.TestCase, Utilities):
links = ['veth99']