mirror of
https://github.com/systemd/systemd
synced 2024-07-21 10:17:21 +00:00
test-network: add testcase for reconfiguring interface
This commit is contained in:
parent
4069545727
commit
fa4d3fed46
7
test/test-network/conf/12-dummy-altname.link
Normal file
7
test/test-network/conf/12-dummy-altname.link
Normal file
|
@ -0,0 +1,7 @@
|
|||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Match]
|
||||
OriginalName=dummy98-2
|
||||
Driver=dummy
|
||||
|
||||
[Link]
|
||||
AlternativeName=dummy98-2-altname
|
5
test/test-network/conf/12-dummy-mac.netdev
Normal file
5
test/test-network/conf/12-dummy-mac.netdev
Normal file
|
@ -0,0 +1,5 @@
|
|||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[NetDev]
|
||||
Name=dummy98
|
||||
Kind=dummy
|
||||
MACAddress=12:34:56:78:9a:01
|
9
test/test-network/conf/12-dummy-match-altname.network
Normal file
9
test/test-network/conf/12-dummy-match-altname.network
Normal file
|
@ -0,0 +1,9 @@
|
|||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Match]
|
||||
Name=dummy98-2-altname
|
||||
Driver=dummy
|
||||
MACAddress=12:34:56:78:9a:02
|
||||
|
||||
[Network]
|
||||
IPv6AcceptRA=no
|
||||
Address=10.0.2.2/16
|
9
test/test-network/conf/12-dummy-match-mac-01.network
Normal file
9
test/test-network/conf/12-dummy-match-mac-01.network
Normal file
|
@ -0,0 +1,9 @@
|
|||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Match]
|
||||
Name=dummy98
|
||||
Driver=dummy
|
||||
MACAddress=12:34:56:78:9a:01
|
||||
|
||||
[Network]
|
||||
IPv6AcceptRA=no
|
||||
Address=10.0.0.1/16
|
9
test/test-network/conf/12-dummy-match-mac-02.network
Normal file
9
test/test-network/conf/12-dummy-match-mac-02.network
Normal file
|
@ -0,0 +1,9 @@
|
|||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Match]
|
||||
Name=dummy98
|
||||
Driver=dummy
|
||||
MACAddress=12:34:56:78:9a:02
|
||||
|
||||
[Network]
|
||||
IPv6AcceptRA=no
|
||||
Address=10.0.0.2/16
|
9
test/test-network/conf/12-dummy-match-renamed.network
Normal file
9
test/test-network/conf/12-dummy-match-renamed.network
Normal file
|
@ -0,0 +1,9 @@
|
|||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Match]
|
||||
Name=dummy98-1
|
||||
Driver=dummy
|
||||
MACAddress=12:34:56:78:9a:02
|
||||
|
||||
[Network]
|
||||
IPv6AcceptRA=no
|
||||
Address=10.0.1.2/16
|
|
@ -1062,6 +1062,54 @@ class NetworkctlTests(unittest.TestCase, Utilities):
|
|||
self.check_link_exists('veth99', expected=False)
|
||||
self.check_link_exists('veth-peer', expected=False)
|
||||
|
||||
class NetworkdMatchTests(unittest.TestCase, Utilities):
|
||||
|
||||
def setUp(self):
|
||||
setup_common()
|
||||
|
||||
def tearDown(self):
|
||||
tear_down_common()
|
||||
|
||||
def test_match(self):
|
||||
copy_network_unit('12-dummy-mac.netdev',
|
||||
'12-dummy-match-mac-01.network',
|
||||
'12-dummy-match-mac-02.network',
|
||||
'12-dummy-match-renamed.network',
|
||||
'12-dummy-match-altname.network',
|
||||
'12-dummy-altname.link')
|
||||
start_networkd()
|
||||
|
||||
self.wait_online(['dummy98:routable'])
|
||||
output = check_output(*networkctl_cmd, '-n', '0', 'status', 'dummy98', env=env)
|
||||
self.assertIn('Network File: /run/systemd/network/12-dummy-match-mac-01.network', output)
|
||||
output = check_output('ip -4 address show dev dummy98')
|
||||
self.assertIn('10.0.0.1/16', output)
|
||||
|
||||
check_output('ip link set dev dummy98 down')
|
||||
check_output('ip link set dev dummy98 address 12:34:56:78:9a:02')
|
||||
|
||||
self.wait_address('dummy98', '10.0.0.2/16', ipv='-4', timeout_sec=10)
|
||||
self.wait_online(['dummy98:routable'])
|
||||
output = check_output(*networkctl_cmd, '-n', '0', 'status', 'dummy98', env=env)
|
||||
self.assertIn('Network File: /run/systemd/network/12-dummy-match-mac-02.network', output)
|
||||
|
||||
check_output('ip link set dev dummy98 down')
|
||||
check_output('ip link set dev dummy98 name dummy98-1')
|
||||
|
||||
self.wait_address('dummy98-1', '10.0.1.2/16', ipv='-4', timeout_sec=10)
|
||||
self.wait_online(['dummy98-1:routable'])
|
||||
output = check_output(*networkctl_cmd, '-n', '0', 'status', 'dummy98-1', env=env)
|
||||
self.assertIn('Network File: /run/systemd/network/12-dummy-match-renamed.network', output)
|
||||
|
||||
check_output('ip link set dev dummy98-1 down')
|
||||
check_output('ip link set dev dummy98-1 name dummy98-2')
|
||||
check_output(*udevadm_cmd, 'trigger', '--action=add', '/sys/class/net/dummy98-2')
|
||||
|
||||
self.wait_address('dummy98-2', '10.0.2.2/16', ipv='-4', timeout_sec=10)
|
||||
self.wait_online(['dummy98-2:routable'])
|
||||
output = check_output(*networkctl_cmd, '-n', '0', 'status', 'dummy98-2', env=env)
|
||||
self.assertIn('Network File: /run/systemd/network/12-dummy-match-altname.network', output)
|
||||
|
||||
class NetworkdNetDevTests(unittest.TestCase, Utilities):
|
||||
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in a new issue