summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
-rw-r--r--plugins/t/check_disk.t37
1 files changed, 36 insertions, 1 deletions
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index 2c0802cc..2ec6cabb 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 => 61; 27 plan tests => 68;
28} 28}
29 29
30$result = NPTest->testCmd( 30$result = NPTest->testCmd(
@@ -111,6 +111,16 @@ like ( $result->output, $successOutput, "OK output" );
111like ( $result->only_output, qr/free space/, "Have free space text"); 111like ( $result->only_output, qr/free space/, "Have free space text");
112like ( $result->only_output, qr/$more_free/, "Have disk name in text"); 112like ( $result->only_output, qr/$more_free/, "Have disk name in text");
113 113
114$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free -p $less_free" );
115cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free and $less_free");
116$_ = $result->output;
117print $result->output."\n";
118my ($free_mb_on_mp1, $free_mb_on_mp2) = (m/(\d+) MB .* (\d+) MB /g);
119my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2;
120print "$free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2\n";
121
122
123
114$result = NPTest->testCmd( "./check_disk -e -w 1 -c 1 -p $more_free" ); 124$result = NPTest->testCmd( "./check_disk -e -w 1 -c 1 -p $more_free" );
115is( $result->only_output, "DISK OK", "No print out of disks with -e for OKs"); 125is( $result->only_output, "DISK OK", "No print out of disks with -e for OKs");
116 126
@@ -284,3 +294,28 @@ unlike( $result->perf_output, '/\/bob/', "perf data does not have /bob in it");
284 294
285$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p / -p /" ); 295$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p / -p /" );
286unlike( $result->output, '/ \/ .* \/ /', "Should not show same filesystem twice"); 296unlike( $result->output, '/ \/ .* \/ /', "Should not show same filesystem twice");
297
298# are partitions added if -C is given without path selection -p ?
299$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -C -w 0% -c 0% -p $mountpoint_valid" );
300like( $result->output, '/;.*;\|/', "-C selects partitions if -p is not given");
301
302# grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit
303$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all + 1) ." -c ". ($free_mb_on_all + 1) ."-g group -p $mountpoint_valid -p $mountpoint2_valid" );
304cmp_ok( $result->return_code, '==', 2, "grouping: exit crit if the sum of free megs on mp1+mp2 is less than warn/crit");
305
306# grouping: exit warning if the sum of free megs on mp1+mp2 is between -w and -c
307$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all + 1) ." -c ". ($free_mb_on_all - 1) ." -g group -p $mountpoint_valid -p $mountpoint2_valid" );
308cmp_ok( $result->return_code, '==', 1, "grouping: exit warning if the sum of free megs on mp1+mp2 is between -w and -c ");
309
310# grouping: exit ok if the sum of free megs on mp1+mp2 is more than warn/crit
311$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -g group -p $mountpoint_valid -p $mountpoint2_valid" );
312cmp_ok( $result->return_code, '==', 0, "grouping: exit ok if the sum of free megs on mp1+mp2 is more than warn/crit");
313
314# grouping: exit unknown if group name is given after -p
315$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" );
316cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname");
317
318# regex: exit unknown if given regex is not compileable
319$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" );
320cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compileable");
321