]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: update tests for ipv4acd 19980/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Jun 2021 06:32:57 +0000 (15:32 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 30 Jun 2021 15:49:03 +0000 (00:49 +0900)
test/test-network/conf/25-address-dad-veth99.network [deleted file]
test/test-network/conf/25-address-ipv4acd-veth99.network [moved from test/test-network/conf/25-address-dad-veth-peer.network with 65% similarity]
test/test-network/conf/25-address-ipv4acd-veth99.network.d/conflict-address.conf [new file with mode: 0644]
test/test-network/conf/dhcp-server-decline.network
test/test-network/systemd-networkd-tests.py

diff --git a/test/test-network/conf/25-address-dad-veth99.network b/test/test-network/conf/25-address-dad-veth99.network
deleted file mode 100644 (file)
index 8e323d8..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-[Match]
-Name=veth99
-
-[Network]
-IPv6AcceptRA=no
-
-[Address]
-Address=192.168.100.10/24
similarity index 65%
rename from test/test-network/conf/25-address-dad-veth-peer.network
rename to test/test-network/conf/25-address-ipv4acd-veth99.network
index 2827a751af8b0bd2eedeb01cd3cf3a4242341a73..c8af4bafc836e17ab29b5c53af4c826778db2945 100644 (file)
@@ -1,9 +1,9 @@
 [Match]
-Name=veth-peer
+Name=veth99
 
 [Network]
 IPv6AcceptRA=no
 
 [Address]
-Address=192.168.100.10/24
+Address=192.168.100.11/24
 DuplicateAddressDetection=ipv4
diff --git a/test/test-network/conf/25-address-ipv4acd-veth99.network.d/conflict-address.conf b/test/test-network/conf/25-address-ipv4acd-veth99.network.d/conflict-address.conf
new file mode 100644 (file)
index 0000000..cec39e4
--- /dev/null
@@ -0,0 +1,3 @@
+[Address]
+Address=192.168.100.10/24
+DuplicateAddressDetection=ipv4
index 9009eaeb577e4b9d13d2d46a50194f881fac9599..2c80e88736d024020756690ffb5e839b08ed5ad8 100644 (file)
@@ -3,12 +3,11 @@ Name=veth-peer
 
 [Network]
 Address=192.168.5.1/24
-Address=192.168.5.10/24
 IPv6AcceptRA=false
 DHCPServer=yes
 
 [DHCPServer]
 PoolOffset=10
-PoolSize=1
+PoolSize=100
 DNS=192.168.5.1
 NTP=192.168.5.1
index 4cc0c64f90ceac82ca0a7ffd5fbf2c99e49e6126..4279b612d0f52f5c78033b8a193d8245ae351572 100755 (executable)
@@ -1797,8 +1797,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         '23-active-slave.network',
         '24-keep-configuration-static.network',
         '24-search-domain.network',
-        '25-address-dad-veth-peer.network',
-        '25-address-dad-veth99.network',
+        '25-address-ipv4acd-veth99.network',
         '25-address-link-section.network',
         '25-address-peer-ipv4.network',
         '25-address-static.network',
@@ -1868,6 +1867,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         remove_routes(self.routes)
         remove_links(self.links)
         stop_networkd(show_logs=False)
+        call('ip netns del ns99', stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
 
     def tearDown(self):
         remove_blackhole_nexthops()
@@ -1876,6 +1876,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         remove_links(self.links)
         remove_unit_from_networkd_path(self.units)
         stop_networkd(show_logs=True)
+        call('ip netns del ns99', stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
 
     def test_address_static(self):
         copy_unit_to_networkd_unit_path('25-address-static.network', '12-dummy.netdev')
@@ -1929,19 +1930,33 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         for i in range(1,254):
             self.assertIn(f'inet 10.3.3.{i}/16 brd 10.3.255.255', output)
 
-    def test_address_dad(self):
-        copy_unit_to_networkd_unit_path('25-address-dad-veth99.network', '25-address-dad-veth-peer.network',
-                                        '25-veth.netdev')
+    def test_address_ipv4acd(self):
+        check_output('ip netns add ns99')
+        check_output('ip link add veth99 type veth peer veth-peer')
+        check_output('ip link set veth-peer netns ns99')
+        check_output('ip link set veth99 up')
+        check_output('ip netns exec ns99 ip link set veth-peer up')
+        check_output('ip netns exec ns99 ip address add 192.168.100.10/24 dev veth-peer')
+
+        copy_unit_to_networkd_unit_path('25-address-ipv4acd-veth99.network', dropins=False)
         start_networkd()
-        self.wait_online(['veth99:routable', 'veth-peer:degraded'])
+        self.wait_online(['veth99:routable'])
 
         output = check_output('ip -4 address show dev veth99')
         print(output)
-        self.assertRegex(output, '192.168.100.10/24')
+        self.assertNotIn('192.168.100.10/24', output)
+        self.assertIn('192.168.100.11/24', output)
 
-        output = check_output('ip -4 address show dev veth-peer')
+        copy_unit_to_networkd_unit_path('25-address-ipv4acd-veth99.network.d/conflict-address.conf')
+        run(*networkctl_cmd, 'reload', env=env)
+        time.sleep(1)
+        rc = call(*wait_online_cmd, '--timeout=10s', '--interface=veth99:routable', env=env)
+        self.assertTrue(rc == 1)
+
+        output = check_output('ip -4 address show dev veth99')
         print(output)
-        self.assertNotRegex(output, '192.168.100.10/24')
+        self.assertNotIn('192.168.100.10/24', output)
+        self.assertIn('192.168.100.11/24', output)
 
     def test_address_peer_ipv4(self):
         # test for issue #17304
@@ -4619,9 +4634,11 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
         copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-decline.network', 'dhcp-client-decline.network')
 
         start_networkd()
-        self.wait_online(['veth-peer:carrier'])
-        rc = call(*wait_online_cmd, '--timeout=10s', '--interface=veth99:routable', env=env)
-        self.assertTrue(rc == 1)
+        self.wait_online(['veth99:routable', 'veth-peer:routable'])
+
+        output = check_output('ip -4 address show dev veth99 scope global dynamic')
+        print(output)
+        self.assertRegex(output, 'inet 192.168.5.[0-9]*/24 metric 1024 brd 192.168.5.255 scope global dynamic veth99')
 
 class NetworkdIPv6PrefixTests(unittest.TestCase, Utilities):
     links = ['veth99']