Unverified Commit b2c39ef5 authored by Francesc Guasch's avatar Francesc Guasch Committed by GitHub
Browse files

Feature #894 clone start (#896)

* test(ldap): fixed ravada posix group test

issue #645

* test(volatile): check started if asked at clone

issue #894

* feature(backend): start on creation if requested

issue #894
parent 0a0d1c6a
......@@ -1423,7 +1423,7 @@ sub create_domain {
}
my $vm_name = delete $args{vm};
my $start = delete $args{start};
my $start = $args{start};
my $id_base = $args{id_base};
my $id_owner = $args{id_owner} or confess "Error: missing id_owner ".Dumper(\%args);
_check_args(\%args,qw(iso_file id_base id_iso id_owner name active swap memory disk id_template start remote_ip request vm));
......
......@@ -311,7 +311,7 @@ sub _around_create_domain {
delete $args{request};
delete $args{iso_file};
delete $args{id_template};
delete @args{'description','remove_cpu','vm'};
delete @args{'description','remove_cpu','vm','start'};
confess "ERROR: Unknown args ".Dumper(\%args) if keys %args;
......
......@@ -5,6 +5,9 @@ use Data::Dumper;
use Test::More;
use YAML qw(LoadFile DumpFile);
no warnings "experimental::signatures";
use feature qw(signatures);
use lib 't/lib';
use Test::Ravada;
......@@ -233,8 +236,7 @@ sub test_user_bind {
}
sub _init_config {
my ($file_config, $with_admin, $with_posix_group) = @_;
sub _init_config($file_config, $with_admin, $with_posix_group) {
if ( ! -e $file_config) {
my $config = {
ldap => {
......@@ -249,7 +251,15 @@ sub _init_config {
}
my $config = LoadFile($file_config);
delete $config->{ldap}->{admin_group} if !$with_admin;
delete $config->{ldap}->{ravada_posix_group} if !$with_posix_group;
if ($with_posix_group) {
if ( !exists $config->{ldap}->{ravada_posix_group}
|| !$config->{ldap}->{ravada_posix_group}) {
$config->{ldap}->{ravada_posix_group} = $RAVADA_POSIX_GROUP;
diag("Adding ravada_posix_group = $RAVADA_POSIX_GROUP in $file_config");
}
} else {
delete $config->{ldap}->{ravada_posix_group};
}
$config->{vm}=['KVM','Void'];
my $fly_config = "/var/tmp/$$.config";
......@@ -325,11 +335,18 @@ SKIP: {
for my $with_posix_group (0,1) {
for my $with_admin (0,1) {
my $fly_config = _init_config($file_config, $with_admin);
my $fly_config = _init_config($file_config, $with_admin, $with_posix_group);
my $ravada = Ravada->new(config => $fly_config
, connector => connector);
$ravada->_install();
Ravada::Auth::LDAP::init();
if ($with_posix_group) {
ok($Ravada::CONFIG->{ldap}->{ravada_posix_group},
"Expecting ravada_posix_group on $fly_config\n"
.Dumper($Ravada::CONFIG->{ldap}))
or exit;
}
my $ldap;
eval { $ldap = Ravada::Auth::LDAP::_init_ldap_admin() };
......
......@@ -14,6 +14,57 @@ use Test::Ravada;
init();
######################################################################3
sub test_volatile_clone_req {
my $vm = shift;
my $remote_ip = '127.0.0.1';
my $domain = create_domain($vm->type);
ok($domain);
is($domain->volatile_clones, 0);
$domain->volatile_clones(1);
is($domain->volatile_clones, 1);
my $clone_name = new_domain_name();
$domain->prepare_base(user_admin);
my $req = Ravada::Request->create_domain(
name => $clone_name
,id_owner => user_admin->id
,id_base => $domain->id
,remote_ip => $remote_ip
,start => 1
);
rvd_back->_process_requests_dont_fork();
my $clone = rvd_back->search_domain($clone_name);
is($clone->is_active, 1);
is($clone->is_volatile, 1);
$domain->volatile_clones(0);
is($domain->volatile_clones, 0);
my $clone_name2 = new_domain_name();
my $req2 = Ravada::Request->create_domain(
name => $clone_name2
,id_owner => user_admin->id
,id_base => $domain->id
,remote_ip => $remote_ip
,start => 1
);
rvd_back->_process_requests_dont_fork();
my $clone2 = rvd_back->search_domain($clone_name2);
is($clone2->is_active, 1);
is($clone2->is_volatile, 0);
$clone2->remove(user_admin);
$clone->remove(user_admin);
$domain->remove(user_admin);
}
sub test_volatile_clone {
my $vm = shift;
......@@ -322,6 +373,9 @@ for my $vm_name ( vm_names() ) {
skip($msg,10) if !$vm;
diag("Testing volatile clones for $vm_name");
test_volatile_clone_req($vm);
test_volatile_clone($vm);
test_old_machine($vm);
test_old_machine_req($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