Skip to content

Commit

Permalink
Fix/prepare scheduled (#2029)
Browse files Browse the repository at this point in the history
fix: fast forward compact when prepare base requested
closes #2026
  • Loading branch information
frankiejol committed Feb 26, 2024
1 parent 78b5a52 commit d7ca486
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/Ravada/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@ sub _validate_compact($self) {
if ( !$id || ( $req_spinoff && $req_spinoff->id > $id) ) {
$id = $req_spinoff->id;
}
$req_compact->at(0) if $req_compact;
$req_spinoff->at(0) if $req_spinoff;

$self->after_request($id) if $id;

Expand Down
5 changes: 4 additions & 1 deletion t/lib/Test/Ravada.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1285,12 +1285,14 @@ sub wait_request {

my $check_error = delete $args{check_error};
$check_error = 1 if !defined $check_error;
my $fast_forward = delete $args{fast_forward};
$fast_forward = 1 if !defined $fast_forward;

die "Error: uknown args ".Dumper(\%args) if keys %args;
my $t0 = time;
my %done;
for ( ;; ) {
fast_forward_requests();
fast_forward_requests() if $fast_forward;
_clean_removed_domains();
my $done_all = 1;
my $prev = join(".",_list_requests);
Expand All @@ -1311,6 +1313,7 @@ sub wait_request {
if ($req->status eq 'requested') {
$run_at = ($req->at_time or 0);
$run_at = $run_at-time if $run_at;
next if $run_at && $run_at > 10;
$run_at = 'now' if !$run_at;
$run_at = " $run_at";
}
Expand Down
35 changes: 35 additions & 0 deletions t/request/40_base.t
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,39 @@ sub test_domain_name_iso($vm) {
$domain->remove(user_admin) if $domain;
}

sub test_schedule_compact($vm, $base_name) {
my $base = rvd_back->search_domain($base_name);
$base->_data('auto_compact' => 1);
rvd_back->setting("/backend/auto_compact",1);
my $name = new_domain_name();
Ravada::Request->clone(
id_domain => $base->id
,name => $name
,start => 1
,uid => user_admin->id
);
wait_request();
my ($clone) = $vm->search_domain($name);
Ravada::Request->shutdown_domain(
id_domain => $clone->id
,timeout => 1
,uid => user_admin->id
);
wait_request( debug => 0, fast_forward => 0);
is($clone->is_active,0);

Ravada::Request->prepare_base(
id_domain => $clone->id
,uid => user_admin->id
);
wait_request( debug => 0, fast_forward => 0);

is($clone->is_base(),1);

rvd_back->setting("/backend/auto_compact",0);
$clone->remove(user_admin);
}

################################################

{
Expand Down Expand Up @@ -678,6 +711,8 @@ for my $vm_name ( vm_names ) {
test_req_create_from_base_novm($vm_name, $base_name);
my $clone_name = test_req_create_from_base($vm_name, $base_name);

test_schedule_compact($vm_connected, $base_name);

test_req_deny($vm_connected, $base_name);

ok($clone_name) or next;
Expand Down

0 comments on commit d7ca486

Please sign in to comment.