Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
f900468f
Commit
f900468f
authored
Jan 10, 2022
by
Francesc Guasch
Browse files
test: create from ISO
parent
0373266c
Changes
2
Hide whitespace changes
Inline
Side-by-side
.github/workflows/github-action-test.yml
View file @
f900468f
...
...
@@ -60,3 +60,5 @@ jobs:
run
:
prove -lr t/17_templates.t
-
name
:
Test mock VM
run
:
prove -lr t/vm/60_new_args.t t/30_request.t
-
name
:
Test create from ISO
run
:
prove -lr t/request/25_create_from_iso.t
t/request/25_create_from_iso.t
0 → 100644
View file @
f900468f
use
warnings
;
use
strict
;
use
Carp
qw(confess)
;
use
Data::
Dumper
qw(Dumper)
;
use
Mojo::
JSON
qw(encode_json decode_json)
;
use
Test::
More
;
use
lib
'
t/lib
';
use
Test::
Ravada
;
no
warnings
"
experimental::signatures
";
use
feature
qw(signatures)
;
########################################################################
sub
test_create
($vm, $with_iso_file=1, $no_cd=0) {
my
$iso
=
_load_iso
(
$vm
,
'
Debian%
');
$iso
=
_load_iso
(
$vm
,
'
Empty Machine 32 bits
')
if
$no_cd
;
my
$name
=
new_domain_name
();
my
@args
=
(
id_owner
=>
user_admin
->
id
,
name
=>
$name
,
vm
=>
$vm
->
type
,
id_iso
=>
$iso
->
{
id
}
);
push
@args
,(
iso_file
=>
"")
if
$with_iso_file
;
my
$req
=
Ravada::
Request
->
create_domain
(
@args
);
unless
(
$no_cd
)
{
my
$req_download
=
Ravada::Request::
_search_request
('
download
');
ok
(
$req_download
,"
Expecting a download request
")
or
die
;
$req_download
->
arg
(
test
=>
1
);
}
wait_request
(
debug
=>
0
);
my
$domain
=
rvd_front
->
search_domain
(
$name
);
ok
(
$domain
);
my
$disks
=
$domain
->
info
(
user_admin
)
->
{
hardware
}
->
{
disk
};
my
(
$cdrom
)
=
grep
{
$_
->
{
file
}
=~
m{/.*iso$}
}
@$disks
;
if
(
$no_cd
)
{
ok
(
!
$cdrom
,"
Expecting no CDROM in
"
.
Dumper
(
$disks
));
}
else
{
ok
(
$cdrom
,"
Expecting a CDROM in
"
.
Dumper
(
$disks
));
}
}
sub
_load_iso
($vm, $name) {
# my $name = 'debian%';
my
$sth
=
connector
->
dbh
->
prepare
("
SELECT * FROM iso_images
"
.
"
WHERE name like ?
"
);
$sth
->
execute
(
$name
);
my
$iso
=
$sth
->
fetchrow_hashref
;
die
"
No
$name
found in iso_images
"
.
Dumper
(
$iso
)
if
!
$iso
->
{
id
};
_remove_device
(
$vm
,
$iso
);
return
$iso
;
}
sub
_remove_device
($vm, $iso ) {
my
$device
=
$iso
->
{
device
};
return
if
!
$device
;
# unlink $device or die "$! $device" if $device;
$iso
->
{
device
}
=
undef
;
my
$sth
=
connector
->
dbh
->
prepare
("
UPDATE iso_images
"
.
"
SET device=NULL
"
.
"
WHERE id=?
"
);
$sth
->
execute
(
$iso
->
{
id
});
$sth
->
finish
;
}
########################################################################
init
();
for
my
$vm_name
(
vm_names
()
)
{
SKIP:
{
my
$vm
=
rvd_back
->
search_vm
(
$vm_name
);
my
$msg
=
"
SKIPPED test: No
$vm_name
VM found
";
if
(
$vm
&&
$vm_name
eq
'
KVM
'
&&
$>
)
{
$msg
=
"
SKIPPED: Test must run as root
";
$vm
=
undef
;
}
diag
(
$msg
)
if
!
$vm
;
skip
$msg
,
10
if
!
$vm
;
diag
("
Testing create from ISO in
$vm_name
");
test_create
(
$vm
,
1
);
test_create
(
$vm
);
test_create
(
$vm
,
0
,
1
);
}
}
end
();
done_testing
();
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment