pf-tools/pf-tools: reanme test files

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Mon Dec 15 09:13:12 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/f28563e8d1d4
changeset: 1382:f28563e8d1d4
user:      melkor <melkor at sitadelle.com>
date:      Mon Dec 15 10:13:02 2014 +0100
description:
reanme test files

diffstat:

 t/14.addmount.t |  232 --------------------------------------------------------
 t/15.addfile.t  |  128 ------------------------------
 t/30.addfile.t  |  128 ++++++++++++++++++++++++++++++
 t/31.addmount.t |  232 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 360 insertions(+), 360 deletions(-)

diffs (736 lines):

diff -r 08b40c0e43f3 -r f28563e8d1d4 t/14.addmount.t
--- a/t/14.addmount.t	Fri Dec 12 13:55:26 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,232 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use Cwd;
-use English qw( -no_match_vars );    # Avoids regex performance penalty
-use File::Copy;
-use File::Path qw( make_path remove_tree );
-use Hash::Merge::Simple qw( clone_merge merge );
-use IO::File;
-use Sys::Hostname;
-use Test::Exception;
-use Test::More qw( no_plan );
-
-use PFTools::Conf;
-use PFTools::Disk;
-use PFTools::Structqueries;
-use PFTools::Update::ADDMOUNT;
-
-########################################################################
-
-my $test_config_file = 't/13.conf.cfg1/etc/pf-tools.1.conf';
-my $test_pf_config
-    = init_pf_config($test_config_file);    # already tested OK above
-
-my $cwd             = getcwd;
-my $test_config_dir = qq{$cwd/t/13.conf.cfg1};
-my $test_hostname   = q{cbv4-spawn00};
-my $test_hash_subst
-    = init_subst( $test_hostname, undef, $test_pf_config, 'private' );
-
-# bypass cvs/svn/whatever for the moment
-unlink q{/tmp/pf-test/var/lib/cvsguest/config};
-make_path(q{/tmp/pf-test/var/lib/cvsguest});
-symlink qq{$cwd/t/13.conf.cfg1/config-export},
-    q{/tmp/pf-test/var/lib/cvsguest/config}
-    or diag qq{symlink: $OS_ERROR};
-
-my $parsed_configuration
-    = init_global_netconfig( q{COMMON:private-network}, $test_hash_subst );
-
-#    print Dumper($parsed_configuration);
-########################################################################
-note('Testing PFTools::Update::ADDMOUNT');
-can_ok( 'PFTools::Update::ADDMOUNT', qw( __get_ip_host_from_global ) );
-
-my $global_config = $parsed_configuration;
-my ( $result, $expected_result);
-
-$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'cbv4-spawn00', $global_config);
-$expected_result = q{10.1.167.0};
-
-is $result, $expected_result
-    => q{get ip of single site service machine on default network}
-        or diag explain $result;
-
-$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'cbv4-spawn00.vlan-systeme.private', $global_config);
-$expected_result = q{10.1.167.0};
-
-is $result, $expected_result
-    => q{get ip of single site service machine on specified default network}
-        or diag explain $result;
-
-$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'cbv4-spawn00.vlan-pfds-int.private', $global_config);
-$expected_result = q{10.2.167.0};
-
-is $result, $expected_result
-    => q{get ip of single site service machine on specified other network}
-        or diag explain $result;
-
-$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'filer-all00', $global_config);
-$expected_result = q{10.1.2.10};
-
-is $result, $expected_result
-    => q{get ip of all site server on machine default network}
-        or diag explain $result;
-
-$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'filer-all00.vlan-systeme.private', $global_config);
-$expected_result = q{10.1.2.10};
-
-is $result, $expected_result
-    => q{get ip of all site server on specified default network}
-        or diag explain $result;
-
-$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'filer-several00', $global_config);
-$expected_result = q{10.1.2.20};
-
-is $result, $expected_result
-    => q{get ip of several site server on default network}
-        or diag explain $result;
-
-$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'filer-several00.vlan-systeme.private', $global_config);
-$expected_result = q{10.1.2.20};
-
-is $result, $expected_result
-    => q{get ip of several site server on specified default network}
-        or diag explain $result;
-
-$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'cbv4-pfds-filer00.vlan-systeme.private', $global_config);
-$expected_result = q{10.1.2.0};
-
-is $result, $expected_result
-    => q{get ip of single site server on default network}
-        or diag explain $result;
-
-$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'cbv4-pfds-filer00.vlan-systeme.private', $global_config);
-$expected_result = q{10.1.2.0};
-
-is $result, $expected_result
-    => q{get ip of single site server on specified default network}
-        or diag explain $result;
-
-$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( '10.128.1.2', $global_config);
-$expected_result = q{10.128.1.2};
-
-is $result, $expected_result
-    => q{Return raw input ip}
-        or diag explain $result;
-
-#TODO test other mount like tmpfs by checking fstab resulted file
-########################################################################
-note('Testing fstab generation');
-
-my $ref_section = {
-    'source'  => 'cbv4-pfds-filer00.vlan-systeme.private:/vol/volvcs/cvs',
-    'options' => 'rw,nodev,tcp,nosuid,noexec,hard,intr,bg',
-    'action'  => 'addmount',
-    'fstype'  => 'nfs',
-};
-
-$result = PFTools::Update::ADDMOUNT::__build_fstab_entry_from_config( {
-    'dest'          => '/var/lib/cvs/repository',
-    'global_config' => $global_config,
-    'ref_section'   => $ref_section,
-});
-
-foreach my $key ( 'source', 'dest', 'fstype', 'options', 'dump', 'pass' ) {
-    $result->{$key} = $result->{$key} || 0;
-}
-
-$expected_result = {
-          'dest' => '/var/lib/cvs/repository',
-          'fstype' => 'nfs',
-          'source' => '10.1.2.0:/vol/volvcs/cvs',
-          'options' => 'bg,hard,intr,nodev,noexec,nosuid,rw,tcp',
-          'action' => 'addmount',
-          'pass' => 0,
-          'dump' => 0,
-        };
-
-is_deeply $result, $expected_result
-    => q{built fstab entry from handmade conf}
-        or diag explain $result;
-
-my $machine_parsed_configuration = get_config_for_hostname_on_site(
-    'cbv4-spawn00', 'cbv4-pfds', $test_hash_subst, $global_config,
-    $test_pf_config
-);
-
-
-my $dest = q{/var/lib/cvs/repository};
-$result = PFTools::Update::ADDMOUNT::__build_fstab_entry_from_config({
-    'dest'          => $dest,
-    'global_config' => $global_config,
-    'ref_section'   => $machine_parsed_configuration->{$dest}
-});
-
-foreach my $key ( 'source', 'dest', 'fstype', 'options', 'dump', 'pass' ) {
-    $result->{$key} = $result->{$key} || 0;
-}
-
-is_deeply $result, $expected_result
-    => q{built fstab entry from generated conf (nfs)}
-        or diag explain $result;
-my $fstab_result = build_fstab_from_structure({ $dest => $result, '__mnt_order' => [$dest] });
-
-$expected_result = [
-  qq{###################################################},
-  qq{# Fstab generated by build_fstab_from_structure},
-  qq{#\n},
-  qq{10.1.2.0:/vol/volvcs/cvs\t/var/lib/cvs/repository\tnfs\tbg,hard,intr,nodev,noexec,nosuid,rw,tcp\t0\t0},
-  qq{},
-];
-
-is_deeply $fstab_result, $expected_result
-    => q{built fstab file from generated conf (nfs)}
-        or diag explain $result;
-
-
-my $dest = q{/var/tmp/php-sessions};
-$result = PFTools::Update::ADDMOUNT::__build_fstab_entry_from_config({
-    'dest'          => $dest,
-    'global_config' => $global_config,
-    'ref_section'   => $machine_parsed_configuration->{$dest}
-});
-
-foreach my $key ( 'source', 'dest', 'fstype', 'options', 'dump', 'pass' ) {
-    $result->{$key} = $result->{$key} || 0;
-}
-
-$expected_result = {
-          'mode' => '0755',
-          'pass' => 0,
-          'dest' => '/var/tmp/php-sessions',
-          'fstype' => 'tmpfs',
-          'source' => 'tmpfs',
-          'action' => 'addmount',
-          'dump' => 0,
-          'options' => 'size=1G'
-        };
-
-is_deeply $result, $expected_result
-    => q{built fstab entry from generated conf (tmpfs)}
-        or diag explain $result;
-my $fstab_result = build_fstab_from_structure({ $dest => $result, '__mnt_order' => [$dest] });
-
-$expected_result = [
-  qq{###################################################},
-  qq{# Fstab generated by build_fstab_from_structure},
-  qq{#\n},
-  qq{tmpfs\t/var/tmp/php-sessions\ttmpfs\tsize=1G\t0\t0},
-  qq{},
-];
-
-is_deeply $fstab_result, $expected_result
-    => q{built fstab file from generated conf (tmpfs)}
-        or diag explain $result;
-
-use Data::Dumper;
-#print Dumper($fstab_result);
-__END__
diff -r 08b40c0e43f3 -r f28563e8d1d4 t/15.addfile.t
--- a/t/15.addfile.t	Fri Dec 12 13:55:26 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-#!perl
-
-use strict;
-use warnings;
-
-use Cwd;
-use Data::Dumper;
-use English qw( -no_match_vars );    # Avoids regex performance penalty
-use File::Copy;
-use File::Path qw( make_path remove_tree );
-use Hash::Merge::Simple qw( clone_merge merge );
-use IO::File;
-use Sys::Hostname;
-use Test::Exception;
-use Test::More qw( no_plan );
-
-use PFTools::Conf;
-use PFTools::Structqueries;
-use PFTools::Update::ADDFILE;
-
-########################################################################
-
-my $test_config_file = 't/13.conf.cfg1/etc/pf-tools.1.conf';
-my $test_pf_config
-    = init_pf_config($test_config_file);    # already tested OK above
-
-my $cwd             = getcwd;
-my $test_config_dir = qq{$cwd/t/13.conf.cfg1};
-my $test_hostname   = q{cbv4-spawn00};
-my $test_hash_subst
-    = init_subst( $test_hostname, undef, $test_pf_config, 'private' );
-
-# bypass cvs/svn/whatever for the moment
-unlink q{/tmp/pf-test/var/lib/cvsguest/config};
-make_path(q{/tmp/pf-test/var/lib/cvsguest});
-symlink qq{$cwd/t/13.conf.cfg1/config-export},
-    q{/tmp/pf-test/var/lib/cvsguest/config}
-    or diag qq{symlink: $OS_ERROR};
-
-my $parsed_configuration
-    = init_global_netconfig( q{COMMON:private-network}, $test_hash_subst );
-
-#    print Dumper($parsed_configuration);
-########################################################################
-note('Testing PFTools::Update::ADDFILE');
-
-can_ok( 'PFTools::Update::ADDFILE', qw( __find_source action_exec ) );
-
-my $global_config = $parsed_configuration;
-my ( $result, $expected_result);
-
-
-my $rh_option = {
-    host    => 'cbv4-spawn00',
-    simul   => 1,
-};
-
-my $machine_parsed_configuration = get_config_for_hostname_on_site(
-    'cbv4-spawn00', 'cbv4-pfds', $test_hash_subst, $global_config,
-    $test_pf_config
-);
-
-#print Dumper $machine_parsed_configuration;
-
-$expected_result = q{/tmp/pf-test/var/lib/cvsguest/config/FILE/spawn/etc/apt/apt-ftp-ubuntu.conf};
-$result = PFTools::Update::ADDFILE::__find_source($rh_option, $test_hash_subst, [ q{/etc/apt/apt-ftp-ubuntu.conf} ] );
-
-is $result, $expected_result
-    => q{get '/etc/apt/apt-ftp-ubuntu.conf' in 'FILE/spawn' directory}
-        or diag explain $result;
-
-$test_hash_subst->{SECTIONNAME} = q{/etc/apt/apt-ftp-ubuntu.conf};
-
-$result = PFTools::Update::ADDFILE::__find_source($rh_option, $test_hash_subst);
-
-delete $test_hash_subst->{SECTIONNAME};
-
-is $result, $expected_result
-    => q{get '/etc/apt/apt-ftp-ubuntu.conf' based on %SECTIONNAME% key in 'FILE/spawn' directory}
-        or diag explain $result;
-
-eval {
-    action_exec(
-        $machine_parsed_configuration,
-        q{/etc/apt/apt-ftp-ubuntu.conf},
-        $rh_option,
-        $test_hash_subst,
-        $global_config
-    );
-};
-
-delete $machine_parsed_configuration->{q{/etc/apt/apt-ftp-ubuntu.conf}}{source};
-eval {
-    action_exec(
-        $machine_parsed_configuration,
-        q{/etc/apt/apt-ftp-ubuntu.conf},
-        $rh_option,
-        $test_hash_subst,
-        $global_config
-    );
-};
-
-$expected_result = $test_hash_subst->{SOURCE};
-
-is $result, $expected_result
-    => q{get '/etc/apt/apt-ftp-ubuntu.conf' in 'FILE/spawn' directory without source defined}
-        or diag explain $result;
-
-delete  $test_hash_subst->{SOURCE};
- $machine_parsed_configuration->{q{/etc/apt/apt-ftp-ubuntu.conf}}{source} = 'AUTO:/etc/apt/apt-ftp-ubuntu.conf';
-
-eval {
-    action_exec(
-        $machine_parsed_configuration,
-        q{/etc/apt/apt-ftp-ubuntu.conf},
-        $rh_option,
-        $test_hash_subst,
-        $global_config
-    );
-};
-
-$expected_result = $test_hash_subst->{SOURCE};
-
-is $result, $expected_result
-    => q{get '/etc/apt/apt-ftp-ubuntu.conf' in 'FILE/spawn' directory with AUTO shortcut}
-        or diag explain $result;
-
-__END__
diff -r 08b40c0e43f3 -r f28563e8d1d4 t/30.addfile.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/30.addfile.t	Mon Dec 15 10:13:02 2014 +0100
@@ -0,0 +1,128 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Cwd;
+use Data::Dumper;
+use English qw( -no_match_vars );    # Avoids regex performance penalty
+use File::Copy;
+use File::Path qw( make_path remove_tree );
+use Hash::Merge::Simple qw( clone_merge merge );
+use IO::File;
+use Sys::Hostname;
+use Test::Exception;
+use Test::More qw( no_plan );
+
+use PFTools::Conf;
+use PFTools::Structqueries;
+use PFTools::Update::ADDFILE;
+
+########################################################################
+
+my $test_config_file = 't/13.conf.cfg1/etc/pf-tools.1.conf';
+my $test_pf_config
+    = init_pf_config($test_config_file);    # already tested OK above
+
+my $cwd             = getcwd;
+my $test_config_dir = qq{$cwd/t/13.conf.cfg1};
+my $test_hostname   = q{cbv4-spawn00};
+my $test_hash_subst
+    = init_subst( $test_hostname, undef, $test_pf_config, 'private' );
+
+# bypass cvs/svn/whatever for the moment
+unlink q{/tmp/pf-test/var/lib/cvsguest/config};
+make_path(q{/tmp/pf-test/var/lib/cvsguest});
+symlink qq{$cwd/t/13.conf.cfg1/config-export},
+    q{/tmp/pf-test/var/lib/cvsguest/config}
+    or diag qq{symlink: $OS_ERROR};
+
+my $parsed_configuration
+    = init_global_netconfig( q{COMMON:private-network}, $test_hash_subst );
+
+#    print Dumper($parsed_configuration);
+########################################################################
+note('Testing PFTools::Update::ADDFILE');
+
+can_ok( 'PFTools::Update::ADDFILE', qw( __find_source action_exec ) );
+
+my $global_config = $parsed_configuration;
+my ( $result, $expected_result);
+
+
+my $rh_option = {
+    host    => 'cbv4-spawn00',
+    simul   => 1,
+};
+
+my $machine_parsed_configuration = get_config_for_hostname_on_site(
+    'cbv4-spawn00', 'cbv4-pfds', $test_hash_subst, $global_config,
+    $test_pf_config
+);
+
+print Dumper $machine_parsed_configuration;
+
+$expected_result = q{/tmp/pf-test/var/lib/cvsguest/config/FILE/spawn/etc/apt/apt-ftp-ubuntu.conf};
+$result = PFTools::Update::ADDFILE::__find_source($rh_option, $test_hash_subst, [ q{/etc/apt/apt-ftp-ubuntu.conf} ] );
+
+is $result, $expected_result
+    => q{get '/etc/apt/apt-ftp-ubuntu.conf' in 'FILE/spawn' directory}
+        or diag explain $result;
+
+$test_hash_subst->{SECTIONNAME} = q{/etc/apt/apt-ftp-ubuntu.conf};
+
+$result = PFTools::Update::ADDFILE::__find_source($rh_option, $test_hash_subst);
+
+delete $test_hash_subst->{SECTIONNAME};
+
+is $result, $expected_result
+    => q{get '/etc/apt/apt-ftp-ubuntu.conf' based on %SECTIONNAME% key in 'FILE/spawn' directory}
+        or diag explain $result;
+
+eval {
+    action_exec(
+        $machine_parsed_configuration,
+        q{/etc/apt/apt-ftp-ubuntu.conf},
+        $rh_option,
+        $test_hash_subst,
+        $global_config
+    );
+};
+
+delete $machine_parsed_configuration->{q{/etc/apt/apt-ftp-ubuntu.conf}}{source};
+eval {
+    action_exec(
+        $machine_parsed_configuration,
+        q{/etc/apt/apt-ftp-ubuntu.conf},
+        $rh_option,
+        $test_hash_subst,
+        $global_config
+    );
+};
+
+$expected_result = $test_hash_subst->{SOURCE};
+
+is $result, $expected_result
+    => q{get '/etc/apt/apt-ftp-ubuntu.conf' in 'FILE/spawn' directory without source defined}
+        or diag explain $result;
+
+delete  $test_hash_subst->{SOURCE};
+ $machine_parsed_configuration->{q{/etc/apt/apt-ftp-ubuntu.conf}}{source} = 'AUTO:/etc/apt/apt-ftp-ubuntu.conf';
+
+eval {
+    action_exec(
+        $machine_parsed_configuration,
+        q{/etc/apt/apt-ftp-ubuntu.conf},
+        $rh_option,
+        $test_hash_subst,
+        $global_config
+    );
+};
+
+$expected_result = $test_hash_subst->{SOURCE};
+
+is $result, $expected_result
+    => q{get '/etc/apt/apt-ftp-ubuntu.conf' in 'FILE/spawn' directory with AUTO shortcut}
+        or diag explain $result;
+
+__END__
diff -r 08b40c0e43f3 -r f28563e8d1d4 t/31.addmount.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/31.addmount.t	Mon Dec 15 10:13:02 2014 +0100
@@ -0,0 +1,232 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Cwd;
+use English qw( -no_match_vars );    # Avoids regex performance penalty
+use File::Copy;
+use File::Path qw( make_path remove_tree );
+use Hash::Merge::Simple qw( clone_merge merge );
+use IO::File;
+use Sys::Hostname;
+use Test::Exception;
+use Test::More qw( no_plan );
+
+use PFTools::Conf;
+use PFTools::Disk;
+use PFTools::Structqueries;
+use PFTools::Update::ADDMOUNT;
+
+########################################################################
+
+my $test_config_file = 't/13.conf.cfg1/etc/pf-tools.1.conf';
+my $test_pf_config
+    = init_pf_config($test_config_file);    # already tested OK above
+
+my $cwd             = getcwd;
+my $test_config_dir = qq{$cwd/t/13.conf.cfg1};
+my $test_hostname   = q{cbv4-spawn00};
+my $test_hash_subst
+    = init_subst( $test_hostname, undef, $test_pf_config, 'private' );
+
+# bypass cvs/svn/whatever for the moment
+unlink q{/tmp/pf-test/var/lib/cvsguest/config};
+make_path(q{/tmp/pf-test/var/lib/cvsguest});
+symlink qq{$cwd/t/13.conf.cfg1/config-export},
+    q{/tmp/pf-test/var/lib/cvsguest/config}
+    or diag qq{symlink: $OS_ERROR};
+
+my $parsed_configuration
+    = init_global_netconfig( q{COMMON:private-network}, $test_hash_subst );
+
+#    print Dumper($parsed_configuration);
+########################################################################
+note('Testing PFTools::Update::ADDMOUNT');
+can_ok( 'PFTools::Update::ADDMOUNT', qw( __get_ip_host_from_global ) );
+
+my $global_config = $parsed_configuration;
+my ( $result, $expected_result);
+
+$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'cbv4-spawn00', $global_config);
+$expected_result = q{10.1.167.0};
+
+is $result, $expected_result
+    => q{get ip of single site service machine on default network}
+        or diag explain $result;
+
+$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'cbv4-spawn00.vlan-systeme.private', $global_config);
+$expected_result = q{10.1.167.0};
+
+is $result, $expected_result
+    => q{get ip of single site service machine on specified default network}
+        or diag explain $result;
+
+$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'cbv4-spawn00.vlan-pfds-int.private', $global_config);
+$expected_result = q{10.2.167.0};
+
+is $result, $expected_result
+    => q{get ip of single site service machine on specified other network}
+        or diag explain $result;
+
+$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'filer-all00', $global_config);
+$expected_result = q{10.1.2.10};
+
+is $result, $expected_result
+    => q{get ip of all site server on machine default network}
+        or diag explain $result;
+
+$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'filer-all00.vlan-systeme.private', $global_config);
+$expected_result = q{10.1.2.10};
+
+is $result, $expected_result
+    => q{get ip of all site server on specified default network}
+        or diag explain $result;
+
+$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'filer-several00', $global_config);
+$expected_result = q{10.1.2.20};
+
+is $result, $expected_result
+    => q{get ip of several site server on default network}
+        or diag explain $result;
+
+$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'filer-several00.vlan-systeme.private', $global_config);
+$expected_result = q{10.1.2.20};
+
+is $result, $expected_result
+    => q{get ip of several site server on specified default network}
+        or diag explain $result;
+
+$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'cbv4-pfds-filer00.vlan-systeme.private', $global_config);
+$expected_result = q{10.1.2.0};
+
+is $result, $expected_result
+    => q{get ip of single site server on default network}
+        or diag explain $result;
+
+$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'cbv4-pfds-filer00.vlan-systeme.private', $global_config);
+$expected_result = q{10.1.2.0};
+
+is $result, $expected_result
+    => q{get ip of single site server on specified default network}
+        or diag explain $result;
+
+$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( '10.128.1.2', $global_config);
+$expected_result = q{10.128.1.2};
+
+is $result, $expected_result
+    => q{Return raw input ip}
+        or diag explain $result;
+
+#TODO test other mount like tmpfs by checking fstab resulted file
+########################################################################
+note('Testing fstab generation');
+
+my $ref_section = {
+    'source'  => 'cbv4-pfds-filer00.vlan-systeme.private:/vol/volvcs/cvs',
+    'options' => 'rw,nodev,tcp,nosuid,noexec,hard,intr,bg',
+    'action'  => 'addmount',
+    'fstype'  => 'nfs',
+};
+
+$result = PFTools::Update::ADDMOUNT::__build_fstab_entry_from_config( {
+    'dest'          => '/var/lib/cvs/repository',
+    'global_config' => $global_config,
+    'ref_section'   => $ref_section,
+});
+
+foreach my $key ( 'source', 'dest', 'fstype', 'options', 'dump', 'pass' ) {
+    $result->{$key} = $result->{$key} || 0;
+}
+
+$expected_result = {
+          'dest' => '/var/lib/cvs/repository',
+          'fstype' => 'nfs',
+          'source' => '10.1.2.0:/vol/volvcs/cvs',
+          'options' => 'bg,hard,intr,nodev,noexec,nosuid,rw,tcp',
+          'action' => 'addmount',
+          'pass' => 0,
+          'dump' => 0,
+        };
+
+is_deeply $result, $expected_result
+    => q{built fstab entry from handmade conf}
+        or diag explain $result;
+
+my $machine_parsed_configuration = get_config_for_hostname_on_site(
+    'cbv4-spawn00', 'cbv4-pfds', $test_hash_subst, $global_config,
+    $test_pf_config
+);
+
+
+my $dest = q{/var/lib/cvs/repository};
+$result = PFTools::Update::ADDMOUNT::__build_fstab_entry_from_config({
+    'dest'          => $dest,
+    'global_config' => $global_config,
+    'ref_section'   => $machine_parsed_configuration->{$dest}
+});
+
+foreach my $key ( 'source', 'dest', 'fstype', 'options', 'dump', 'pass' ) {
+    $result->{$key} = $result->{$key} || 0;
+}
+
+is_deeply $result, $expected_result
+    => q{built fstab entry from generated conf (nfs)}
+        or diag explain $result;
+my $fstab_result = build_fstab_from_structure({ $dest => $result, '__mnt_order' => [$dest] });
+
+$expected_result = [
+  qq{###################################################},
+  qq{# Fstab generated by build_fstab_from_structure},
+  qq{#\n},
+  qq{10.1.2.0:/vol/volvcs/cvs\t/var/lib/cvs/repository\tnfs\tbg,hard,intr,nodev,noexec,nosuid,rw,tcp\t0\t0},
+  qq{},
+];
+
+is_deeply $fstab_result, $expected_result
+    => q{built fstab file from generated conf (nfs)}
+        or diag explain $result;
+
+
+my $dest = q{/var/tmp/php-sessions};
+$result = PFTools::Update::ADDMOUNT::__build_fstab_entry_from_config({
+    'dest'          => $dest,
+    'global_config' => $global_config,
+    'ref_section'   => $machine_parsed_configuration->{$dest}
+});
+
+foreach my $key ( 'source', 'dest', 'fstype', 'options', 'dump', 'pass' ) {
+    $result->{$key} = $result->{$key} || 0;
+}
+
+$expected_result = {
+          'mode' => '0755',
+          'pass' => 0,
+          'dest' => '/var/tmp/php-sessions',
+          'fstype' => 'tmpfs',
+          'source' => 'tmpfs',
+          'action' => 'addmount',
+          'dump' => 0,
+          'options' => 'size=1G'
+        };
+
+is_deeply $result, $expected_result
+    => q{built fstab entry from generated conf (tmpfs)}
+        or diag explain $result;
+my $fstab_result = build_fstab_from_structure({ $dest => $result, '__mnt_order' => [$dest] });
+
+$expected_result = [
+  qq{###################################################},
+  qq{# Fstab generated by build_fstab_from_structure},
+  qq{#\n},
+  qq{tmpfs\t/var/tmp/php-sessions\ttmpfs\tsize=1G\t0\t0},
+  qq{},
+];
+
+is_deeply $fstab_result, $expected_result
+    => q{built fstab file from generated conf (tmpfs)}
+        or diag explain $result;
+
+use Data::Dumper;
+#print Dumper($fstab_result);
+__END__



More information about the pf-tools-commits mailing list