summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
-rw-r--r--plugins/t/check_disk.t27
1 files changed, 21 insertions, 6 deletions
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index dd4fcee4..50d2e6d5 100644
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
@@ -24,7 +24,7 @@ my $mountpoint2_valid = getTestParameter( "NP_MOUNTPOINT2_VALID", "Path to anoth
24if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") { 24if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") {
25 plan skip_all => "Need 2 mountpoints to test"; 25 plan skip_all => "Need 2 mountpoints to test";
26} else { 26} else {
27 plan tests => 56; 27 plan tests => 57;
28} 28}
29 29
30$result = NPTest->testCmd( 30$result = NPTest->testCmd(
@@ -36,6 +36,12 @@ $_ = $result->output;
36$c++ while /\(/g; # counts number of "(" - should be two 36$c++ while /\(/g; # counts number of "(" - should be two
37cmp_ok( $c, '==', 2, "Got two mountpoints in output"); 37cmp_ok( $c, '==', 2, "Got two mountpoints in output");
38 38
39
40# Get perf data
41# Should use Nagios::Plugin
42my @perf_data = sort(split(/ /, $result->perf_output));
43
44
39# Calculate avg_free free on mountpoint1 and mountpoint2 45# Calculate avg_free free on mountpoint1 and mountpoint2
40# because if you check in the middle, you should get different errors 46# because if you check in the middle, you should get different errors
41$_ = $result->output; 47$_ = $result->output;
@@ -63,7 +69,7 @@ my ($more_inode_free, $less_inode_free);
63if ($free_inode_on_mp1 > $free_inode_on_mp2) { 69if ($free_inode_on_mp1 > $free_inode_on_mp2) {
64 $more_inode_free = $mountpoint_valid; 70 $more_inode_free = $mountpoint_valid;
65 $less_inode_free = $mountpoint2_valid; 71 $less_inode_free = $mountpoint2_valid;
66} elsif ($free_on_mp1 < $free_on_mp2) { 72} elsif ($free_inode_on_mp1 < $free_inode_on_mp2) {
67 $more_inode_free = $mountpoint2_valid; 73 $more_inode_free = $mountpoint2_valid;
68 $less_inode_free = $mountpoint_valid; 74 $less_inode_free = $mountpoint_valid;
69} else { 75} else {
@@ -72,8 +78,15 @@ if ($free_inode_on_mp1 > $free_inode_on_mp2) {
72 78
73 79
74 80
75# Basic filesystem checks for sizes 81# Check when order of mount points are reversed, that perf data remains same
82$result = NPTest->testCmd(
83 "./check_disk -w 1% -c 1% -p $mountpoint2_valid -w 1% -c 1% -p $mountpoint_valid"
84 );
85@_ = sort(split(/ /, $result->perf_output));
86is_deeply( \@perf_data, \@_, "perf data for both filesystems same when reversed");
87
76 88
89# Basic filesystem checks for sizes
77$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free" ); 90$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free" );
78cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free"); 91cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free");
79like ( $result->output, $successOutput, "OK output" ); 92like ( $result->output, $successOutput, "OK output" );
@@ -116,9 +129,11 @@ $result = NPTest->testCmd(
116 "./check_disk -e -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free" 129 "./check_disk -e -w $avg_free% -c 0% -p $less_free -w $avg_free% -c $avg_free% -p $more_free"
117 ); 130 );
118isnt( $result->output, $all_disks, "-e gives different output"); 131isnt( $result->output, $all_disks, "-e gives different output");
119like( $result->output, qr/$less_free/, "Found problem $less_free"); 132
120unlike( $result->only_output, qr/$more_free/, "Has ignored $more_free as not a problem"); 133# Need spaces around filesystem name in case less_free and more_free are nested
121like( $result->perf_output, qr/$more_free/, "But $more_free is still in perf data"); 134like( $result->output, qr/ $less_free /, "Found problem $less_free");
135unlike( $result->only_output, qr/ $more_free /, "Has ignored $more_free as not a problem");
136like( $result->perf_output, qr/ $more_free=/, "But $more_free is still in perf data");
122 137
123$result = NPTest->testCmd( 138$result = NPTest->testCmd(
124 "./check_disk -w $avg_free% -c 0% -p $more_free" 139 "./check_disk -w $avg_free% -c 0% -p $more_free"