Commit d9d1752a authored by Francesc Guasch's avatar Francesc Guasch
Browse files

void Virtual manager for testing purposes

parent 653b2fa2
......@@ -109,6 +109,7 @@ sub _create_vm_kvm {
eval { $vm_kvm = Ravada::VM::KVM->new( connector => ( $self->connector or $CONNECTOR )) };
my $err_kvm = $@;
return (undef, $err_kvm) if !$vm_kvm;
my ($internal_vm , $storage);
eval {
......@@ -616,6 +617,10 @@ sub search_vm {
my $class = 'Ravada::VM::'.uc($type);
if ($type eq 'Void') {
return Ravada::VM::Void->new();
}
my @vms;
eval { @vms = @{$self->vm} };
for my $vm (@vms) {
......
......@@ -20,6 +20,24 @@ with 'Ravada::VM';
##########################################################################
#
sub connect {}
sub create_domain {
}
sub create_volume {
}
sub list_domains {
return [];
}
sub search_domain {
}
sub search_domain_by_id {
}
#########################################################################3
1;
use warnings;
use strict;
use Data::Dumper;
use Test::More;
use Test::SQL::Data;
......@@ -12,42 +13,56 @@ use_ok('Ravada');
##########################################################
sub test_vm_connect {
my $vm = Ravada::VM::KVM->new(backend => $BACKEND );
my $vm_name = shift;
my $class = "Ravada::VM::$vm_name";
my $obj = {};
bless $obj,$class;
my $vm = $obj->new();
ok($vm);
ok($vm->type eq 'qemu');
ok($vm->host eq 'localhost');
ok($vm->vm);
}
sub test_search_vm {
my $vm_name = shift;
return if $vm_name eq 'Void';
my $class = "Ravada::VM::$vm_name";
my $ravada = Ravada->new();
my $vm = $ravada->search_vm($BACKEND);
ok($vm,"I can't find a $BACKEND virtual manager");
ok(ref $vm eq $CLASS,"Virtual Manager is of class ".(ref($vm) or '<NULL>')
." it should be $CLASS");
my $vm = $ravada->search_vm($vm_name);
ok($vm,"I can't find a $vm virtual manager");
ok(ref $vm eq $class,"Virtual Manager is of class ".(ref($vm) or '<NULL>')
." it should be $class");
}
#######################################################
my $BACKEND = 'Void';
my $CLASS= "Ravada::VM::$BACKEND";
for my $VM (qw( Void KVM )) {
use_ok($CLASS);
diag("Testing $VM VM");
my $CLASS= "Ravada::VM::$VM";
my $RAVADA;
eval { $RAVADA = Ravada->new() };
use_ok($CLASS);
my $vm;
my $RAVADA;
eval { $RAVADA = Ravada->new() };
eval { $vm = $RAVADA->search_vm($BACKEND) } if $RAVADA;
my $vm;
SKIP: {
my $msg = "SKIPPED test: No VM backend found";
diag($msg) if !$vm;
skip $msg,10 if !$vm;
eval { $vm = $RAVADA->search_vm($VM) } if $RAVADA;
test_vm_connect();
test_search_vm();
SKIP: {
my $msg = "SKIPPED test: No $VM VM found ";
diag($msg) if !$vm;
skip $msg,10 if !$vm;
};
test_vm_connect($VM);
test_search_vm($VM);
};
}
done_testing();
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