Commit 0f85584a authored by Francesc Guasch's avatar Francesc Guasch
Browse files

[#326] Set the file_re for Stretch and test downloads

Testing the downloads requires set TEST_DOWNLOADS environment
variable as we don't want to do it frequently.
parent 6dd47f2c
......@@ -228,8 +228,9 @@ sub _update_isos {
,debian_stretch => {
name =>'Debian Stretch 64 bits'
,description => 'Debian 9.0 Stretch 64 bits (XFCE desktop)'
,url => 'https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-9.0.0-amd64-xfce-CD-1.iso'
,md5 => '9346436c0cf1862af71cb0a03d9a703c'
,url => 'https://cdimage.debian.org/debian-cd/9.1.0/amd64/iso-cd/'
,file_re => 'debian-9.[\d\.]+-amd64-xfce-CD-1.iso'
,md5_url => 'https://cdimage.debian.org/debian-cd/9.1.0/amd64/iso-cd/MD5SUMS'
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
}
......
......@@ -1066,7 +1066,7 @@ sub _fetch_filename {
next if !$found;
$file=$found if $found;
}
die "No ".qr($row->{file_re})." found on $row->{url}" if !$file;
die "No ".qr($row->{file_re})." found on $row->{url}<br><pre>$content</pre>" if !$file;
$row->{filename} = $file;
$row->{url} .= "/" if $row->{url} !~ m{/$};
......
......@@ -56,7 +56,7 @@ for my $vm_name ('KVM') {
################################################
#
# Request for the 1st ISO
# Request for the 2nd ISO
$id_iso = 2;
my $iso2 = $vm->_search_iso($id_iso);
if (!$iso2->{device} || ! -e $iso2->{device}) {
......
use warnings;
use strict;
use Carp qw(confess);
use Data::Dumper;
use IPC::Run3;
use Test::More;
use Test::SQL::Data;
use lib 't/lib';
use Test::Ravada;
my $test = Test::SQL::Data->new(config => 't/etc/sql.conf');
use_ok('Ravada');
init($test->connector);
$Ravada::DEBUG=0;
$Ravada::SECONDS_WAIT_CHILDREN = 1;
if (!$ENV{TEST_DOWNLOAD}) {
diag("Set environment variable TEST_DOWNLOAD to run this test.");
done_testing();
exit;
}
sub test_download {
my ($vm, $id_iso) = @_;
my $iso = $vm->_search_iso($id_iso);
unlink($iso->{device}) or die "$! $iso->{device}"
if $iso->{device} && -e $iso->{device};
my $req1 = Ravada::Request->download(
id_iso => $id_iso
, id_vm => $vm->id
, delay => 4
);
is($req1->status, 'requested');
rvd_back->_process_all_requests_dont_fork();
is($req1->status, 'done');
}
##################################################################
for my $vm_name ('KVM') {
my $rvd_back = rvd_back();
my $vm = $rvd_back->search_vm($vm_name);
SKIP: {
my $msg = "SKIPPED: No virtual managers found";
if ($vm && $vm_name =~ /kvm/i && $>) {
$msg = "SKIPPED: Test must run as root";
$vm = undef;
}
skip($msg,10) if !$vm;
################################################
#
# Request for Debian Streth ISO
my $id_iso = search_id_iso('Debian Stretch') or die "I can't find id_iso for Stretch";
test_download($vm, $id_iso);
}
}
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