Commit 687ef626 authored by Francesc Guasch's avatar Francesc Guasch Committed by Francesc Guasch
Browse files

test(ports): check new ports in base are in clone too

issue #1197
parent 63d5de68
......@@ -497,6 +497,38 @@ sub test_clone_exports($vm) {
$base->remove(user_admin);
}
sub test_clone_exports_add_ports($vm) {
my $base = create_domain($vm, user_admin,'debian stretch');
$base->expose(port => 22, name => "ssh");
my @base_ports0 = $base->list_ports();
$base->prepare_base(user => user_admin, with_cd => 1);
my $clone = $base->clone(name => new_domain_name, user => user_admin);
$base->expose(port => 80, name => "web");
my @base_ports = $base->list_ports();
is(scalar @base_ports, scalar @base_ports0 + 1);
$clone->start(remote_ip => '10.1.1.1', user => user_admin);
my @clone_ports = $clone->list_ports();
is(scalar @clone_ports,2 );
for my $n ( 0 .. 1 ) {
is($base_ports[$n]->{internal_port}, $clone_ports[$n]->{internal_port});
isnt($base_ports[$n]->{public_port}, $clone_ports[$n]->{public_port},"Same public port in clone and base for ".$base_ports[$n]->{internal_port});
is($base_ports[$n]->{name}, $clone_ports[$n]->{name});
}
_wait_ip($vm, $clone);
wait_request( );
my @out = split /\n/, `iptables -t nat -L PREROUTING -n`;
ok(grep /dpt:\d+.*\d+:22/, @out);
ok(grep /dpt:\d+.*\d+:80/, @out);
$clone->remove(user_admin);
$base->remove(user_admin);
}
sub _wait_ip {
my $vm_name = shift;
my $domain = shift or confess "Missing domain arg";
......@@ -898,6 +930,7 @@ for my $vm_name ( 'KVM', 'Void' ) {
next if !$vm;
diag("Testing $vm_name");
test_clone_exports_add_ports($vm);
test_no_dupe($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