Commit 7f21471f authored by frankiejol's avatar frankiejol
Browse files

refactor(test): skip non-root test

parent d1d7184c
......@@ -9,18 +9,23 @@ use Test::More;
use lib 't/lib';
use Test::Ravada;
use_ok('Ravada');
init();
$Ravada::DEBUG=0;
$Ravada::SECONDS_WAIT_CHILDREN = 1;
##################################################################
SKIP: {
if ($>) {
my $msg = "SKIPPED: Test must run as root";
skip($msg,10) if $<;
}
init();
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";
......@@ -32,7 +37,7 @@ for my $vm_name ('KVM') {
################################################
#
# Request for the 1st ISO
my $id_iso = 1;
my $id_iso = search_id_iso('Alpine');
my $iso = $vm->_search_iso($id_iso);
if (!$iso->{device}) {
......@@ -55,7 +60,7 @@ for my $vm_name ('KVM') {
################################################
#
# Request for the 2nd ISO
$id_iso = 2;
$id_iso = search_id_iso('Debian');
my $iso2 = $vm->_search_iso($id_iso);
if (!$iso2->{device} || ! -e $iso2->{device}) {
$msg = "ISO for $iso2->{filename} not downloaded, I won't do it in the tests";
......@@ -86,7 +91,8 @@ for my $vm_name ('KVM') {
is($req2->status, 'done');
diag($req1->error) if $req1->error;
diag($req2->error) if $req2->error;
}
}
end();
} # of skip
done_testing();
......@@ -12,8 +12,6 @@ use Test::Ravada;
no warnings "experimental::signatures";
use feature qw(signatures);
use_ok('Ravada');
init();
$Ravada::DEBUG=0;
......@@ -53,10 +51,18 @@ sub search_id_isos {
##################################################################
SKIP: {
if ($>) {
my $msg = "SKIPPED: Test must run as root";
diag($msg);
skip($msg,30);
}
init();
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";
......@@ -72,7 +78,7 @@ for my $vm_name ('KVM') {
test_download($vm, $id_iso,1);
}
#test_download($vm, $id_iso,0);
}
}
end();
}
done_testing();
......@@ -69,7 +69,7 @@ sub test_request {
clean();
for my $vm_name (qw(KVM)) {
for my $vm_name ( vm_names() ) {
my $vm;
my $msg = "SKIPPED: virtual manager $vm_name not found";
eval {
......@@ -79,6 +79,10 @@ for my $vm_name (qw(KVM)) {
$msg = "SKIPPED: Test must run as root";
$vm= undef;
}
if ($vm_name eq 'Void') {
$msg = "SKIPPED: Refresh storage missing in Void";
$vm= undef;
}
};
......
......@@ -265,10 +265,9 @@ sub test_settings {
################################################################
remove_old_domains();
remove_old_disks();
clean();
for my $vm_name ('Void','KVM') {
for my $vm_name ( vm_names() ) {
my $vm;
eval { $vm =rvd_back->search_vm($vm_name) };
SKIP: {
......
......@@ -254,7 +254,7 @@ sub test_small {
clean();
$Data::Dumper::Sortkeys = 1;
for my $vm_name (qw( Void KVM )) {
for my $vm_name ( vm_names() ) {
diag("Testing $vm_name VM");
......
......@@ -412,7 +412,7 @@ remove_old_disks();
# maybe ($rv, $out_ar, $errs_ar) = $ipt_obj->run_ipt_cmd('/sbin/iptables
# -t filter -v -n -L RAVADA');
for my $vm_name (qw( Void KVM )) {
for my $vm_name ( vm_names() ) {
diag("Testing $vm_name VM");
......
......@@ -219,7 +219,7 @@ remove_old_disks();
# maybe ($rv, $out_ar, $errs_ar) = $ipt_obj->run_ipt_cmd('/sbin/iptables
# -t filter -v -n -L RAVADA');
for my $vm_name (qw( Void KVM )) {
for my $vm_name ( vm_names() ) {
diag("Testing $vm_name VM");
......
......@@ -519,7 +519,7 @@ sub test_clone_exports($vm, $spinoff=0) {
}
sub test_routing_hibernated($vm) {
my $base = create_domain($vm, user_admin,'debian stretch');
my $base = $BASE->clone(name => new_domain_name, user => user_admin);
$base->expose(port => 22, name => "ssh");
my @base_ports0 = $base->list_ports();
......@@ -555,7 +555,7 @@ sub test_routing_hibernated($vm) {
}
sub test_routing_already_used($vm) {
my $base = create_domain($vm, user_admin,'debian stretch');
my $base = $BASE->clone(name => new_domain_name, user => user_admin);
$base->expose(port => 22, name => "ssh");
my @base_ports0 = $base->list_ports();
......@@ -1087,7 +1087,7 @@ Test::Ravada::_clean_db();
add_network_10(0);
test_can_expose_ports();
for my $vm_name ( 'KVM', 'Void' ) {
for my $vm_name ( vm_names() ) {
SKIP: {
my $vm = rvd_back->search_vm($vm_name);
......@@ -1102,10 +1102,11 @@ for my $vm_name ( 'KVM', 'Void' ) {
skip $msg,10 if !$vm;
diag("Testing $vm_name");
import_base($vm);
test_routing_hibernated($vm);
test_routing_already_used($vm);
import_base($vm);
test_clone_exports_add_ports($vm);
......
......@@ -132,7 +132,7 @@ sub test_autostart_front($vm_name) {
clean();
for my $vm_name ( 'Void', 'KVM' ) {
for my $vm_name ( vm_names() ) {
my $vm;
......
......@@ -229,7 +229,7 @@ sub test_copy_req_many {
##########################################################################3
for my $vm_name ('Void', 'KVM') {
for my $vm_name ( vm_names() ) {
diag($vm_name);
my $vm = rvd_back->search_vm($vm_name);
......
......@@ -59,7 +59,7 @@ sub test_dont_download {
clean();
for my $vm_name ('Void', 'KVM') {
for my $vm_name ( vm_names() ) {
my $vm = rvd_back->search_vm($vm_name);
SKIP: {
......
......@@ -134,7 +134,7 @@ sub test_add_disk_boot_order {
clean();
for my $vm_name ('Void', 'KVM') {
for my $vm_name ( vm_names() ) {
my $vm = rvd_back->search_vm($vm_name);
SKIP: {
......
......@@ -86,7 +86,7 @@ sub test_remove_hybernated {
clean();
for my $vm_name ( @{rvd_front->list_vm_types}) {
for my $vm_name ( vm_names() ) {
my $vm = rvd_back->search_vm($vm_name);
......
......@@ -19,7 +19,7 @@ my $USER = create_user("foo","bar", 1);
clean();
for my $vm_name ( @{rvd_front->list_vm_types}) {
for my $vm_name ( vm_names() ) {
my $vm = rvd_back->search_vm($vm_name);
......
......@@ -85,10 +85,7 @@ sub test_change_memory_base {
eval { $domain->set_max_mem(1024*1024*3) };
ok(!$@,$@);
my $doc = XML::LibXML->load_xml(string => $domain->xml_description);
ok($doc,$doc);
$domain->remove(user_admin);
}
......@@ -132,7 +129,7 @@ sub test_req_change_mem($vm) {
}
####################################################################
for my $vm_name ( q(KVM) ) {
for my $vm_name ( vm_names() ) {
init('t/etc/ravada_freemem.conf');
my $vm;
......
......@@ -208,7 +208,7 @@ sub test_chain($vm_name, %args) {
clean();
flush_rules();
for my $vm_name ( 'Void', 'KVM' ) {
for my $vm_name ( vm_names() ) {
my $vm;
......
......@@ -12,15 +12,13 @@ use_ok('Ravada');
my $RVD_BACK = rvd_back();
my $RVD_FRONT= rvd_front();
my @VMS = ('KVM','Void');
my $TEST_LONG = ($ENV{TEST_LONG} or 0);
#############################################################
clean();
for my $vm_name (reverse sort @VMS) {
for my $vm_name ( vm_names() ) {
diag("Testing $vm_name VM");
......
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