selftest: Restore IPs 12-16 for selftest client
authorTim Beale <timbeale@catalyst.net.nz>
Mon, 18 Mar 2019 04:55:39 +0000 (17:55 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 27 Mar 2019 13:31:27 +0000 (13:31 +0000)
The assumption that tests only used the .11 IP was wrong. The
winsreplication test tries to use multiple different IPs - CI doesn't
fail when we remove the additional IPs, but it starts to skip test
cases.

+ Update get_interfaces_config() and get_ipv4_addr() so we can add
multiple different IPs for the same host.
+ Update selftest.pl so the client gets 6 IP addresses.
+ Update comments to better reflect this dependency.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/selftest.pl
selftest/target/Samba.pm

index 52109e99b6fd82d1519fb45fb035fae44d0a2601..228bb29ecfe9891ce24effed0a9a4180bb1bca78 100755 (executable)
@@ -514,7 +514,10 @@ foreach (@opt_include) {
        push (@includes, read_test_regexes($_));
 }
 
-my $interfaces = Samba::get_interfaces_config("client");
+# We give the selftest client 6 different IPv4 addresses to use. Most tests
+# only use the first (.11) IP. Note that winsreplication.c is one test that
+# uses the other IPs (search for iface_list_count()).
+my $interfaces = Samba::get_interfaces_config("client", 6);
 
 my $clientdir = "$prefix_abs/client";
 
index f7332da893ee559111a27861ce577495cbd4bc3f..6f28a017b1706f47a244329716d49d29b5d05361 100644 (file)
@@ -437,12 +437,11 @@ sub get_interface($)
                localnt4dc9       => 9,
                # 10 is spare
 
-               # 11 is used by selftest.pl for the client interface
+               # 11-16 are used by selftest.pl for the client.conf. Most tests only
+               # use the first .11 IP. However, some tests (like winsreplication) rely
+               # on the client having multiple IPs.
                client            => 11,
 
-               # 12-16 have been historically reserved for the client, although
-               # aren't actually used
-
                addc_no_nss       => 17,
                addc_no_ntlm      => 18,
                idmapadmember     => 19,
@@ -491,9 +490,15 @@ sub get_interface($)
 
 sub get_ipv4_addr
 {
-       (my $hostname) = @_;
+       my ($hostname, $iface_num) = @_;
        my $swiface = Samba::get_interface($hostname);
 
+       # Handle testenvs with multiple different addresses, i.e. IP multihoming.
+       # Currently only the selftest client has multiple IPv4 addresses.
+       if (defined($iface_num)) {
+               $swiface += $iface_num;
+       }
+
        return "127.0.0.$swiface";
 }
 
@@ -509,11 +514,23 @@ sub get_ipv6_addr
 # addresses for testenv
 sub get_interfaces_config
 {
-       (my $hostname) = @_;
-       my $ipv4_addr = Samba::get_ipv4_addr($hostname);
+       my ($hostname, $num_ips) = @_;
+       my $interfaces = "";
+
+       # We give the client.conf multiple different IPv4 addresses.
+       # All other testenvs generally just have one IPv4 address.
+       if (! defined($num_ips)) {
+               $num_ips = 1;
+       }
+       for (my $i = 0; $i < $num_ips; $i++) {
+               my $ipv4_addr = Samba::get_ipv4_addr($hostname, $i);
+               $interfaces .= "$ipv4_addr/8 ";
+       }
+
        my $ipv6_addr = Samba::get_ipv6_addr($hostname);
+       $interfaces .= "$ipv6_addr/64";
 
-       return "$ipv4_addr/8 $ipv6_addr/64";
+       return $interfaces;
 }
 
 sub cleanup_child($$)