12 use PVE
::Network
::SDN
;
13 use PVE
::Network
::SDN
::Zones
;
14 use PVE
::Network
::SDN
::Controllers
;
20 # Read structure back in again
21 open my $in, '<', $file or die $!;
24 local $/; # slurp mode
25 $sdn_config = eval <$in>;
32 my @tests = grep { -d
} glob './zones/*/*';
34 foreach my $test (@tests) {
36 my $sdn_config = read_sdn_config
("./$test/sdn_config");
38 open(my $fh1, '<', "./$test/interfaces") or die "can't read interfaces file - $!";
39 my $interfaces_config = PVE
::INotify
::__read_etc_network_interfaces
($fh1, undef, undef);
42 my $pve_common_inotify;
43 $pve_common_inotify = Test
::MockModule-
>new('PVE::INotify');
44 $pve_common_inotify->mock(
49 return $interfaces_config;
54 $pve_sdn_subnets = Test
::MockModule-
>new('PVE::Network::SDN::Subnets');
55 $pve_sdn_subnets->mock(
57 return $sdn_config->{subnets
};
61 my $pve_sdn_zones_plugin;
62 $pve_sdn_zones_plugin = Test
::MockModule-
>new('PVE::Network::SDN::Zones::Plugin');
63 $pve_sdn_zones_plugin->mock(
64 get_local_route_ip
=> sub {
65 my $outiface = "vmbr0";
66 my $outip = $interfaces_config->{ifaces
}->{$outiface}->{address
};
67 return ($outip, $outiface);
70 return $interfaces_config->{ifaces
}->{vmbr0
}->{'bridge_vlan_aware'};
73 return 1 if $interfaces_config->{ifaces
}->{vmbr0
}->{'type'} eq 'OVSBridge';
75 get_bridge_ifaces
=> sub {
83 my $sdn_module = Test
::MockModule-
>new("PVE::Network::SDN");
85 running_config
=> sub {
91 my $expected = read_file
("./$test/expected_sdn_interfaces");
93 my $result = eval { PVE
::Network
::SDN
::Zones
::generate_etc_network_config
() };
96 diag
("got unexpected error - $err");
99 is($result, $expected, $name);
102 if ($sdn_config->{controllers
}) {
103 my $expected = read_file
("./$test/expected_controller_config");
104 my $controller_rawconfig = "";
107 my $config = PVE
::Network
::SDN
::Controllers
::generate_controller_config
();
108 $controller_rawconfig =
109 PVE
::Network
::SDN
::Controllers
::generate_controller_rawconfig
($config);
112 diag
("got unexpected error - $err");
115 is($controller_rawconfig, $expected, $name);