Commit 4fb2083a authored by Francesc Guasch's avatar Francesc Guasch
Browse files

skip test if no VM Backend found

parent 43eb08b4
......@@ -477,6 +477,8 @@ sub search_vm {
my $self = shift;
my $type = shift;
confess "Missing VM type" if !$type;
my $class = 'Ravada::VM::'.uc($type);
for my $vm (@{$self->vm}) {
return $vm if ref($vm) eq $class;
......
......@@ -157,12 +157,16 @@ sub remove_old_disks {
################################################
eval { $ravada = Ravada->new(connector => $test->connector) };
ok($ravada,"I can't launch a new Ravada") or exit;
ok($ravada,"I can't launch a new Ravada");# or exit;
my $vm_kvm = $ravada->search_vm('kvm');
my $vm_lxc = $ravada->search_vm('lxc');
my ($vm_kvm, $vm_lxc);
eval { $vm_kvm = $ravada->search_vm('kvm') if $ravada };
eval { $vm_lxc = $ravada->search_vm('lxc') if $ravada };
ok($vm_kvm || $vm_lxc,"No KVM nor LXC virtual managers found") or exit;
SKIP: {
my $msg = "SKIPPED: No KVM nor LXC virtual managers found";
diag($msg) if !$vm_kvm && !$vm_lxc;
skip($msg,10) if !$vm_kvm && !$vm_lxc;
test_remove_domain($DOMAIN_NAME."_iso");
remove_old_disks();
......@@ -185,4 +189,6 @@ remove_old_disks();
test_remove_domain($DOMAIN_NAME."_iso");
};
done_testing();
......@@ -9,7 +9,9 @@ use_ok('Ravada::Request');
my $test = Test::SQL::Data->new(config => 't/etc/ravada.conf');
my $ravada = Ravada->new(connector => $test->connector);
my $ravada;
eval { $ravada = Ravada->new(connector => $test->connector) };
my ($DOMAIN_NAME) = $0 =~ m{.*/(.*)\.};
......@@ -113,7 +115,17 @@ sub test_start {
###############################################################
#
test_start();
my $vmm;
eval { $vmm = $ravada->search_vm() if $ravada };
SKIP: {
my $msg = "SKIPPED: No virtual managers found";
diag($msg) if !$vmm;
skip($msg,10) if !$vmm;
test_start();
};
done_testing();
......@@ -32,8 +32,13 @@ sub test_search_vm {
#######################################################
my $RAVADA = Ravada->new();
my $vm = $RAVADA->search_vm('kvm');
my $RAVADA;
eval { $RAVADA = Ravada->new() };
my $vm;
eval { $vm = $RAVADA->search_vm('kvm') } if $RAVADA;
SKIP: {
my $msg = "SKIPPED test: No VM backend found";
diag($msg) if !$vm;
......
......@@ -10,7 +10,8 @@ use_ok('Ravada');
use_ok('Ravada::Domain::KVM');
my $test = Test::SQL::Data->new( config => 't/etc/ravada.conf');
my $RAVADA = Ravada->new( connector => $test->connector);
my $RAVADA;
eval { $RAVADA = Ravada->new( connector => $test->connector) };
my $CONT= 0;
......@@ -250,9 +251,11 @@ sub remove_old_disks {
################################################################
my $vm = $RAVADA->search_vm('kvm');
my $vm;
eval { $vm = $RAVADA->search_vm('kvm') } if $RAVADA;
SKIP: {
my $msg = "SKIPPED test: No VM backend found";
my $msg = "SKIPPED test: No KVM backend found";
diag($msg) if !$vm;
skip $msg,10 if !$vm;
......
......@@ -12,7 +12,9 @@ use_ok('Ravada');
use_ok('Ravada::Domain::KVM');
my $test = Test::SQL::Data->new( config => 't/etc/ravada.conf');
my $RAVADA = Ravada->new( connector => $test->connector);
my $RAVADA;
eval { $RAVADA = Ravada->new( connector => $test->connector) };
my ($DOMAIN_NAME) = $0 =~ m{.*/(.*)\.};
my $DOMAIN_NAME_SON=$DOMAIN_NAME."_son";
......@@ -213,9 +215,12 @@ sub test_dont_allow_remove_base_before_sons {
}
################################################################
my $vm = $RAVADA->search_vm('kvm');
my $vm;
eval { $vm = $RAVADA->search_vm('kvm') } if $RAVADA;
SKIP: {
my $msg = "SKIPPED test: No VM backend found";
my $msg = "SKIPPED test: No KVM backend found";
diag($msg) if !$vm;
skip $msg,10 if !$vm;
......
......@@ -10,7 +10,9 @@ use_ok('Ravada');
use_ok('Ravada::Domain::KVM');
my $test = Test::SQL::Data->new( config => 't/etc/ravada.conf');
my $RAVADA = Ravada->new( connector => $test->connector);
my $RAVADA;
eval { $RAVADA = Ravada->new( connector => $test->connector) };
my $REMOTE_VIEWER = `which remote-viewer`;
chomp $REMOTE_VIEWER;
......@@ -54,9 +56,10 @@ sub remove_old_disks {
##############################################################
my $vm = $RAVADA->search_vm('kvm');
my $vm;
eval { $vm = $RAVADA->search_vm('kvm') } if $RAVADA;
SKIP: {
my $msg = "SKIPPED test: No VM backend found";
my $msg = "SKIPPED test: No KVM backend found";
diag($msg) if !$vm;
skip $msg,10 if !$vm;
......
Supports Markdown
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