mirror of
https://github.com/systemd/systemd
synced 2024-07-21 10:17:21 +00:00
test: add test to verify RequiredForOnline= setting with ActivationPolicy=
Add test to verify that the RequiredForOnline= value is correct based on the configuration of ActivationPolicy=
This commit is contained in:
parent
003015af5a
commit
61764fe4e2
|
@ -0,0 +1,5 @@
|
|||
[Link]
|
||||
ActivationPolicy=bound
|
||||
|
||||
[Network]
|
||||
BindCarrier=dummy98
|
|
@ -0,0 +1,2 @@
|
|||
[Link]
|
||||
RequiredForOnline=no
|
|
@ -0,0 +1,2 @@
|
|||
[Link]
|
||||
RequiredForOnline=yes
|
|
@ -1793,6 +1793,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
|
|||
units = [
|
||||
'11-dummy.netdev',
|
||||
'12-dummy.netdev',
|
||||
'12-dummy.network',
|
||||
'23-active-slave.network',
|
||||
'24-keep-configuration-static.network',
|
||||
'24-search-domain.network',
|
||||
|
@ -2801,6 +2802,50 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
|
|||
with self.subTest(test=test):
|
||||
self._test_activation_policy(test)
|
||||
|
||||
def _test_activation_policy_required_for_online(self, policy, required):
|
||||
self.setUp()
|
||||
conffile = '25-activation-policy.network'
|
||||
units = ['11-dummy.netdev', '12-dummy.netdev', '12-dummy.network', conffile]
|
||||
if policy:
|
||||
units += [f'{conffile}.d/{policy}.conf']
|
||||
if required:
|
||||
units += [f'{conffile}.d/required-{required}.conf']
|
||||
copy_unit_to_networkd_unit_path(*units, dropins=False)
|
||||
start_networkd()
|
||||
|
||||
if policy.endswith('down') or policy == 'manual':
|
||||
self.wait_operstate('test1', 'off', setup_state='configuring')
|
||||
else:
|
||||
self.wait_online(['test1'])
|
||||
|
||||
if policy == 'always-down':
|
||||
# if always-down, required for online is forced to no
|
||||
expected = False
|
||||
elif required:
|
||||
# otherwise if required for online is specified, it should match that
|
||||
expected = required == 'yes'
|
||||
elif policy:
|
||||
# otherwise if only policy specified, required for online defaults to
|
||||
# true if policy is up, always-up, or bound
|
||||
expected = policy.endswith('up') or policy == 'bound'
|
||||
else:
|
||||
# default is true, if neither are specified
|
||||
expected = True
|
||||
|
||||
output = check_output(*networkctl_cmd, '-n', '0', 'status', 'test1', env=env)
|
||||
print(output)
|
||||
|
||||
yesno = 'yes' if expected else 'no'
|
||||
self.assertRegex(output, f'Required For Online: {yesno}')
|
||||
|
||||
self.tearDown()
|
||||
|
||||
def test_activation_policy_required_for_online(self):
|
||||
for policy in ['up', 'always-up', 'manual', 'always-down', 'down', 'bound', '']:
|
||||
for required in ['yes', 'no', '']:
|
||||
with self.subTest(policy=policy, required=required):
|
||||
self._test_activation_policy_required_for_online(policy, required)
|
||||
|
||||
def test_domain(self):
|
||||
copy_unit_to_networkd_unit_path('12-dummy.netdev', '24-search-domain.network')
|
||||
start_networkd()
|
||||
|
|
Loading…
Reference in a new issue