diff options
author | Bernd Arnold <wopfel@gmail.com> | 2018-06-03 16:51:43 +0200 |
---|---|---|
committer | Bernd Arnold <wopfel@gmail.com> | 2018-06-03 16:51:43 +0200 |
commit | 250adb31ef1849adea8b3bd7f66e92df1bbdd431 (patch) | |
tree | 601f9be8fbf098e437d8a161c0a0582ae7b1ac5c | |
parent | d5fbf8ae93c511e9bb9e0ee4304625d4b4023622 (diff) | |
download | monitoring-plugins-250adb31ef1849adea8b3bd7f66e92df1bbdd431.tar.gz |
Added test file
-rw-r--r-- | plugins-scripts/t/check_uptime.t | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/plugins-scripts/t/check_uptime.t b/plugins-scripts/t/check_uptime.t new file mode 100644 index 00000000..410a0800 --- /dev/null +++ b/plugins-scripts/t/check_uptime.t | |||
@@ -0,0 +1,73 @@ | |||
1 | #!/usr/bin/perl -w -I .. | ||
2 | # | ||
3 | # check_uptime tests | ||
4 | # | ||
5 | # | ||
6 | |||
7 | use strict; | ||
8 | use Test::More tests => 21; | ||
9 | use NPTest; | ||
10 | |||
11 | my $result; | ||
12 | |||
13 | $result = NPTest->testCmd( | ||
14 | "./check_uptime" | ||
15 | ); | ||
16 | cmp_ok( $result->return_code, '==', 3, "Missing parameters" ); | ||
17 | like ( $result->output, '/^Usage: check_uptime -w/', "Output for missing parameters correct" ); | ||
18 | |||
19 | $result = NPTest->testCmd( | ||
20 | "./check_uptime --help" | ||
21 | ); | ||
22 | cmp_ok( $result->return_code, '==', 3, "Help output requested" ); | ||
23 | like ( $result->output, '/ABSOLUTELY NO WARRANTY/', "Output for help correct" ); | ||
24 | |||
25 | $result = NPTest->testCmd( | ||
26 | "./check_uptime -w 5 -c 2" | ||
27 | ); | ||
28 | cmp_ok( $result->return_code, '==', 3, "Warning greater than critical" ); | ||
29 | like ( $result->output, '/^Warning .*cannot be greater than Critical/', "Output for warning greater than critical correct" ); | ||
30 | |||
31 | $result = NPTest->testCmd( | ||
32 | "./check_uptime -c 1000 -W 100 2>&1" | ||
33 | ); | ||
34 | like ( $result->output, '/^Unknown option: W/', "Output with wrong parameter is correct" ); | ||
35 | |||
36 | $result = NPTest->testCmd( | ||
37 | "./check_uptime -f -w 1 -c 2" | ||
38 | ); | ||
39 | cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" ); | ||
40 | like ( $result->output, '/Running for \d+/', "Output for the f parameter correct" ); | ||
41 | |||
42 | $result = NPTest->testCmd( | ||
43 | "./check_uptime -s -w 1 -c 2" | ||
44 | ); | ||
45 | cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" ); | ||
46 | like ( $result->output, '/Running since \d+/', "Output for the s parameter correct" ); | ||
47 | |||
48 | $result = NPTest->testCmd( | ||
49 | "./check_uptime -w 1 -c 2" | ||
50 | ); | ||
51 | cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" ); | ||
52 | like ( $result->output, '/^CRITICAL: uptime is \d+ seconds/', "Output for uptime higher than 2 seconds correct" ); | ||
53 | |||
54 | $result = NPTest->testCmd( | ||
55 | "./check_uptime -w 1 -c 9999w" | ||
56 | ); | ||
57 | cmp_ok( $result->return_code, '==', 1, "Uptime lower than 9999 weeks" ); | ||
58 | like ( $result->output, '/^WARNING: uptime is \d+ seconds/', "Output for uptime lower than 9999 weeks correct" ); | ||
59 | |||
60 | $result = NPTest->testCmd( | ||
61 | "./check_uptime -w 9998w -c 9999w" | ||
62 | ); | ||
63 | cmp_ok( $result->return_code, '==', 0, "Uptime lower than 9998 weeks" ); | ||
64 | like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 9998 weeks correct" ); | ||
65 | like ( $result->output, '/\|uptime=[0-9]+s;6046790400;6047395200;/', "Checking for performance output" ); | ||
66 | |||
67 | $result = NPTest->testCmd( | ||
68 | "./check_uptime -w 111222d -c 222333d" | ||
69 | ); | ||
70 | cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days" ); | ||
71 | like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 111222 days correct" ); | ||
72 | like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); | ||
73 | |||