Commit 16b72eb2 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

refactor(test): removed debug and fixed non-root tests

Also fixed test large ISO in request
parent 106f28f4
......@@ -31,7 +31,7 @@ sub remove_machines(@machines) {
my $domain = rvd_front->search_domain($name) or next;
remove_domain_and_clones_req($domain,1); #remove and wait
}
_wait_request(debug => 1, background => 1, timeout => 120);
_wait_request(debug => 0, background => 1, timeout => 120);
}
sub _wait_request(@args) {
......@@ -87,7 +87,7 @@ sub test_many_clones($base) {
warn Dumper($response);
};
wait_request(debug => 1, background => 1);
wait_request(debug => 0, background => 1);
ok(scalar($base->clones)>=$n_clones);
test_iptables_clones($base);
......@@ -119,7 +119,7 @@ sub test_different_mac(@domain) {
sub test_iptables_clones($base) {
delete_request('set_time','screenshot','refresh_machine_ports');
wait_request(background => 1, debug => 1);
wait_request(background => 1, debug => 0);
my %port_display;
for my $clone_data ( $base->clones ) {
next if $clone_data->{is_base};
......@@ -199,7 +199,7 @@ sub test_copy_without_prepare($clone) {
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);
wait_request(debug => 0, check_error => 1, background => 1, timeout => 120);
my @clones = $clone->clones();
is(scalar @clones, $n_clones) or exit;
......@@ -454,7 +454,7 @@ for my $vm_name ( @{rvd_front->list_vm_types} ) {
}
)->status_is(302);
_wait_request(debug => 1, background => 1, check_error => 1);
_wait_request(debug => 0, background => 1, check_error => 1);
my $base0;
for ( 1 .. 10 ) {
$base0 = rvd_front->search_domain($name);
......@@ -467,7 +467,7 @@ for my $vm_name ( @{rvd_front->list_vm_types} ) {
test_admin_can_do_anything($t, $base0);
mojo_request($t, "add_hardware", { id_domain => $base0->id, name => 'network' });
wait_request(debug => 1, check_error => 1, background => 1, timeout => 120);
wait_request(debug => 0, check_error => 1, background => 1, timeout => 120);
test_validate_html("/machine/manage/".$base0->id.".html");
......
......@@ -9,15 +9,17 @@ eval {
SKIP: {
diag($@) if $@;
skip(2,$@) if $@;
for my $type ( qw(VM Domain ) ){
# TODO: doc for Ravada::Domain::* qw(VM Domain)
for my $type ( qw(VM) ){
Test::Pod::Coverage::pod_coverage_ok( "Ravada::$type"
, { also_private => [ qr/^[A-Z]+$/ ]}
, "Ravada::$type is covered" );
for my $backend (keys %Ravada::VALID_VM ) {
my $module = "Ravada::".$type."::$backend";
Test::Pod::Coverage::pod_coverage_ok(
"Ravada::$type::$backend"
$module
, { also_private => [ qr/^[A-Z]+$/ ]}
, "Ravada::$type::$backend is covered" );
, "$module is covered" );
}
}
for my $pkg ( 'Ravada' , 'Ravada::Front' , 'Ravada::Request', 'Ravada::Auth' ) {
......
......@@ -269,10 +269,12 @@ sub test_all_boot_order($domain, $old_boot) {
}
}
SKIP: {
skip("This test must run as root",56) if $<;
my $vm = rvd_back->search_vm('KVM');
test_change_capacity($vm);
for my $n ( 1 .. 4 ) {
test_change_capacity($vm,$n);
}
}
done_testing();
......@@ -1309,8 +1309,9 @@ sub test_prepare_chained($vm) {
sub test_change_display_settings($vm) {
my $domain = create_domain($vm);
wait_request(debug => 0);
if ($vm->type eq 'Void') {
test_change_display_settings_kvm($domain);
# TODO
} elsif ($vm->type eq 'KVM') {
test_change_display_settings_kvm($domain);
}
......@@ -1650,7 +1651,9 @@ sub test_display_conflict_next($vm) {
for ( 1 .. 10 ) {
$displays1 = $domain1->info(user_admin)->{hardware}->{display};
isnt($displays1->[1+$TLS]->{port}, $next_port_builtin);
if ($vm->type eq 'KVM') {
isnt($displays1->[1+$TLS]->{port}, $next_port_builtin) or die Dumper($displays1);
}
# Now conflict x2go with next builtin display
my ($display_x2go) = grep { $_->{driver} eq 'x2go' } @$displays1;
......@@ -1813,10 +1816,16 @@ sub test_removed_leftover($vm) {
}
sub test_long_iso($vm) {
my $iso_file = '/var/lib/libvirt/'.('a' x 1250);
my $file_dir;
if ($vm->type eq 'KVM') {
$file_dir = '/var/lib/libvirt/images/';
} else {
$file_dir = "/var/tmp";
}
my $iso_file = $file_dir."/".('a' x 200).".iso";
my $req;
eval { $req = Ravada::Request->create_domain( name => 'a', id_template => 1
eval { $req = Ravada::Request->create_domain( name => new_domain_name(), id_template => 1
, iso_file => $iso_file
, id_owner => user_admin->id
, vm => $vm->type
......@@ -1955,7 +1964,6 @@ for my $vm_name ( vm_names() ) {
test_display_info($vm);
test_display_port_already_used($vm);
test_change_display_settings($vm);
test_remove_display($vm);
......
......@@ -258,13 +258,13 @@ sub test_limit_change($vm, $limit) {
@list = rvd_back->list_domains(user => $user, active => 1);
is(scalar @list,3) or warn Dumper([map { $_->name } @list]);
wait_request( debug => 1);
wait_request( debug => 0);
@list = rvd_back->list_domains(user => $user, active => 1);
$req = Ravada::Request->enforce_limits(timeout => 1, _force => 1);
delete_request('set_time');
wait_request( debug => 1);
wait_request( debug => 0);
is($req->status,'done');
is($req->error,'');
......
......@@ -220,7 +220,7 @@ sub test_new_ip {
my $remote_ip = '192.0.2.6';
$domain->start( user => user_admin, remote_ip => $remote_ip);
wait_request(debug => 1);
wait_request(debug => 0);
my ($local_port) = $domain->display(user_admin) =~ m{\d+\.\d+\.\d+\.\d+\:(\d+)};
# test_chain($vm->type, $vm->ip, $local_port, $remote_ip,1);
......
......@@ -1068,7 +1068,7 @@ sub test_req_expose($vm_name) {
,id_domain => $domain->id
);
for ( 1 .. 10 ) {
wait_request(request => $req, debug => 1);
wait_request(request => $req, debug => 0);
last if $req->status eq 'done';
sleep 1;
}
......@@ -1381,11 +1381,7 @@ sub test_expose_nested_base($vm) {
for my $db ( 'mysql', 'sqlite' ) {
clean();
add_network_10(0);
test_can_expose_ports();
for my $vm_name ( reverse vm_names() ) {
if ($db eq 'mysql') {
......@@ -1400,6 +1396,8 @@ for my $vm_name ( reverse vm_names() ) {
}
diag("Testing $vm_name on $db");
clean();
add_network_10(0);
test_can_expose_ports();
SKIP: {
my $vm = rvd_back->search_vm($vm_name);
......
......@@ -308,11 +308,11 @@ sub test_exposed_port($vm) {
$base->expose(22);
my $req = Ravada::Request->manage_pools(uid => user_admin->id , _no_duplicate => 1);
wait_request( debug => 1, skip => 'set_time' );
wait_request( debug => 0, skip => 'set_time' );
is($req->status, 'done');
my $req_refresh = Ravada::Request->refresh_vms( _no_duplicate => 1);
wait_request( debug => 1 ,skip => 'set_time' );
wait_request( debug => 0 ,skip => 'set_time' );
is($req_refresh->status, 'done');
is(scalar($base->clones), $n);
......
......@@ -22,7 +22,7 @@ sub test_storage_pools($vm) {
my $req_cleanup = Ravada::Request->cleanup(
after_request_ok => $req->id
);
wait_request( debug => 1);
wait_request( debug => 0);
is($req->status,'done');
is($req->error, '');
......@@ -67,7 +67,7 @@ sub test_storage_pools_fail($vm) {
after_request_ok => $req->id
);
is($req_cleanup->after_request_ok,$req->id);
wait_request( debug => 1, check_error => 0);
wait_request( debug => 0, check_error => 0);
is($req->status,'done');
like($req->error, qr/not mounted/);
......
Markdown is supported
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