pf-tools/pf-tools: test fstab generation file for nsf and tmpfs
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Fri Dec 12 12:55:29 UTC 2014
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/08b40c0e43f3
changeset: 1381:08b40c0e43f3
user: shad
date: Fri Dec 12 13:55:26 2014 +0100
description:
test fstab generation file for nsf and tmpfs
diffstat:
t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/update-cbv4-spawn | 6 +
t/13.conf.t | 8 +
t/14.addmount.t | 110 ++++++++++
3 files changed, 124 insertions(+), 0 deletions(-)
diffs (167 lines):
diff -r c345a5c87907 -r 08b40c0e43f3 t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/update-cbv4-spawn
--- a/t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/update-cbv4-spawn Fri Dec 12 13:14:34 2014 +0100
+++ b/t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/update-cbv4-spawn Fri Dec 12 13:55:26 2014 +0100
@@ -21,6 +21,12 @@
fstype = nfs
options = rw,nodev,tcp,nosuid,noexec,hard,intr,bg
+[/var/tmp/php-sessions]
+ action = addmount
+ source = tmpfs
+ fstype = tmpfs
+ options = size=1G
+ mode = 0755
#
# Apache config
diff -r c345a5c87907 -r 08b40c0e43f3 t/13.conf.t
--- a/t/13.conf.t Fri Dec 12 13:14:34 2014 +0100
+++ b/t/13.conf.t Fri Dec 12 13:55:26 2014 +0100
@@ -1966,6 +1966,13 @@
'action' => 'addmount',
'fstype' => 'nfs',
},
+ '/var/tmp/php-sessions' => {
+ 'source' => 'tmpfs',
+ 'options' => 'size=1G',
+ 'action' => 'addmount',
+ 'fstype' => 'tmpfs',
+ 'mode' => '0755',
+ },
'__sections_order' => [
'pf-tools',
'apt-utils',
@@ -1975,6 +1982,7 @@
'/usr/local/sbin/update-apt-ftparchive',
'/distrib',
'/var/lib/cvs/repository',
+ '/var/tmp/php-sessions',
'/etc/apache2/ports.conf',
'/etc/apache2/sites-available/default',
'/var/www/debian',
diff -r c345a5c87907 -r 08b40c0e43f3 t/14.addmount.t
--- a/t/14.addmount.t Fri Dec 12 13:14:34 2014 +0100
+++ b/t/14.addmount.t Fri Dec 12 13:55:26 2014 +0100
@@ -14,6 +14,7 @@
use Test::More qw( no_plan );
use PFTools::Conf;
+use PFTools::Disk;
use PFTools::Structqueries;
use PFTools::Update::ADDMOUNT;
@@ -118,5 +119,114 @@
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