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

[#507] use common lib for test create domain args

parent b9cfc0db
......@@ -29,7 +29,7 @@ sub test_new_domain {
my $freemem = _check_free_memory();
my $domain;
eval { $domain = $vm->create_domain(name => $name
, id_iso => 1
, id_iso => search_id_iso('Alpine')
,vm => $vm->type
,id_owner => $USER->id
,memory => 1.5*1024*1024
......
......@@ -186,7 +186,7 @@ remove_old_disks();
my $domain_name = new_domain_name();
my $domain = $vm->create_domain( name => $domain_name
, id_iso => 1 , id_owner => $USER->id);
, id_iso => search_id_iso('Alpine') , id_owner => $USER->id);
$domain->prepare_base($USER);
$domain->is_public(1);
......
......@@ -19,11 +19,6 @@ my $USER = create_user('foo','bar');
my $RVD_BACK = rvd_back( );
my $RVD_FRONT = rvd_front();
my %ARG_CREATE_DOM = (
KVM => [ id_iso => 1 ]
,Void => [ ]
);
# twice so it won't warn it is only used once
ok($Ravada::CONNECTOR,"\$Ravada::Connector wasn't set");
ok($Ravada::CONNECTOR,"\$Ravada::Connector wasn't set");
......@@ -54,7 +49,7 @@ sub test_add_domain_db {
my $domain = $vm->create_domain(
name => $domain_name
, id_owner => $USER->id
, @{$ARG_CREATE_DOM{$vm_name}}
, arg_create_dom($vm_name)
);
my $domains = $RVD_FRONT->list_domains();
ok($domains,"No domains list returned");
......
......@@ -24,7 +24,7 @@ my $RVD_FRONT = Ravada::Front->new(
my $USER = create_user('foo','bar');
my %CREATE_ARGS = (
KVM => { id_iso => 1, id_owner => $USER->id }
KVM => { id_iso => search_id_iso('Alpine'), id_owner => $USER->id }
,LXC => { id_template => 1, id_owner => $USER->id }
,Void => { id_owner => $USER->id }
);
......
......@@ -18,14 +18,8 @@ my $FILE_CONFIG = 't/etc/ravada.conf';
my $RVD_BACK = rvd_back($test->connector, $FILE_CONFIG);
my $RVD_FRONT= rvd_front($test->connector, $FILE_CONFIG);
my %ARG_CREATE_DOM = (
KVM => [ id_iso => 1 ]
,Void => [ ]
);
my @ARG_RVD = ( config => $FILE_CONFIG, connector => $test->connector);
my @VMS = keys %ARG_CREATE_DOM;
my @VMS = vm_names();
my $USER = create_user("foo","bar");
#########################################################
......@@ -39,16 +33,10 @@ sub test_create_domain {
my $name = new_domain_name();
if (!$ARG_CREATE_DOM{$vm_name}) {
diag("VM $vm_name should be defined at \%ARG_CREATE_DOM");
return;
}
my @arg_create = @{$ARG_CREATE_DOM{$vm_name}};
my $domain;
eval { $domain = $vm->create_domain(name => $name
, id_owner => $USER->id
, @{$ARG_CREATE_DOM{$vm_name}})
, arg_create_dom($vm_name))
};
ok($domain,"No domain $name created with ".ref($vm)." ".($@ or '')) or exit;
......
......@@ -27,8 +27,8 @@ my $RVD_FRONT = Ravada::Front->new( @rvd_args
my $USER = create_user('foo','bar',1);
my %CREATE_ARGS = (
Void => { id_iso => 1, id_owner => $USER->id }
,KVM => { id_iso => 1, id_owner => $USER->id }
Void => { id_iso => search_id_iso('Alpine'), id_owner => $USER->id }
,KVM => { id_iso => search_id_iso('Alpine'), id_owner => $USER->id }
,LXC => { id_template => 1, id_owner => $USER->id }
);
......
......@@ -76,7 +76,8 @@ sub test_new_domain {
test_remove_domain($name);
diag("Creating domain $name");
my $domain = $RAVADA->create_domain(name => $name, id_iso => 1, active => $active
my $domain = $RAVADA->create_domain(name => $name, id_iso => search_id_iso('Alpine')
, active => $active
, id_owner => $USER->id
, vm => $BACKEND
);
......@@ -114,7 +115,8 @@ sub test_new_domain_iso {
diag("Creating domain $name");
my $domain;
eval {
$domain = $RAVADA->create_domain(name => $name, id_iso => 1, active => $active
$domain = $RAVADA->create_domain(name => $name, id_iso => search_id_iso('alpine')
, active => $active
, id_owner => $USER->id , iso_file => $iso->{device}
, vm => $BACKEND
);
......
......@@ -65,7 +65,7 @@ sub test_new_domain_from_iso {
diag("Creating domain $name from iso");
my $domain;
eval { $domain = $RAVADA->create_domain(name => $name
, id_iso => 1
, id_iso => search_id_iso('alpine')
,vm => $BACKEND
,id_owner => $USER->id
)
......
......@@ -61,7 +61,7 @@ test_remove_domain($name, user_admin());
my $domain = $VMM->create_domain(
name => $name
, id_iso => 1
, id_iso => search_id_iso('alpine')
, active => 0
, id_owner => $USER->id
);
......
......@@ -129,7 +129,7 @@ sub test_req_create_domain_iso {
diag("requesting create domain $name");
my $req = Ravada::Request->create_domain(
name => $name
,id_iso => 1
,id_iso => search_id_iso('alpine')
,id_owner => $USER->id
,vm => $BACKEND
);
......@@ -159,7 +159,7 @@ sub test_force_kvm {
my $name = new_domain_name();
my $req = Ravada::Request->create_domain(
name => $name
,id_iso => 1
,id_iso => search_id_iso('alpine')
,id_owner => $USER->id
,vm => 'kvm'
);
......
......@@ -17,14 +17,9 @@ my $FILE_CONFIG = 't/etc/ravada.conf';
my $RVD_BACK = rvd_back($TEST_SQL->connector, $FILE_CONFIG);
my $RVD_FRONT= rvd_front($TEST_SQL->connector, $FILE_CONFIG);
my %ARG_CREATE_DOM = (
KVM => [ id_iso => 1 ]
# ,Void => [ ]
);
my @ARG_RVD = ( config => $FILE_CONFIG, connector => $TEST_SQL->connector);
my @VMS = reverse keys %ARG_CREATE_DOM;
my @VMS = ('KVM');
my $USER = create_user("foo","bar");
#############################################################################
......@@ -34,16 +29,10 @@ sub test_create_domain {
my $name = new_domain_name();
if (!$ARG_CREATE_DOM{$vm_name}) {
diag("VM $vm_name should be defined at \%ARG_CREATE_DOM");
return;
}
my @arg_create = @{$ARG_CREATE_DOM{$vm_name}};
my $domain;
eval { $domain = $vm->create_domain(name => $name
, id_owner => $USER->id
, @{$ARG_CREATE_DOM{$vm_name}})
, arg_create_dom($vm_name))
};
ok($domain,"Domain $name created with ".ref($vm)." ".($@ or '')) or exit;
......@@ -163,7 +152,7 @@ for my $vm_name (@VMS) {
my $vm = $RVD_BACK->search_vm($vm_name);
SKIP : {
my $msg = "SKIPPED test: No $vm_name VM found ";
if ($vm_name eq 'KVM') {
if ($vm_name eq 'KVM' && $>) {
$msg = "SKIPPED test: $vm_name must be tested from root user";
$vm = undef;
}
......
......@@ -16,9 +16,6 @@ my $test = Test::SQL::Data->new(config => 't/etc/sql.conf');
init($test->connector, $FILE_CONFIG);
my $USER = create_user('foo','bar');
my %ARG_CREATE_DOM = (
KVM => [ id_iso => 1 ]
);
our $TIMEOUT_SHUTDOWN = 10;
our %SKIP_DEFAULT_VALUE = map { $_ => 1 } qw(image jpeg playback streaming zlib);
......@@ -32,16 +29,12 @@ sub test_create_domain {
my $name = new_domain_name();
if (!$ARG_CREATE_DOM{$vm_name}) {
diag("VM $vm_name should be defined at \%ARG_CREATE_DOM");
return;
}
my @arg_create = @{$ARG_CREATE_DOM{$vm_name}};
my $domain;
eval { $domain = $vm->create_domain(name => $name
, id_owner => $USER->id
, @{$ARG_CREATE_DOM{$vm_name}})
, arg_create_dom($vm_name)
);
};
ok($domain,"No domain $name created with ".ref($vm)." ".($@ or '')) or return;
......
......@@ -12,11 +12,7 @@ my $test = Test::SQL::Data->new(config => 't/etc/sql.conf');
use_ok('Ravada');
my %ARG_CREATE_DOM = (
KVM => [ id_iso => 1 ]
);
my @VMS = reverse keys %ARG_CREATE_DOM;
my @VMS = vm_names();
init($test->connector);
my $USER = create_user("foo","bar");
......@@ -31,16 +27,10 @@ sub test_create_domain {
my $name = new_domain_name();
if (!$ARG_CREATE_DOM{$vm_name}) {
diag("VM $vm_name should be defined at \%ARG_CREATE_DOM");
return;
}
my @arg_create = @{$ARG_CREATE_DOM{$vm_name}};
my $domain;
eval { $domain = $vm->create_domain(name => $name
, id_owner => $USER->id
, @{$ARG_CREATE_DOM{$vm_name}})
, arg_create_dom($vm_name))
};
ok($domain,"No domain $name created with ".ref($vm)." ".($@ or '')) or return;
......
......@@ -13,11 +13,7 @@ my $test = Test::SQL::Data->new(config => 't/etc/sql.conf');
use_ok('Ravada');
my $FILE_CONFIG = 't/etc/ravada.conf';
my %ARG_CREATE_DOM = (
KVM => [ id_iso => 1 ]
);
my @VMS = reverse keys %ARG_CREATE_DOM;
my @VMS = vm_names();
init($test->connector);
my $USER = create_user("foo","bar");
my $DISPLAY_IP = '99.1.99.1';
......@@ -34,16 +30,10 @@ sub test_create_domain {
my $name = new_domain_name();
diag("Test create domain $name");
if (!$ARG_CREATE_DOM{$vm_name}) {
diag("VM $vm_name should be defined at \%ARG_CREATE_DOM");
return;
}
my @arg_create = @{$ARG_CREATE_DOM{$vm_name}};
my $domain;
eval { $domain = $vm->create_domain(name => $name
, id_owner => $USER->id
, @{$ARG_CREATE_DOM{$vm_name}})
, arg_create_dom($vm_name))
};
ok($domain,"No domain $name created with ".ref($vm)." ".($@ or '')) or return;
......
......@@ -17,11 +17,7 @@ use_ok('Ravada');
my $RVD_BACK = rvd_back($test->connector);
my $RVD_FRONT= rvd_front($test->connector);
my %ARG_CREATE_DOM = (
kvm => [ id_iso => 1 ]
);
my @VMS = reverse keys %ARG_CREATE_DOM;
my @VMS = vm_names();
my $USER = create_user("foo","bar");
#########################################################################
......@@ -77,16 +73,10 @@ sub test_create_domain {
my $name = new_domain_name();
ok($ARG_CREATE_DOM{lc($vm_name)}) or do {
diag("VM $vm_name should be defined at \%ARG_CREATE_DOM");
return;
};
my @arg_create = @{$ARG_CREATE_DOM{$vm_name}};
my $domain;
eval { $domain = $vm->create_domain(name => $name
, id_owner => $USER->id
, @{$ARG_CREATE_DOM{$vm_name}})
, arg_create_dom($vm_name))
};
ok($domain,"No domain $name created with ".ref($vm)." ".($@ or '')) or exit;
......@@ -147,8 +137,6 @@ sub test_base {
sub test_volumes_in_two_pools {
my $vm_name = shift;
my @arg_create = @{$ARG_CREATE_DOM{$vm_name}};
my $vm = rvd_back->search_vm($vm_name);
ok($vm,"I can't find VM $vm_name") or return;
......@@ -159,7 +147,7 @@ sub test_volumes_in_two_pools {
my $domain;
eval { $domain = $vm->create_domain(name => $name
, id_owner => $USER->id
, @{$ARG_CREATE_DOM{$vm_name}})
, arg_create_dom($vm_name))
};
ok($domain,"No domain $name created with ".ref($vm)." ".($@ or '')) or return;
......@@ -208,7 +196,7 @@ sub test_default_pool {
clean();
my $vm_name = 'kvm';
my $vm_name = 'KVM';
my $vm = rvd_back->search_vm($vm_name);
SKIP: {
......
......@@ -17,10 +17,7 @@ use_ok('Ravada');
my $RVD_BACK = rvd_back($test->connector);
my $RVD_FRONT= rvd_front($test->connector);
my %ARG_CREATE_DOM = (
kvm => [ id_iso => 1 ]
);
my @VMS = reverse keys %ARG_CREATE_DOM;
my @VMS = vm_names();
my $USER = create_user("foo","bar");
sub test_create_domain {
......@@ -31,16 +28,10 @@ sub test_create_domain {
my $name = new_domain_name();
ok($ARG_CREATE_DOM{lc($vm_name)}) or do {
diag("VM $vm_name should be defined at \%ARG_CREATE_DOM");
return;
};
my @arg_create = @{$ARG_CREATE_DOM{$vm_name}};
my $domain;
eval { $domain = $vm->create_domain(name => $name
, id_owner => $USER->id
, @{$ARG_CREATE_DOM{$vm_name}})
, arg_create_dom($vm_name))
};
ok($domain,"No domain $name created with ".ref($vm)." ".($@ or '')) or exit;
......@@ -59,7 +50,7 @@ sub test_create_domain {
clean();
my $vm_name = 'kvm';
my $vm_name = 'KVM';
my $vm = rvd_back->search_vm($vm_name);
SKIP: {
......
......@@ -13,11 +13,8 @@ use Test::Ravada;
my $test = Test::SQL::Data->new(config => 't/etc/sql.conf');
use_ok('Ravada');
my %ARG_CREATE_DOM = (
KVM => [ id_iso => 1 ]
);
my @VMS = reverse keys %ARG_CREATE_DOM;
my @VMS = vm_names();
init($test->connector);
my $USER = create_user("foo","bar");
......@@ -32,7 +29,7 @@ sub test_domain_no_password {
ok(!$net->requires_password);
my $domain_name = new_domain_name();
my $domain = $vm->create_domain( name => $domain_name
, id_iso => 1 , id_owner => $USER->id);
, id_iso => search_id_iso('Alpine') , id_owner => $USER->id);
$domain->start(user => $USER, remote_ip => '127.0.0.1');
......@@ -78,7 +75,7 @@ sub test_domain_password2 {
ok(!$net->requires_password) or return;
my $domain_name = new_domain_name();
my $domain = $vm->create_domain( name => $domain_name
, id_iso => 1 , id_owner => $USER->id);
, id_iso => search_id_iso('Alpine') , id_owner => $USER->id);
$domain->start(user => $USER, remote_ip => '127.0.0.1');
......@@ -126,7 +123,7 @@ sub test_domain_password1 {
ok($net2->requires_password,"Expecting net requires password ")
or return;
my $domain = $vm->create_domain( name => new_domain_name
, id_iso => 1 , id_owner => $USER->id);
, id_iso => search_id_iso('Alpine') , id_owner => $USER->id);
$domain->start(user => $USER, remote_ip => '10.0.0.1');
......@@ -157,7 +154,7 @@ sub test_any_network_password {
add_network_any(1);
my $domain = $vm->create_domain( name => new_domain_name
, id_iso => 1 , id_owner => $USER->id);
, id_iso => search_id_iso('Alpine') , id_owner => $USER->id);
$domain->start(user => $USER, remote_ip => '127.0.0.1');
......@@ -187,7 +184,7 @@ sub test_any_network_password_hybernate{
add_network_any(1);
my $domain = $vm->create_domain( name => new_domain_name
, id_iso => 1 , id_owner => $USER->id);
, id_iso => search_id_iso('Alpine') , id_owner => $USER->id);
$domain->start(user => $USER, remote_ip => '127.0.0.1');
......@@ -209,7 +206,7 @@ sub test_any_network_password_hybernate{
# create another domain to start from far away
$domain = $vm->create_domain( name => new_domain_name
, id_iso => 1 , id_owner => $USER->id);
, id_iso => search_id_iso('Alpine') , id_owner => $USER->id);
eval {
$domain->start($USER) if !$domain->is_active;
......
......@@ -13,11 +13,8 @@ use Test::Ravada;
my $test = Test::SQL::Data->new(config => 't/etc/sql.conf');
use_ok('Ravada');
my %ARG_CREATE_DOM = (
KVM => [ id_iso => 1 ]
);
my @VMS = reverse keys %ARG_CREATE_DOM;
my @VMS = vm_names();
init($test->connector);
my $USER = create_user("foo","bar");
......@@ -28,7 +25,7 @@ sub test_spice {
my $domain_name = new_domain_name();
my $domain = $vm->create_domain( name => $domain_name
, id_iso => 1 , id_owner => $USER->id);
, id_iso => search_id_iso('Alpine') , id_owner => $USER->id);
$domain->start($USER);
......
......@@ -19,7 +19,8 @@ init($test->connector, 't/etc/ravada.conf');
my $USER = create_user("foo","bar");
my $ID_ISO = 1;
rvd_back();
my $ID_ISO = search_id_iso('Alpine');
my @ARG_CREATE_DOM = (
id_iso => $ID_ISO
,id_owner => $USER->id
......@@ -480,7 +481,7 @@ for my $vm_name ( qw(KVM Void)) {
my $rvd_back = rvd_back();
my $vm= $rvd_back->search_vm($vm_name) if rvd_back();
$vm_connected = 1 if $vm;
@ARG_CREATE_DOM = ( id_iso => 1, vm => $vm_name, id_owner => $USER->id );
@ARG_CREATE_DOM = ( id_iso => search_id_iso('Alpine'), vm => $vm_name, id_owner => $USER->id );
if ($vm_name eq 'KVM') {
my $iso = $vm->_search_iso($ID_ISO);
......
......@@ -13,11 +13,8 @@ use Test::Ravada;
my $test = Test::SQL::Data->new(config => 't/etc/sql.conf');
use_ok('Ravada');
my %ARG_CREATE_DOM = (
KVM => [ id_iso => 1 ]
);
my @VMS = reverse keys %ARG_CREATE_DOM;
my @VMS = vm_names();
init($test->connector);
rvd_back();
......
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