Commit 3f669f4b authored by Francesc Guasch's avatar Francesc Guasch
Browse files

refactor(tests); fix check with local ips

in some environments with no network it may fail
parent f939436c
......@@ -55,6 +55,7 @@ create_domain
init_ldap_config
create_storage_pool
local_ips
);
our $DEFAULT_CONFIG = "t/etc/ravada.conf";
......@@ -758,6 +759,8 @@ sub clean {
warn $@ if $@;
_clean_remote_nodes($config) if $config;
}
unlink $FILE_CONFIG_TMP or die "$! $FILE_CONFIG_TMP"
if $FILE_CONFIG_TMP && -e $FILE_CONFIG_TMP;
_clean_db();
_clean_file_config();
shutdown_nodes();
......@@ -1164,6 +1167,15 @@ sub find_ip_rule {
return $found[0];
}
sub local_ips($vm) {
my ($out, $err) = $vm->run_command("/bin/ip","address");
confess $err if $err;
my @ips = map { m{^\s+inet (.*?)/};$1 }
grep { m{^\s+inet } }
split /\n/,$out;
return @ips;
}
sub shutdown_domain_internal($domain) {
if ($domain->type eq 'KVM') {
$domain->domain->destroy();
......
......@@ -67,18 +67,19 @@ for my $vm_name ( 'Void', 'KVM') {
$vm = undef;
}
my ($node1,$node2) = remote_node_2($vm_name);
if ( !$node2 ) {
$msg = "Expecting at least 2 nodes configured to test";
$vm = undef;
my ($node1,$node2);
if ($vm) {
($node1,$node2) = remote_node_2($vm_name);
if (!$node2) {
$vm = undef;
$msg = "Expecting at least 2 nodes configured to test";
}
}
diag($msg) if !$vm;
skip($msg,10) if !$vm;
diag("Testing remote node in $vm_name");
clean_remote_node($node1);
clean_remote_node($node2) if $node2;
......
......@@ -71,6 +71,11 @@ sub test_files_base {
sub test_display {
my ($vm_name, $domain) = @_;
my @ips = local_ips($domain->_vm);
my @ips2 = grep { $_ ne '127.0.0.1' } @ips;
skip("No IPs found in ".$domain->_vm->name,5) if !scalar @ips2;
my $display;
$domain->shutdown_now(user_admin);
$domain->start(user => user_admin, remote_ip => '1.2.3.4' );# if !$domain->is_active;
......
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