1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

selftest: Do not start tests on an environment that has failed to start up

This avoids debugging subsequent test failures, which may not be as clear

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2015-12-07 13:18:38 +13:00
parent af16d52f7d
commit b0aa686eb6

View File

@ -89,7 +89,10 @@ sub check_or_start($$$)
my ($self, $env_vars, $process_model) = @_;
my $STDIN_READER;
return 0 if $self->check_env($env_vars);
my $env_ok = $self->check_env($env_vars);
if ($env_ok) {
return $env_vars->{SAMBA_PID};
}
# use a pipe for stdin in the child processes. This allows
# those processes to monitor the pipe for EOF to ensure they
@ -150,17 +153,28 @@ sub check_or_start($$$)
exec(@preargs, Samba::bindir_path($self, "samba"), "-M", $process_model, "-i", "--maximum-runtime=$self->{server_maxtime}", $env_vars->{CONFIGURATION}, @optargs) or die("Unable to start samba: $!");
}
$env_vars->{SAMBA_PID} = $pid;
print "DONE\n";
print "DONE ($pid)\n";
close($STDIN_READER);
if ($self->wait_for_start($env_vars) != 0) {
warn("Samba $pid failed to start up");
return undef;
}
return $pid;
}
sub wait_for_start($$)
{
my ($self, $testenv_vars) = @_;
my $ret;
my $ret = 0;
if (not $self->check_env($testenv_vars)) {
warn("unable to confirm Samba $testenv_vars->{SAMBA_PID} is running");
return -1;
}
# give time for nbt server to register its names
print "delaying for nbt name registration\n";
sleep 2;
@ -200,7 +214,7 @@ sub wait_for_start($$)
while (system("$ldbsearch -H ldap://$testenv_vars->{SERVER} -U$testenv_vars->{USERNAME}%$testenv_vars->{PASSWORD} -s base -b \"$rid_set_dn\" rIDAllocationPool > /dev/null") != 0) {
$count++;
if ($count > 40) {
$ret = 1;
$ret = -1;
last;
}
sleep(1);
@ -2006,7 +2020,10 @@ sub check_env($$)
my $childpid = Samba::cleanup_child($samba_pid, "samba");
return ($childpid == 0);
if ($childpid == 0) {
return 1;
}
return 0;
}
sub setup_env($$$)
@ -2095,9 +2112,9 @@ sub setup_s4member($$$)
my $env = $self->provision_s4member($path, $dc_vars);
if (defined $env) {
$self->check_or_start($env, "single");
$self->wait_for_start($env);
if (not defined($self->check_or_start($env, "single"))) {
return undef;
}
$self->{vars}->{s4member} = $env;
}
@ -2112,9 +2129,9 @@ sub setup_rpc_proxy($$$)
my $env = $self->provision_rpc_proxy($path, $dc_vars);
if (defined $env) {
$self->check_or_start($env, "single");
$self->wait_for_start($env);
if (not defined($self->check_or_start($env, "single"))) {
return undef;
}
$self->{vars}->{rpc_proxy} = $env;
}
@ -2127,9 +2144,10 @@ sub setup_ad_dc_ntvfs($$)
my $env = $self->provision_ad_dc_ntvfs($path);
if (defined $env) {
$self->check_or_start($env, "standard");
$self->wait_for_start($env);
if (not defined($self->check_or_start($env, "standard"))) {
warn("Failed to start ad_dc_ntvfs");
return undef;
}
$self->{vars}->{ad_dc_ntvfs} = $env;
}
@ -2142,9 +2160,9 @@ sub setup_chgdcpass($$)
my $env = $self->provision_chgdcpass($path);
if (defined $env) {
$self->check_or_start($env, "single");
$self->wait_for_start($env);
if (not defined($self->check_or_start($env, "single"))) {
return undef;
}
$self->{vars}->{chgdcpass} = $env;
}
@ -2157,9 +2175,9 @@ sub setup_fl2000dc($$)
my $env = $self->provision_fl2000dc($path);
if (defined $env) {
$self->check_or_start($env, "single");
$self->wait_for_start($env);
if (not defined($self->check_or_start($env, "single"))) {
return undef;
}
$self->{vars}->{fl2000dc} = $env;
}
@ -2174,9 +2192,9 @@ sub setup_fl2003dc($$$)
my $env = $self->provision_fl2003dc($path);
if (defined $env) {
$self->check_or_start($env, "single");
$self->wait_for_start($env);
if (not defined($self->check_or_start($env, "single"))) {
return undef;
}
$env = $self->setup_trust($env, $dc_vars, "external", "--no-aes-keys");
@ -2192,9 +2210,9 @@ sub setup_fl2008r2dc($$$)
my $env = $self->provision_fl2008r2dc($path);
if (defined $env) {
$self->check_or_start($env, "single");
$self->wait_for_start($env);
if (not defined($self->check_or_start($env, "single"))) {
return undef;
}
my $upn_array = ["$env->{REALM}.upn"];
my $spn_array = ["$env->{REALM}.spn"];
@ -2216,9 +2234,9 @@ sub setup_vampire_dc($$$)
my $env = $self->provision_vampire_dc($path, $dc_vars);
if (defined $env) {
$self->check_or_start($env, "single");
$self->wait_for_start($env);
if (not defined($self->check_or_start($env, "single"))) {
return undef;
}
$self->{vars}->{vampire_dc} = $env;
@ -2279,9 +2297,9 @@ sub setup_promoted_dc($$$)
my $env = $self->provision_promoted_dc($path, $dc_vars);
if (defined $env) {
$self->check_or_start($env, "single");
$self->wait_for_start($env);
if (not defined($self->check_or_start($env, "single"))) {
return undef;
}
$self->{vars}->{promoted_dc} = $env;
@ -2343,9 +2361,9 @@ sub setup_subdom_dc($$$)
my $env = $self->provision_subdom_dc($path, $dc_vars);
if (defined $env) {
$self->check_or_start($env, "single");
$self->wait_for_start($env);
if (not defined($self->check_or_start($env, "single"))) {
return undef;
}
$self->{vars}->{subdom_dc} = $env;
@ -2399,9 +2417,9 @@ sub setup_rodc($$$)
return undef;
}
$self->check_or_start($env, "single");
$self->wait_for_start($env);
if (not defined($self->check_or_start($env, "single"))) {
return undef;
}
# force source and replicated DC to update repsTo/repsFrom
# for vampired partitions
@ -2472,9 +2490,9 @@ sub setup_ad_dc($$)
$env->{NSS_WRAPPER_MODULE_FN_PREFIX} = undef;
}
$self->check_or_start($env, "single");
$self->wait_for_start($env);
if (not defined($self->check_or_start($env, "single"))) {
return undef;
}
my $upn_array = ["$env->{REALM}.upn"];
my $spn_array = ["$env->{REALM}.spn"];