selftest: Improve check to detect if nmbd is working.
authorAndreas Schneider <asn@samba.org>
Fri, 25 Jul 2014 14:45:29 +0000 (16:45 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 4 Aug 2014 15:58:58 +0000 (17:58 +0200)
With this change you mostly have to wait only for one second till the
tests get executed instead of ten seconds.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Mon Aug  4 17:58:58 CEST 2014 on sn-devel-104

selftest/target/Samba3.pm

index 0f88d93a45d57b8fb5773fa82e7ee9ba5db93da5..394d6372c0cd3ec57f217fcdce95f164483b40dd 100755 (executable)
@@ -1286,16 +1286,31 @@ sub wait_for_start($$$$$)
        my $ret;
 
        if ($nmbd eq "yes") {
-           # give time for nbt server to register its names
-           print "delaying for nbt name registration\n";
-           sleep(10);
-           # 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, "nmblookup");
-           system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
-           system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
-           system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
-           system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
-           system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
+               my $count = 0;
+
+               # give time for nbt server to register its names
+               print "checking for nmbd\n";
+
+               # 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, "nmblookup");
+
+               do {
+                       $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
+                       if ($ret != 0) {
+                               sleep(1);
+                       } else {
+                               system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
+                               system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
+                               system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
+                               system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
+                       }
+                       $count++;
+               } while ($ret != 0 && $count < 10);
+               if ($count == 10) {
+                       print "NMBD not reachable after 10 retries\n";
+                       teardown_env($self, $envvars);
+                       return 0;
+               }
        }
 
        if ($winbindd eq "yes") {