X Tutup
Skip to content

Commit 4492443

Browse files
committed
test-network: update tests for ipv4acd
1 parent d7ab6ef commit 4492443

File tree

5 files changed

+35
-24
lines changed

5 files changed

+35
-24
lines changed

test/test-network/conf/25-address-dad-veth99.network

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/test-network/conf/25-address-dad-veth-peer.network renamed to test/test-network/conf/25-address-ipv4acd-veth99.network

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[Match]
2-
Name=veth-peer
2+
Name=veth99
33

44
[Network]
55
IPv6AcceptRA=no
66

77
[Address]
8-
Address=192.168.100.10/24
8+
Address=192.168.100.11/24
99
DuplicateAddressDetection=ipv4
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Address]
2+
Address=192.168.100.10/24
3+
DuplicateAddressDetection=ipv4

test/test-network/conf/dhcp-server-decline.network

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ Name=veth-peer
33

44
[Network]
55
Address=192.168.5.1/24
6-
Address=192.168.5.10/24
76
IPv6AcceptRA=false
87
DHCPServer=yes
98

109
[DHCPServer]
1110
PoolOffset=10
12-
PoolSize=1
11+
PoolSize=100
1312
DNS=192.168.5.1
1413
NTP=192.168.5.1

test/test-network/systemd-networkd-tests.py

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,8 +1797,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
17971797
'23-active-slave.network',
17981798
'24-keep-configuration-static.network',
17991799
'24-search-domain.network',
1800-
'25-address-dad-veth-peer.network',
1801-
'25-address-dad-veth99.network',
1800+
'25-address-ipv4acd-veth99.network',
18021801
'25-address-link-section.network',
18031802
'25-address-peer-ipv4.network',
18041803
'25-address-static.network',
@@ -1868,6 +1867,7 @@ def setUp(self):
18681867
remove_routes(self.routes)
18691868
remove_links(self.links)
18701869
stop_networkd(show_logs=False)
1870+
call('ip netns del ns99', stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
18711871

18721872
def tearDown(self):
18731873
remove_blackhole_nexthops()
@@ -1876,6 +1876,7 @@ def tearDown(self):
18761876
remove_links(self.links)
18771877
remove_unit_from_networkd_path(self.units)
18781878
stop_networkd(show_logs=True)
1879+
call('ip netns del ns99', stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
18791880

18801881
def test_address_static(self):
18811882
copy_unit_to_networkd_unit_path('25-address-static.network', '12-dummy.netdev')
@@ -1929,19 +1930,33 @@ def test_address_static(self):
19291930
for i in range(1,254):
19301931
self.assertIn(f'inet 10.3.3.{i}/16 brd 10.3.255.255', output)
19311932

1932-
def test_address_dad(self):
1933-
copy_unit_to_networkd_unit_path('25-address-dad-veth99.network', '25-address-dad-veth-peer.network',
1934-
'25-veth.netdev')
1933+
def test_address_ipv4acd(self):
1934+
check_output('ip netns add ns99')
1935+
check_output('ip link add veth99 type veth peer veth-peer')
1936+
check_output('ip link set veth-peer netns ns99')
1937+
check_output('ip link set veth99 up')
1938+
check_output('ip netns exec ns99 ip link set veth-peer up')
1939+
check_output('ip netns exec ns99 ip address add 192.168.100.10/24 dev veth-peer')
1940+
1941+
copy_unit_to_networkd_unit_path('25-address-ipv4acd-veth99.network', dropins=False)
19351942
start_networkd()
1936-
self.wait_online(['veth99:routable', 'veth-peer:degraded'])
1943+
self.wait_online(['veth99:routable'])
19371944

19381945
output = check_output('ip -4 address show dev veth99')
19391946
print(output)
1940-
self.assertRegex(output, '192.168.100.10/24')
1947+
self.assertNotIn('192.168.100.10/24', output)
1948+
self.assertIn('192.168.100.11/24', output)
19411949

1942-
output = check_output('ip -4 address show dev veth-peer')
1950+
copy_unit_to_networkd_unit_path('25-address-ipv4acd-veth99.network.d/conflict-address.conf')
1951+
run(*networkctl_cmd, 'reload', env=env)
1952+
time.sleep(1)
1953+
rc = call(*wait_online_cmd, '--timeout=10s', '--interface=veth99:routable', env=env)
1954+
self.assertTrue(rc == 1)
1955+
1956+
output = check_output('ip -4 address show dev veth99')
19431957
print(output)
1944-
self.assertNotRegex(output, '192.168.100.10/24')
1958+
self.assertNotIn('192.168.100.10/24', output)
1959+
self.assertIn('192.168.100.11/24', output)
19451960

19461961
def test_address_peer_ipv4(self):
19471962
# test for issue #17304
@@ -4619,9 +4634,11 @@ def test_dhcp_client_decline(self):
46194634
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-decline.network', 'dhcp-client-decline.network')
46204635

46214636
start_networkd()
4622-
self.wait_online(['veth-peer:carrier'])
4623-
rc = call(*wait_online_cmd, '--timeout=10s', '--interface=veth99:routable', env=env)
4624-
self.assertTrue(rc == 1)
4637+
self.wait_online(['veth99:routable', 'veth-peer:routable'])
4638+
4639+
output = check_output('ip -4 address show dev veth99 scope global dynamic')
4640+
print(output)
4641+
self.assertRegex(output, 'inet 192.168.5.[0-9]*/24 metric 1024 brd 192.168.5.255 scope global dynamic veth99')
46254642

46264643
class NetworkdIPv6PrefixTests(unittest.TestCase, Utilities):
46274644
links = ['veth99']

0 commit comments

Comments
 (0)
X Tutup