forked from Mirror/pve-network
test: run through perltidy
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
74dcbe9c08
commit
ddd3d0f726
|
@ -20,6 +20,7 @@ $Data::Dumper::Sortkeys = 1;
|
|||
|
||||
sub read_sdn_config {
|
||||
my ($file) = @_;
|
||||
|
||||
# Read structure back in again
|
||||
open my $in, '<', $file or die $!;
|
||||
my $sdn_config;
|
||||
|
@ -32,7 +33,6 @@ sub read_sdn_config {
|
|||
return $sdn_config;
|
||||
}
|
||||
|
||||
|
||||
my @plugins = read_dir('./dns/', prefix => 1);
|
||||
|
||||
foreach my $path (@plugins) {
|
||||
|
@ -40,7 +40,6 @@ foreach my $path (@plugins) {
|
|||
my (undef, $dnsid) = split(/\//, $path);
|
||||
my $sdn_config = read_sdn_config("$path/sdn_config");
|
||||
|
||||
|
||||
my $pve_sdn_dns;
|
||||
$pve_sdn_dns = Test::MockModule->new('PVE::Network::SDN::Dns');
|
||||
$pve_sdn_dns->mock(
|
||||
|
@ -64,11 +63,9 @@ foreach my $path (@plugins) {
|
|||
my $encoded_data = $js->encode($data) if $data;
|
||||
my $req = HTTP::Request->new($method, $url, $headers, $encoded_data);
|
||||
die Dumper($req);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
|
||||
my $dns_cfg = PVE::Network::SDN::Dns::config();
|
||||
my $plugin_config = $dns_cfg->{ids}->{$dnsid};
|
||||
my $plugin = PVE::Network::SDN::Dns::Plugin->lookup($plugin_config->{type});
|
||||
|
@ -93,7 +90,7 @@ foreach my $path (@plugins) {
|
|||
},
|
||||
get_zone_rrset => sub {
|
||||
return undef;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
## add_a_record
|
||||
|
@ -122,7 +119,6 @@ foreach my $path (@plugins) {
|
|||
fail($name);
|
||||
}
|
||||
|
||||
|
||||
## del_ptr_record
|
||||
$test = "del_ptr_record";
|
||||
$expected = Dumper read_sdn_config("$path/expected.$test.$ipversion");
|
||||
|
@ -136,7 +132,6 @@ foreach my $path (@plugins) {
|
|||
fail($name);
|
||||
}
|
||||
|
||||
|
||||
## del_a_record
|
||||
|
||||
$sdn_dns_plugin->mock(
|
||||
|
@ -148,17 +143,21 @@ foreach my $path (@plugins) {
|
|||
|
||||
my $type = Net::IP::ip_is_ipv6($ip) ? "AAAA" : "A";
|
||||
my $fqdn = $hostname . "." . $zone . ".";
|
||||
my $record = { content => $ip,
|
||||
my $record = {
|
||||
content => $ip,
|
||||
disabled => JSON::false,
|
||||
name => $fqdn,
|
||||
type => $type };
|
||||
type => $type,
|
||||
};
|
||||
|
||||
my $rrset = { name => $fqdn,
|
||||
my $rrset = {
|
||||
name => $fqdn,
|
||||
type => $type,
|
||||
ttl => '3600',
|
||||
records => [ $record ] };
|
||||
records => [$record],
|
||||
};
|
||||
return $rrset;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
$test = "del_a_record";
|
||||
|
@ -182,22 +181,28 @@ foreach my $path (@plugins) {
|
|||
},
|
||||
get_zone_rrset => sub {
|
||||
|
||||
my $record = { content => $ip,
|
||||
my $record = {
|
||||
content => $ip,
|
||||
disabled => JSON::false,
|
||||
name => $fqdn,
|
||||
type => $type };
|
||||
type => $type,
|
||||
};
|
||||
|
||||
my $record2 = { content => $ip2,
|
||||
my $record2 = {
|
||||
content => $ip2,
|
||||
disabled => JSON::false,
|
||||
name => $fqdn,
|
||||
type => $type };
|
||||
type => $type,
|
||||
};
|
||||
|
||||
my $rrset = { name => $fqdn,
|
||||
my $rrset = {
|
||||
name => $fqdn,
|
||||
type => $type,
|
||||
ttl => '3600',
|
||||
records => [ $record, $record2 ] };
|
||||
records => [$record, $record2],
|
||||
};
|
||||
return $rrset;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
$test = "del_a_multiple_record";
|
||||
|
@ -221,17 +226,21 @@ foreach my $path (@plugins) {
|
|||
},
|
||||
get_zone_rrset => sub {
|
||||
|
||||
my $record2 = { content => $ip2,
|
||||
my $record2 = {
|
||||
content => $ip2,
|
||||
disabled => JSON::false,
|
||||
name => $fqdn,
|
||||
type => $type };
|
||||
type => $type,
|
||||
};
|
||||
|
||||
my $rrset = { name => $fqdn,
|
||||
my $rrset = {
|
||||
name => $fqdn,
|
||||
type => $type,
|
||||
ttl => '3600',
|
||||
records => [ $record2 ] };
|
||||
records => [$record2],
|
||||
};
|
||||
return $rrset;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
$test = "add_a_multiple_record";
|
||||
|
@ -264,4 +273,3 @@ foreach my $path (@plugins) {
|
|||
|
||||
done_testing();
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ $Data::Dumper::Sortkeys = 1;
|
|||
|
||||
sub read_sdn_config {
|
||||
my ($file) = @_;
|
||||
|
||||
# Read structure back in again
|
||||
open my $in, '<', $file or die $!;
|
||||
my $sdn_config;
|
||||
|
@ -32,7 +33,6 @@ sub read_sdn_config {
|
|||
return $sdn_config;
|
||||
}
|
||||
|
||||
|
||||
#my @plugins = <./ipams/*>;
|
||||
my @plugins = read_dir('./ipams/', prefix => 1);
|
||||
|
||||
|
@ -41,7 +41,6 @@ foreach my $path (@plugins) {
|
|||
my (undef, $ipamid) = split(/\//, $path);
|
||||
my $sdn_config = read_sdn_config("$path/sdn_config");
|
||||
|
||||
|
||||
my $pve_sdn_subnets;
|
||||
$pve_sdn_subnets = Test::MockModule->new('PVE::Network::SDN::Subnets');
|
||||
$pve_sdn_subnets->mock(
|
||||
|
@ -73,11 +72,9 @@ foreach my $path (@plugins) {
|
|||
my $encoded_data = $js->encode($data) if $data;
|
||||
my $req = HTTP::Request->new($method, $url, $headers, $encoded_data);
|
||||
die Dumper($req);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
|
||||
#test params;
|
||||
my $subnetid = "myzone-10.0.0.0-24";
|
||||
my $ip = "10.0.0.1";
|
||||
|
@ -86,8 +83,8 @@ foreach my $path (@plugins) {
|
|||
my $description = "mydescription";
|
||||
my $is_gateway = 1;
|
||||
|
||||
|
||||
my $subnet = PVE::Network::SDN::Subnets::sdn_subnets_config($sdn_config->{subnets}, $subnetid, 1);
|
||||
my $subnet =
|
||||
PVE::Network::SDN::Subnets::sdn_subnets_config($sdn_config->{subnets}, $subnetid, 1);
|
||||
|
||||
my $ipam_cfg = PVE::Network::SDN::Ipams::config();
|
||||
my $plugin_config = $ipam_cfg->{ids}->{$ipamid};
|
||||
|
@ -102,7 +99,7 @@ foreach my $path (@plugins) {
|
|||
},
|
||||
is_ip_gateway => sub {
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
## add_ip
|
||||
|
@ -110,7 +107,8 @@ foreach my $path (@plugins) {
|
|||
my $expected = Dumper read_sdn_config("$path/expected.$test");
|
||||
my $name = "$ipamid $test";
|
||||
|
||||
$plugin->add_ip($plugin_config, $subnetid, $subnet, $ip, $hostname, $mac, $description, $is_gateway, 1);
|
||||
$plugin->add_ip($plugin_config, $subnetid, $subnet, $ip, $hostname, $mac, $description,
|
||||
$is_gateway, 1);
|
||||
|
||||
if ($@) {
|
||||
is($@, $expected, $name);
|
||||
|
@ -131,7 +129,6 @@ foreach my $path (@plugins) {
|
|||
fail($name);
|
||||
}
|
||||
|
||||
|
||||
## del_ip
|
||||
$test = "del_ip";
|
||||
$expected = Dumper read_sdn_config("$path/expected.$test");
|
||||
|
@ -149,7 +146,8 @@ foreach my $path (@plugins) {
|
|||
$test = "update_ip";
|
||||
$expected = Dumper read_sdn_config("$path/expected.$test");
|
||||
$name = "$ipamid $test";
|
||||
$plugin->update_ip($plugin_config, $subnetid, $subnet, $ip, $hostname, $mac, $description, $is_gateway, 1);
|
||||
$plugin->update_ip($plugin_config, $subnetid, $subnet, $ip, $hostname, $mac, $description,
|
||||
$is_gateway, 1);
|
||||
|
||||
if ($@) {
|
||||
is($@, $expected, $name);
|
||||
|
@ -163,7 +161,8 @@ foreach my $path (@plugins) {
|
|||
$expected = Dumper read_sdn_config("$path/expected.$test");
|
||||
$name = "$ipamid $test";
|
||||
|
||||
$plugin->add_ip($plugin_config, $subnetid, $subnet, $ip, $hostname, $mac, $description, $is_gateway, 1);
|
||||
$plugin->add_ip($plugin_config, $subnetid, $subnet, $ip, $hostname, $mac, $description,
|
||||
$is_gateway, 1);
|
||||
|
||||
if ($@) {
|
||||
is($@, $expected, $name);
|
||||
|
@ -194,4 +193,3 @@ foreach my $path (@plugins) {
|
|||
|
||||
done_testing();
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ use JSON;
|
|||
use Data::Dumper qw(Dumper);
|
||||
$Data::Dumper::Sortkeys = 1;
|
||||
|
||||
|
||||
my $locks = {};
|
||||
|
||||
my $mocked_cfs_lock_file = sub {
|
||||
|
@ -37,6 +36,7 @@ my $mocked_cfs_lock_file = sub {
|
|||
|
||||
sub read_sdn_config {
|
||||
my ($file) = @_;
|
||||
|
||||
# Read structure back in again
|
||||
open my $in, '<', $file or die $!;
|
||||
my $sdn_config;
|
||||
|
@ -49,7 +49,6 @@ sub read_sdn_config {
|
|||
return $sdn_config;
|
||||
}
|
||||
|
||||
|
||||
my @plugins = read_dir('./subnets/', prefix => 1);
|
||||
|
||||
foreach my $path (@plugins) {
|
||||
|
@ -59,7 +58,6 @@ foreach my $path (@plugins) {
|
|||
print "test: $testid\n";
|
||||
my $sdn_config = read_sdn_config("$path/sdn_config");
|
||||
|
||||
|
||||
my $pve_sdn_subnets;
|
||||
$pve_sdn_subnets = Test::MockModule->new('PVE::Network::SDN::Subnets');
|
||||
$pve_sdn_subnets->mock(
|
||||
|
@ -71,18 +69,17 @@ foreach my $path (@plugins) {
|
|||
},
|
||||
add_dns_record => sub {
|
||||
return;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
my $js = JSON->new;
|
||||
$js->canonical(1);
|
||||
|
||||
|
||||
#test params;
|
||||
my $subnets = $sdn_config->{subnets}->{ids};
|
||||
my $subnetid = (keys %{$subnets})[0];
|
||||
my $subnet = PVE::Network::SDN::Subnets::sdn_subnets_config($sdn_config->{subnets}, $subnetid, 1);
|
||||
my $subnet =
|
||||
PVE::Network::SDN::Subnets::sdn_subnets_config($sdn_config->{subnets}, $subnetid, 1);
|
||||
|
||||
my $subnet_cidr = $subnet->{cidr};
|
||||
my $iplist = NetAddr::IP->new($subnet_cidr);
|
||||
|
@ -132,7 +129,7 @@ foreach my $path (@plugins) {
|
|||
},
|
||||
del_cache_mac_ip => sub {
|
||||
return;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
## add_subnet
|
||||
|
@ -159,10 +156,16 @@ foreach my $path (@plugins) {
|
|||
$test = "add_ip $ip";
|
||||
$name = "$testid $test";
|
||||
$result = undef;
|
||||
$expected = '{"zones":{"myzone":{"subnets":{"'.$subnet_cidr.'":{"ips":{"'.$ip.'":{"gateway":1}}}}}}}';
|
||||
$expected =
|
||||
'{"zones":{"myzone":{"subnets":{"'
|
||||
. $subnet_cidr
|
||||
. '":{"ips":{"'
|
||||
. $ip
|
||||
. '":{"gateway":1}}}}}}}';
|
||||
|
||||
eval {
|
||||
PVE::Network::SDN::Subnets::add_ip($zone, $subnetid, $subnet, $ip, $hostname, $mac, $vmid, $is_gateway);
|
||||
PVE::Network::SDN::Subnets::add_ip($zone, $subnetid, $subnet, $ip, $hostname, $mac, $vmid,
|
||||
$is_gateway);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
|
@ -180,7 +183,8 @@ foreach my $path (@plugins) {
|
|||
$name = "$testid $test";
|
||||
|
||||
eval {
|
||||
PVE::Network::SDN::Subnets::add_ip($zone, $subnetid, $subnet, $ip, $hostname, $mac, $vmid);
|
||||
PVE::Network::SDN::Subnets::add_ip($zone, $subnetid, $subnet, $ip, $hostname, $mac,
|
||||
$vmid);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
|
@ -194,7 +198,20 @@ foreach my $path (@plugins) {
|
|||
$test = "add_second_ip $ip2";
|
||||
$name = "$testid $test";
|
||||
$result = undef;
|
||||
$expected = '{"zones":{"myzone":{"subnets":{"'.$subnet_cidr.'":{"ips":{"'.$ip.'":{"gateway":1},"'.$ip2.'":{"hostname":"'.$hostname.'","mac":"'.$mac.'","vmid":"'.$vmid.'"}}}}}}}';
|
||||
$expected =
|
||||
'{"zones":{"myzone":{"subnets":{"'
|
||||
. $subnet_cidr
|
||||
. '":{"ips":{"'
|
||||
. $ip
|
||||
. '":{"gateway":1},"'
|
||||
. $ip2
|
||||
. '":{"hostname":"'
|
||||
. $hostname
|
||||
. '","mac":"'
|
||||
. $mac
|
||||
. '","vmid":"'
|
||||
. $vmid
|
||||
. '"}}}}}}}';
|
||||
|
||||
eval {
|
||||
PVE::Network::SDN::Subnets::add_ip($zone, $subnetid, $subnet, $ip2, $hostname, $mac, $vmid);
|
||||
|
@ -213,10 +230,26 @@ foreach my $path (@plugins) {
|
|||
$test = "find_next_freeip ($ipnextfree)";
|
||||
$name = "$testid $test";
|
||||
$result = undef;
|
||||
$expected = '{"zones":{"myzone":{"subnets":{"'.$subnet_cidr.'":{"ips":{"'.$ip.'":{"gateway":1},"'.$ipnextfree.'":{},"'.$ip2.'":{"hostname":"'.$hostname.'","mac":"'.$mac.'","vmid":"'.$vmid.'"}}}}}}}';
|
||||
$expected =
|
||||
'{"zones":{"myzone":{"subnets":{"'
|
||||
. $subnet_cidr
|
||||
. '":{"ips":{"'
|
||||
. $ip
|
||||
. '":{"gateway":1},"'
|
||||
. $ipnextfree
|
||||
. '":{},"'
|
||||
. $ip2
|
||||
. '":{"hostname":"'
|
||||
. $hostname
|
||||
. '","mac":"'
|
||||
. $mac
|
||||
. '","vmid":"'
|
||||
. $vmid
|
||||
. '"}}}}}}}';
|
||||
|
||||
eval {
|
||||
$ip3 = PVE::Network::SDN::Subnets::add_next_free_ip($zone, $subnetid, $subnet, $hostname, $mac, $vmid);
|
||||
$ip3 = PVE::Network::SDN::Subnets::add_next_free_ip($zone, $subnetid, $subnet, $hostname,
|
||||
$mac, $vmid);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
|
@ -230,11 +263,22 @@ foreach my $path (@plugins) {
|
|||
$test = "del_ip $ip";
|
||||
$name = "$testid $test";
|
||||
$result = undef;
|
||||
$expected = '{"zones":{"myzone":{"subnets":{"'.$subnet_cidr.'":{"ips":{"'.$ipnextfree.'":{},"'.$ip2.'":{"hostname":"'.$hostname.'","mac":"'.$mac.'","vmid":"'.$vmid.'"}}}}}}}';
|
||||
$expected =
|
||||
'{"zones":{"myzone":{"subnets":{"'
|
||||
. $subnet_cidr
|
||||
. '":{"ips":{"'
|
||||
. $ipnextfree
|
||||
. '":{},"'
|
||||
. $ip2
|
||||
. '":{"hostname":"'
|
||||
. $hostname
|
||||
. '","mac":"'
|
||||
. $mac
|
||||
. '","vmid":"'
|
||||
. $vmid
|
||||
. '"}}}}}}}';
|
||||
|
||||
eval {
|
||||
PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $subnet, $ip, $hostname);
|
||||
};
|
||||
eval { PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $subnet, $ip, $hostname); };
|
||||
|
||||
if ($@) {
|
||||
fail("$name : $@");
|
||||
|
@ -252,9 +296,7 @@ foreach my $path (@plugins) {
|
|||
$result = undef;
|
||||
$expected = undef;
|
||||
|
||||
eval {
|
||||
PVE::Network::SDN::Subnets::del_subnet($zone, $subnetid, $subnet);
|
||||
};
|
||||
eval { PVE::Network::SDN::Subnets::del_subnet($zone, $subnetid, $subnet); };
|
||||
|
||||
if ($@) {
|
||||
is($result, $expected, $name);
|
||||
|
@ -263,7 +305,6 @@ foreach my $path (@plugins) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
## add_ip_rollback_failing_dns
|
||||
$test = "add_ip_rollback_failing_dns";
|
||||
|
||||
|
@ -277,12 +318,25 @@ foreach my $path (@plugins) {
|
|||
add_dns_record => sub {
|
||||
die "error add dns record";
|
||||
return;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
$name = "$testid $test";
|
||||
$result = undef;
|
||||
$expected = '{"zones":{"myzone":{"subnets":{"'.$subnet_cidr.'":{"ips":{"'.$ipnextfree.'":{},"'.$ip2.'":{"hostname":"'.$hostname.'","mac":"'.$mac.'","vmid":"'.$vmid.'"}}}}}}}';
|
||||
$expected =
|
||||
'{"zones":{"myzone":{"subnets":{"'
|
||||
. $subnet_cidr
|
||||
. '":{"ips":{"'
|
||||
. $ipnextfree
|
||||
. '":{},"'
|
||||
. $ip2
|
||||
. '":{"hostname":"'
|
||||
. $hostname
|
||||
. '","mac":"'
|
||||
. $mac
|
||||
. '","vmid":"'
|
||||
. $vmid
|
||||
. '"}}}}}}}';
|
||||
|
||||
eval {
|
||||
PVE::Network::SDN::Subnets::add_ip($zone, $subnetid, $subnet, $ip, $hostname, $mac, $vmid);
|
||||
|
@ -299,7 +353,6 @@ foreach my $path (@plugins) {
|
|||
fail("$name : $@");
|
||||
}
|
||||
|
||||
|
||||
## del_empty_subnet
|
||||
$test = "del_empty_subnet";
|
||||
$name = "$testid $test";
|
||||
|
@ -309,9 +362,7 @@ foreach my $path (@plugins) {
|
|||
PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $subnet, $ip2, $hostname);
|
||||
PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $subnet, $ip3, $hostname);
|
||||
|
||||
eval {
|
||||
PVE::Network::SDN::Subnets::del_subnet($zone, $subnetid, $subnet);
|
||||
};
|
||||
eval { PVE::Network::SDN::Subnets::del_subnet($zone, $subnetid, $subnet); };
|
||||
|
||||
if ($@) {
|
||||
fail("$name : $@");
|
||||
|
@ -326,4 +377,3 @@ foreach my $path (@plugins) {
|
|||
|
||||
done_testing();
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ $Data::Dumper::Sortkeys = 1;
|
|||
|
||||
sub read_sdn_config {
|
||||
my ($file) = @_;
|
||||
|
||||
# Read structure back in again
|
||||
open my $in, '<', $file or die $!;
|
||||
my $sdn_config;
|
||||
|
@ -32,7 +33,6 @@ sub read_sdn_config {
|
|||
return $sdn_config;
|
||||
}
|
||||
|
||||
|
||||
my @plugins = read_dir('./vnets/', prefix => 1);
|
||||
|
||||
foreach my $path (@plugins) {
|
||||
|
@ -69,7 +69,7 @@ foreach my $path (@plugins) {
|
|||
},
|
||||
add_dns_record => sub {
|
||||
return;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
my $js = JSON->new;
|
||||
|
@ -80,7 +80,8 @@ foreach my $path (@plugins) {
|
|||
my $subnets = $sdn_config->{subnets}->{ids};
|
||||
|
||||
my $subnetid = (sort keys %{$subnets})[0];
|
||||
my $subnet = PVE::Network::SDN::Subnets::sdn_subnets_config($sdn_config->{subnets}, $subnetid, 1);
|
||||
my $subnet =
|
||||
PVE::Network::SDN::Subnets::sdn_subnets_config($sdn_config->{subnets}, $subnetid, 1);
|
||||
my $subnet_cidr = $subnet->{cidr};
|
||||
my $iplist = NetAddr::IP->new($subnet_cidr);
|
||||
my $mask = $iplist->masklen();
|
||||
|
@ -99,7 +100,8 @@ foreach my $path (@plugins) {
|
|||
my $cidr_outofrange = '8.8.8.8/8';
|
||||
|
||||
my $subnetid2 = (sort keys %{$subnets})[1];
|
||||
my $subnet2 = PVE::Network::SDN::Subnets::sdn_subnets_config($sdn_config->{subnets}, $subnetid2, 1);
|
||||
my $subnet2 =
|
||||
PVE::Network::SDN::Subnets::sdn_subnets_config($sdn_config->{subnets}, $subnetid2, 1);
|
||||
my $subnet2_cidr = $subnet2->{cidr};
|
||||
my $iplist2 = NetAddr::IP->new($subnet2_cidr);
|
||||
$iplist2++;
|
||||
|
@ -127,7 +129,7 @@ foreach my $path (@plugins) {
|
|||
write_db => sub {
|
||||
my ($cfg) = @_;
|
||||
$ipamdb = $cfg;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -148,9 +150,7 @@ foreach my $path (@plugins) {
|
|||
my $result = undef;
|
||||
my $expected = '';
|
||||
|
||||
eval {
|
||||
PVE::Network::SDN::Vnets::add_cidr($vnetid, $cidr1, $hostname, $mac, $description);
|
||||
};
|
||||
eval { PVE::Network::SDN::Vnets::add_cidr($vnetid, $cidr1, $hostname, $mac, $description); };
|
||||
|
||||
if ($@) {
|
||||
fail("$name : $@");
|
||||
|
@ -164,9 +164,7 @@ foreach my $path (@plugins) {
|
|||
$result = undef;
|
||||
$expected = '';
|
||||
|
||||
eval {
|
||||
PVE::Network::SDN::Vnets::add_cidr($vnetid, $cidr1, $hostname, $mac, $description);
|
||||
};
|
||||
eval { PVE::Network::SDN::Vnets::add_cidr($vnetid, $cidr1, $hostname, $mac, $description); };
|
||||
|
||||
if ($@) {
|
||||
is(undef, undef, $name);
|
||||
|
@ -182,9 +180,7 @@ foreach my $path (@plugins) {
|
|||
$result = undef;
|
||||
$expected = '';
|
||||
|
||||
eval {
|
||||
PVE::Network::SDN::Vnets::add_cidr($vnetid, $cidr2, $hostname, $mac, $description);
|
||||
};
|
||||
eval { PVE::Network::SDN::Vnets::add_cidr($vnetid, $cidr2, $hostname, $mac, $description); };
|
||||
|
||||
if ($@) {
|
||||
fail("$name : $@");
|
||||
|
@ -199,7 +195,8 @@ foreach my $path (@plugins) {
|
|||
$expected = '';
|
||||
|
||||
eval {
|
||||
PVE::Network::SDN::Vnets::add_cidr($vnetid, $cidr_outofrange, $hostname, $mac, $description);
|
||||
PVE::Network::SDN::Vnets::add_cidr($vnetid, $cidr_outofrange, $hostname, $mac,
|
||||
$description);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
|
@ -214,9 +211,7 @@ foreach my $path (@plugins) {
|
|||
$result = undef;
|
||||
$expected = '';
|
||||
|
||||
eval {
|
||||
PVE::Network::SDN::Vnets::add_cidr($vnetid, $cidr4, $hostname, $mac, $description);
|
||||
};
|
||||
eval { PVE::Network::SDN::Vnets::add_cidr($vnetid, $cidr4, $hostname, $mac, $description); };
|
||||
|
||||
if ($@) {
|
||||
fail("$name : $@");
|
||||
|
@ -224,14 +219,14 @@ foreach my $path (@plugins) {
|
|||
is(undef, undef, $name);
|
||||
}
|
||||
|
||||
|
||||
$test = "find_next_free_cidr_in_second_subnet ($cidr3)";
|
||||
$name = "$testid $test";
|
||||
$result = undef;
|
||||
$expected = $ipam ? $cidr3 : undef;
|
||||
|
||||
eval {
|
||||
$result = PVE::Network::SDN::Vnets::add_next_free_cidr($vnetid, $hostname, $mac, $description);
|
||||
$result =
|
||||
PVE::Network::SDN::Vnets::add_next_free_cidr($vnetid, $hostname, $mac, $description);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
|
@ -240,15 +235,12 @@ foreach my $path (@plugins) {
|
|||
is($result, $expected, $name);
|
||||
}
|
||||
|
||||
|
||||
$test = "del_cidr $cidr1";
|
||||
$name = "$testid $test";
|
||||
$result = undef;
|
||||
$expected = undef;
|
||||
|
||||
eval {
|
||||
$result = PVE::Network::SDN::Vnets::del_cidr($vnetid, $cidr1, $hostname);
|
||||
};
|
||||
eval { $result = PVE::Network::SDN::Vnets::del_cidr($vnetid, $cidr1, $hostname); };
|
||||
|
||||
if ($@) {
|
||||
fail("$name : $@");
|
||||
|
@ -261,9 +253,7 @@ foreach my $path (@plugins) {
|
|||
$result = undef;
|
||||
$expected = undef;
|
||||
|
||||
eval {
|
||||
$result = PVE::Network::SDN::Vnets::del_cidr($vnetid, $cidr3, $hostname);
|
||||
};
|
||||
eval { $result = PVE::Network::SDN::Vnets::del_cidr($vnetid, $cidr3, $hostname); };
|
||||
|
||||
if ($@) {
|
||||
fail("$name : $@");
|
||||
|
@ -276,9 +266,7 @@ foreach my $path (@plugins) {
|
|||
$result = undef;
|
||||
$expected = undef;
|
||||
|
||||
eval {
|
||||
$result = PVE::Network::SDN::Vnets::del_cidr($vnetid, $cidr1, $hostname);
|
||||
};
|
||||
eval { $result = PVE::Network::SDN::Vnets::del_cidr($vnetid, $cidr1, $hostname); };
|
||||
|
||||
if ($@) {
|
||||
is(undef, undef, $name);
|
||||
|
@ -293,9 +281,7 @@ foreach my $path (@plugins) {
|
|||
$result = undef;
|
||||
$expected = undef;
|
||||
|
||||
eval {
|
||||
$result = PVE::Network::SDN::Vnets::del_cidr($vnetid, $cidr_outofrange, $hostname);
|
||||
};
|
||||
eval { $result = PVE::Network::SDN::Vnets::del_cidr($vnetid, $cidr_outofrange, $hostname); };
|
||||
|
||||
if ($@) {
|
||||
is(undef, undef, $name);
|
||||
|
@ -309,7 +295,8 @@ foreach my $path (@plugins) {
|
|||
$expected = $ipam ? $cidr1 : undef;
|
||||
|
||||
eval {
|
||||
$result = PVE::Network::SDN::Vnets::add_next_free_cidr($vnetid, $hostname, $mac, $description);
|
||||
$result =
|
||||
PVE::Network::SDN::Vnets::add_next_free_cidr($vnetid, $hostname, $mac, $description);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
|
@ -324,7 +311,8 @@ foreach my $path (@plugins) {
|
|||
$expected = undef;
|
||||
|
||||
eval {
|
||||
$result = PVE::Network::SDN::Vnets::update_cidr($vnetid, $cidr1, $hostname, $hostname, $mac, $description);
|
||||
$result = PVE::Network::SDN::Vnets::update_cidr($vnetid, $cidr1, $hostname, $hostname, $mac,
|
||||
$description);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
|
@ -339,7 +327,8 @@ foreach my $path (@plugins) {
|
|||
$expected = undef;
|
||||
|
||||
eval {
|
||||
$result = PVE::Network::SDN::Vnets::update_cidr($vnetid, $cidr1, $hostname, $hostname, $mac, $description);
|
||||
$result = PVE::Network::SDN::Vnets::update_cidr($vnetid, $cidr1, $hostname, $hostname, $mac,
|
||||
$description);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
|
@ -352,4 +341,3 @@ foreach my $path (@plugins) {
|
|||
|
||||
done_testing();
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ sub read_sdn_config {
|
|||
return $sdn_config;
|
||||
}
|
||||
|
||||
|
||||
my @tests = grep { -d } glob './zones/*/*';
|
||||
|
||||
foreach my $test (@tests) {
|
||||
|
@ -78,7 +77,7 @@ foreach my $test (@tests) {
|
|||
},
|
||||
find_bridge => sub {
|
||||
return;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
my $sdn_module = Test::MockModule->new("PVE::Network::SDN");
|
||||
|
@ -106,7 +105,8 @@ foreach my $test (@tests) {
|
|||
|
||||
eval {
|
||||
my $config = PVE::Network::SDN::Controllers::generate_controller_config();
|
||||
$controller_rawconfig = PVE::Network::SDN::Controllers::generate_controller_rawconfig($config);
|
||||
$controller_rawconfig =
|
||||
PVE::Network::SDN::Controllers::generate_controller_rawconfig($config);
|
||||
};
|
||||
if (my $err = $@) {
|
||||
diag("got unexpected error - $err");
|
||||
|
@ -119,4 +119,3 @@ foreach my $test (@tests) {
|
|||
|
||||
done_testing();
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue