Commit 7a7425a8 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

fix(backend): prepare base before clone many

parent aaf769b0
......@@ -2777,6 +2777,15 @@ sub _req_clone_many($self, $request) {
my $domains = $self->list_domains_data();
my %domain_exists = map { $_->{name} => 1 } @$domains;
if (!$base->is_base) {
my $uid = $request->defined_arg('uid');
confess Dumper($request) if !$uid;
my $req_prepare = Ravada::Request->prepare_base(
id_domain => $base->id
, uid => $uid
);
$args->{after_request} = $req_prepare->id;
}
my @reqs;
for ( 1 .. $number ) {
my $n = $_;
......
......@@ -772,6 +772,7 @@ sub wait_request {
." ".($req->error or '')) if $debug && (time%5 == 0);
$done_all = 0;
} elsif (!$done{$req->id}) {
$t0 = time;
$done{$req->{id}}++;
is($req->error,'') or confess if $check_error;
}
......
......@@ -76,6 +76,9 @@ sub test_many_clones($base) {
my $n_clones = 30;
$n_clones = 100 if $base->type =~ /Void/i;
$n_clones = 4 if !$ENV{TEST_STRESS} && ! $ENV{TEST_LONG};
$t->post_ok('/machine/copy' => json => {id_base => $base->id, copy_number => $n_clones});
like($t->tx->res->code(),qr/^(200|302)$/) or die $t->tx->res->body->to_string;
......@@ -117,6 +120,19 @@ sub _init_mojo_client {
$t->get_ok('/')->status_is(200)->content_like(qr/choose a machine/i);
}
sub test_copy_without_prepare($clone) {
is ($clone->is_base,0) or die "Clone ".$clone->name." is supposed to be non-base";
my $n_clones = 3;
mojo_request($t, "clone", { id_domain => $clone->id, number => $n_clones });
wait_request(debug => 1, check_error => 1, background => 1, timeout => 120);
my @clones = $clone->clones();
is(scalar @clones, $n_clones) or exit;
remove_machines($clone);
}
########################################################################################
init('/etc/ravada.conf',0);
......@@ -171,10 +187,13 @@ for my $vm_name ( vm_names() ) {
is(scalar($clone->list_ports),0);
}
push @bases, ( $clone );
test_copy_without_prepare($clone);
test_many_clones($base);
}
ok(@bases,"Expecting some machines created");
remove_machines(@bases);
_wait_request(background => 1);
remove_old_domains_req();
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