Commit 2e9015be authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'master' of github.com:frankiejol/ravada

parents 8cf30a1e 86b035de
......@@ -22,3 +22,7 @@ See docs/production.md
### Operation
See docs/operation.md
### Testing
See docs/test.md
#Testing environment
Previously [install](https://github.com/frankiejol/Test-SQL-Data/blob/master/INSTALL.md) TEST::SQL::DATA module.
In project root run:
$ perl Makefile.PL
$ sudo make test
At the end, in "Test Summary Report" you can check the result.
If something goes wrong you see:
Result: FAIL
##Run a single test
$ make && sudo prove -b t/lxc/*t
package Ravada::Domain::LXC;
use warnings;
use strict;
use Carp qw(cluck croak);
use Data::Dumper;
use IPC::Run3 qw(run3);
use Moose;
use XML::LibXML;
#with 'Ravada::Domain';
##################################################
#
our $TIMEOUT_SHUTDOWN = 60;
our $CONNECTOR = \$Ravada::CONNECTOR;
##################################################
#TODO
#sub name {
# my $self = shift;
#}
#TODO
sub create_container {
my $self = shift;
my $name = shift;
my @domain = ('lxc-create','-n',$name,'-t','ubuntu');
my ($in,$out,$err);
run3(\@domain,\$in,\$out,\$err);
warn $out if $out;
warn $err if $err;
return;
}
sub remove_container {
my $self = shift;
my $name = shift;
my @domain = ('lxc-destroy','-n',$name,'-f');
my ($in,$out,$err);
run3(\@domain,\$in,\$out,\$err);
warn $out if $out;
warn $err if $err;
return;
}
sub search_container {
my $self = shift;
my $name = shift;
my @info = ('lxc-info','-n',$name);
my ($in,$out,$err);
run3(\@info,\$in,\$out,\$err);
warn $out if $out;
warn $err if $err;
return;
}
sub shutdown {
my $self = shift;
}
=head2 pause
Pauses the domain
=cut
sub pause {
}
1;
use warnings;
use strict;
use Data::Dumper;
use IPC::Run3;
use Test::More;
use Test::SQL::Data;
use_ok('Ravada');
use_ok('Ravada::Domain::LXC');
my $test = Test::SQL::Data->new( config => 't/etc/ravada.conf');
my $ravada= 'Ravada::Domain::LXC'->new();
my $CONT= 0;
sub test_remove_container {
my $name = shift;
my $domain;
$domain = $ravada->search_container($name,1);
if ($domain) {
diag("Removing container $name");
$ravada->remove_container($name);
}
}
sub test_new_container {
my $active = shift;
my ($name) = $0 =~ m{.*/(.*)\.t};
$name .= "_".$CONT++;
test_remove_container($name);
diag("Creating container $name");
$ravada->create_container($name,1);
# ok(!$?),"Container $name created");
return $name;
}
################################################################
test_new_container();
#test_remove_container();
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