Commit 0cea8bfa authored by frankiejol's avatar frankiejol
Browse files

test(nodes): test shared nodes

parent 95cbd234
......@@ -14,6 +14,45 @@ use feature qw(signatures);
##################################################################################
sub test_remove_n($vm, @nodes ) {
my $domain = create_domain($vm);
$domain->prepare_base(user_admin);
my $n=1;
for my $node ( @nodes ) {
$domain->set_base_vm(vm => $node, user => user_admin);
is($domain->list_instances, ++$n);
}
for my $node1 ( @nodes ) {
my $clone = $domain->clone(user => user_admin, name => new_domain_name);
$clone->migrate($node1);
$clone->start(user_admin);
for my $node2 ( @nodes ) {
diag("Migrating ".$clone->name." from ".$node1->name." to ".$node2->name);
my $req = Ravada::Request->migrate(
uid => user_admin->id
,id_domain => $clone->id
,id_node => $node2->id
,shutdown => 1
,start => 1
);
wait_request( debug => 0);
is($req->status,'done');
is($req->error,'');
my $clone2 = Ravada::Domain->open($clone->id);
is($clone2->_vm->id, $node2->id);
is($clone2->is_active,1,"Expecting ".$clone2->name." [ ".$clone2->id." ] active")
or exit;
delete_request('enforce_limits','set_time', 'refresh_machine');
}
$clone->remove(user_admin);
}
$domain->remove(user_admin);
}
sub test_remove($vm, $node1, $node2) {
my $domain = create_domain($vm);
......@@ -114,6 +153,10 @@ for my $vm_name ( 'Void', 'KVM') {
goto NEXT;
}
my $node_shared = remote_node_shared($vm_name) or next;
test_remove_n($vm, $node1, $node2, $node_shared);
test_remove($vm, $node1, $node2);
NEXT:
......@@ -121,6 +164,7 @@ for my $vm_name ( 'Void', 'KVM') {
clean_remote_node($node2) if $node2;
remove_node($node1) if $node1;
remove_node($node2) if $node2;
remove_node($node_shared) if $node_shared;
}
}
......
......@@ -105,6 +105,7 @@ sub _add_disk($domain) {
);
wait_request(debug => 0);
is($req->error,'');
is($req->status, 'done');
}
sub _change_ram($domain) {
......@@ -184,6 +185,7 @@ sub test_add_disk($vm, $node, $start=0, $prepare_base=0, $migrate=0) {
$domain = $base->clone(name => new_domain_name, user => user_admin);
}
my $n = scalar($domain->list_volumes);
my @volumes0 = map { $_->{file} } $domain->list_volumes_info;
req_migrate($node, $domain, $start) if $migrate;
_add_disk($domain);
......@@ -195,7 +197,8 @@ sub test_add_disk($vm, $node, $start=0, $prepare_base=0, $migrate=0) {
my $domain_local = $vm->search_domain($domain->name);
is($domain_local->_vm->id,$vm->id);
is(scalar($domain_local->list_volumes),$n+1);
my @volumes1 = map { $_->{file} } $domain->list_volumes_info;
is(scalar($domain_local->list_volumes),$n+1,Dumper(\@volumes0,\@volumes1)) or exit;
req_start($domain);
req_migrate($node, $domain, 1);
......
......@@ -332,8 +332,9 @@ sub test_display_iptables($vm) {
for my $display ( @displays ) {
for my $port ( $display->{port}, $display->{extra}->{tls_port} ) {
next if !defined $port;
ok(!$dupe_port{$port}," port $port duplicated $display->{driver} and "
.($dupe_port{$port} or ''));
ok(!$dupe_port{$port},$domain->name
." port $port duplicated $display->{driver} and "
.($dupe_port{$port} or '')) or exit;
$dupe_port{$port} = $display->{driver};
my $display_ip = $display->{ip};
ok(grep /--dport $port/,@iptables_all, "Expecting --dport $port ".Dumper(\@iptables_all)) or die $domain->name;
......
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