<commit_before>use warnings;
use strict;

use Carp qw(confess);
use Data::Dumper;
use Digest::MD5;
use Test::More;
use Test::SQL::Data;

use lib 't/lib';
use Test::Ravada;

no warnings "experimental::signatures";
use feature qw(signatures);

my $test = Test::SQL::Data->new(config => 't/etc/sql.conf');
$Ravada::Domain::MIN_FREE_MEMORY = 256 * 1024;

init($test->connector);

clean();
clean_remote();

my $REMOTE_CONFIG;
#############################################################

sub create_node {
    my $vm_name = shift;

    die "Error: missing host in remote config\n ".Dumper($REMOTE_CONFIG)
        if !$REMOTE_CONFIG->{host};

    my $vm = rvd_back->search_vm($vm_name);

    my $node;
    my @list_nodes0 = rvd_front->list_vms;

    eval { $node = $vm->new(%{$REMOTE_CONFIG}) };

    shutdown_node($node)   if $node->ping && !$node->_connect_rex();
    start_node($node);

    clean_remote_node($node);

    return $node;
}

sub test_list_vms($vm_name) {<commit_msg>[#555] use more general is_connected<commit_after>use warnings;
use strict;

use Carp qw(confess);
use Data::Dumper;
use Digest::MD5;
use Test::More;
use Test::SQL::Data;

use lib 't/lib';
use Test::Ravada;

no warnings "experimental::signatures";
use feature qw(signatures);

my $test = Test::SQL::Data->new(config => 't/etc/sql.conf');
$Ravada::Domain::MIN_FREE_MEMORY = 256 * 1024;

init($test->connector);

clean();
clean_remote();

my $REMOTE_CONFIG;
#############################################################

sub create_node {
    my $vm_name = shift;

    die "Error: missing host in remote config\n ".Dumper($REMOTE_CONFIG)
        if !$REMOTE_CONFIG->{host};

    my $vm = rvd_back->search_vm($vm_name);

    my $node;
    my @list_nodes0 = rvd_front->list_vms;

    eval { $node = $vm->new(%{$REMOTE_CONFIG}) };

    shutdown_node($node)   if $node->ping && !$node->is_connected();
    start_node($node);

    clean_remote_node($node);

    return $node;
}

sub test_list_vms($vm_name) {
{'fraction_non_alphanumeric': 0.21980798383021727, 'fraction_numerical': 0.010611419909044972, 'mean_word_length': 4.806451612903226, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3184656', 'n_tokens_mistral': 755, 'n_tokens_neox': 698, 'n_words': 152}