selftest: Remove nbt wait time
authorAndreas Schneider <asn@samba.org>
Fri, 17 Jun 2016 08:01:19 +0000 (10:01 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 17 Jun 2016 20:15:09 +0000 (22:15 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Jun 17 22:15:09 CEST 2016 on sn-devel-144

selftest/target/Samba4.pm

index 5556a22ee6b8ace9f94b3c4c7009f33d9b8ff2d2..693e62305c78c26d6ec45d462805e718fe18f96a 100755 (executable)
@@ -172,6 +172,7 @@ sub check_or_start($$$)
 sub wait_for_start($$)
 {
        my ($self, $testenv_vars) = @_;
+       my $count = 0;
        my $ret = 0;
 
        if (not $self->check_env($testenv_vars)) {
@@ -179,25 +180,34 @@ sub wait_for_start($$)
            return -1;
        }
 
-       # give time for nbt server to register its names
-       print "delaying for nbt name registration\n";
-       sleep 2;
-
        # This will return quickly when things are up, but be slow if we
        # need to wait for (eg) SSL init
        my $nmblookup =  Samba::bindir_path($self, "nmblookup4");
-       system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
-       system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
-       system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
-       system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
-       system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
-       system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
-       system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
-       system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
-       system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
-       system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
-       system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
-       system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
+
+       do {
+               $ret = system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
+               if ($ret != 0) {
+                       sleep(1);
+               } else {
+                       system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
+                       system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
+                       system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
+                       system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
+                       system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
+                       system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
+                       system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
+                       system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
+                       system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
+                       system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
+                       system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
+               }
+               $count++;
+       } while ($ret != 0 && $count < 20);
+       if ($count == 10) {
+               warn("nbt not reachable after 20 retries\n");
+               teardown_env($self, $testenv_vars);
+               return 0;
+       }
 
        # Ensure we have the first RID Set before we start tests.  This makes the tests more reliable.
        if ($testenv_vars->{SERVER_ROLE} eq "domain controller" and not ($testenv_vars->{NETBIOSNAME} eq "RODC")) {