Commit 9c138cd4 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

refactor(test): cope with failures testing

parent 43f864c7
......@@ -42,7 +42,8 @@ sub test_remove_domain {
my $vm = shift;
my $name = shift;
my $domain = $name if ref($name);
my $domain;
$domain = $name if ref($name);
$domain = $vm->search_domain($name,1);
if ($domain) {
......
......@@ -168,7 +168,6 @@ SKIP: {
};
}
remove_old_domains();
remove_old_disks();
end();
done_testing();
......@@ -860,7 +860,8 @@ sub _remove_old_disks_void_remote($node) {
return if !$node->ping(undef,0);
my $cmd = "rm -rfv ".$node->dir_img."/".base_domain_name().'_*';
$node->run_command($cmd);
eval { $node->run_command($cmd); };
die $@ if $@ && $@ !~ /Error connecting/i;
}
sub _remove_old_disks_void_local {
......@@ -1369,16 +1370,22 @@ sub remove_old_user_ldap {
sub _remove_old_groups_ldap() {
my $ldap;
eval { $ldap = Ravada::Auth::LDAP::_init_ldap_admin() if !$ldap };
eval { $ldap = Ravada::Auth::LDAP::_init_ldap_admin() };
return if $@ && $@ =~ /Missing ldap section/;
warn $@ if $@;
return if !$ldap;
my $name = base_domain_name();
for my $group ( Ravada::Auth::LDAP::search_group( name => "group_$name".'*')
,Ravada::Auth::LDAP::search_group( name => $name.'*')
) {
my @groups;
eval {
push @groups,(Ravada::Auth::LDAP::search_group( name => "group_$name".'*', ldap => $ldap));
push @groups,( Ravada::Auth::LDAP::search_group( name => $name.'*', ldap => $ldap) );
};
return if $@ && $@ =~ /Error.*can't connect/i;
die $@ if $@;
for my $group ( @groups ) {
next if !$group;
warn $group->dn;
for my $n ( 1 .. 3 ) {
my $mesg = $ldap->delete($group);
last if !$mesg->code;
......
......@@ -191,7 +191,7 @@ sub test_login_fail {
like($t->tx->res->dom->at("button#submit")->text,qr'Login') or exit;
$t->get_ok("/admin/users")->status_is(401);
is($t->tx->res->dom->at("button#submit")->text,'Login') or exit;
like($t->tx->res->dom->at("button#submit")->text,qr'Login') or exit;
}
sub test_copy_without_prepare($clone) {
......
......@@ -250,15 +250,21 @@ sub test_limit_change($vm, $limit) {
is(scalar @list,1) or warn Dumper([map { $_->name } @list]);
user_admin->grant($user, 'start_limit', 2);
is($user->can_start_limit,2) or exit;
$clone1->start(user_admin);
$clone2->start(user_admin);
$clone3->start(user_admin);
delete_request('set_time');
@list = rvd_back->list_domains(user => $user, active => 1);
is(scalar @list,3) or warn Dumper([map { $_->name } @list]);
wait_request( debug => 1);
@list = rvd_back->list_domains(user => $user, active => 1);
$req = Ravada::Request->enforce_limits(timeout => 1, _force => 1);
wait_request( debug => 0);
delete_request('set_time');
wait_request( debug => 1);
is($req->status,'done');
is($req->error,'');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment