Skip to content

Commit

Permalink
wip: check the hd is from the proper node
Browse files Browse the repository at this point in the history
issue #2035
  • Loading branch information
frankiejol committed May 6, 2024
1 parent 573b210 commit 291acf5
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion t/device/50_nodes.t
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ sub test_assign($vm, $node, $hd, $n_expected_in_vm, $n_expected_in_node) {
my $found_in_node=0;
my $found_in_vm=0;
my %dupe;
for ($hd->list_devices_nodes) {

my %devices_nodes = $hd->list_devices_nodes();
for (0 .. $n_expected_in_vm+$n_expected_in_node) {
my $name = new_domain_name;
my $req = Ravada::Request->clone(
uid => user_admin->id
Expand All @@ -151,6 +153,7 @@ sub test_assign($vm, $node, $hd, $n_expected_in_vm, $n_expected_in_node) {
my $domain = rvd_back->search_domain($name);
$domain->_data('status','active');
is($domain->is_active,1) if $vm->type eq 'Void';
check_hd_from_node($domain,\%devices_nodes);
my $hd = check_host_device($domain);
push(@{$dupe{$hd}},($base->name." ".$base->id));
is(scalar(@{$dupe{$hd}}),1) or die Dumper(\%dupe);
Expand All @@ -168,6 +171,23 @@ sub test_assign($vm, $node, $hd, $n_expected_in_vm, $n_expected_in_node) {
remove_domain($base2, $base);
}

sub check_hd_from_node($domain, $devices_node) {
my $id_vm = $domain->_data('id_vm');
is($domain->_vm->id,$id_vm);

my @devices = $domain->list_host_devices_attached();
my ($locked) = grep { $_->{is_locked} } @devices;

warn Dumper($locked);

my $vm = Ravada::VM->open($id_vm);
my $devices = $devices_node->{$vm->name};

my ($match) = grep { $_ eq $locked->{name} } @$devices;
ok($match,"Expecting $match in ".Dumper($devices));
exit;
}

sub test_clone_nohd($base) {
my $name = new_domain_name();
my $req0 = Ravada::Request->clone(
Expand Down

0 comments on commit 291acf5

Please sign in to comment.