diff options
Diffstat (limited to 'plugins/t')
| -rw-r--r-- | plugins/t/NPTest.cache.travis | 4 | ||||
| -rw-r--r-- | plugins/t/check_apt.t | 18 | ||||
| -rw-r--r-- | plugins/t/check_dns.t | 26 | 
3 files changed, 42 insertions, 6 deletions
| diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis index bcec9855..38c0a6b2 100644 --- a/plugins/t/NPTest.cache.travis +++ b/plugins/t/NPTest.cache.travis | |||
| @@ -4,8 +4,10 @@ | |||
| 4 | 'NP_DNS_SERVER' => '8.8.8.8', | 4 | 'NP_DNS_SERVER' => '8.8.8.8', | 
| 5 | 'NP_GOOD_NTP_SERVICE' => '', | 5 | 'NP_GOOD_NTP_SERVICE' => '', | 
| 6 | 'NP_HOSTNAME_INVALID' => 'nosuchhost', | 6 | 'NP_HOSTNAME_INVALID' => 'nosuchhost', | 
| 7 | 'NP_HOSTNAME_VALID' => 'monitoringplugins.org', | 7 | 'NP_HOSTNAME_VALID' => 'monitoring-plugins.org', | 
| 8 | 'NP_HOSTNAME_VALID_IP' => '130.133.8.40', | 8 | 'NP_HOSTNAME_VALID_IP' => '130.133.8.40', | 
| 9 | 'NP_HOSTNAME_VALID_CIDR' => '130.133.8.41/30', | ||
| 10 | 'NP_HOSTNAME_INVALID_CIDR' => '130.133.8.39/30', | ||
| 9 | 'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.', | 11 | 'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.', | 
| 10 | 'NP_HOST_DHCP_RESPONSIVE' => '', | 12 | 'NP_HOST_DHCP_RESPONSIVE' => '', | 
| 11 | 'NP_HOST_NONRESPONSIVE' => '10.0.0.1', | 13 | 'NP_HOST_NONRESPONSIVE' => '10.0.0.1', | 
| diff --git a/plugins/t/check_apt.t b/plugins/t/check_apt.t index 9ba0ff8e..430eb53e 100644 --- a/plugins/t/check_apt.t +++ b/plugins/t/check_apt.t | |||
| @@ -23,7 +23,7 @@ sub make_result_regexp { | |||
| 23 | } | 23 | } | 
| 24 | 24 | ||
| 25 | if (-x "./check_apt") { | 25 | if (-x "./check_apt") { | 
| 26 | plan tests => 28; | 26 | plan tests => 36; | 
| 27 | } else { | 27 | } else { | 
| 28 | plan skip_all => "No check_apt compiled"; | 28 | plan skip_all => "No check_apt compiled"; | 
| 29 | } | 29 | } | 
| @@ -40,10 +40,18 @@ $result = NPTest->testCmd( sprintf($testfile_command, "", "debian2") ); | |||
| 40 | is( $result->return_code, 1, "Debian apt output, warning" ); | 40 | is( $result->return_code, 1, "Debian apt output, warning" ); | 
| 41 | like( $result->output, make_result_regexp(13, 0), "Output correct" ); | 41 | like( $result->output, make_result_regexp(13, 0), "Output correct" ); | 
| 42 | 42 | ||
| 43 | $result = NPTest->testCmd( sprintf($testfile_command, "-o", "debian2") ); | ||
| 44 | is( $result->return_code, 0, "Debian apt output, no critical" ); | ||
| 45 | like( $result->output, make_result_regexp(13, 0), "Output correct" ); | ||
| 46 | |||
| 43 | $result = NPTest->testCmd( sprintf($testfile_command, "", "debian3") ); | 47 | $result = NPTest->testCmd( sprintf($testfile_command, "", "debian3") ); | 
| 44 | is( $result->return_code, 2, "Debian apt output, some critical" ); | 48 | is( $result->return_code, 2, "Debian apt output, some critical" ); | 
| 45 | like( $result->output, make_result_regexp(19, 4), "Output correct" ); | 49 | like( $result->output, make_result_regexp(19, 4), "Output correct" ); | 
| 46 | 50 | ||
| 51 | $result = NPTest->testCmd( sprintf($testfile_command, "-o", "debian3") ); | ||
| 52 | is( $result->return_code, 2, "Debian apt output, some critical" ); | ||
| 53 | like( $result->output, make_result_regexp(19, 4), "Output correct" ); | ||
| 54 | |||
| 47 | $result = NPTest->testCmd( sprintf($testfile_command, "-c '^[^\\(]*\\(.* (Debian-Security:|Ubuntu:[^/]*/[^-]*-security)'", "debian3") ); | 55 | $result = NPTest->testCmd( sprintf($testfile_command, "-c '^[^\\(]*\\(.* (Debian-Security:|Ubuntu:[^/]*/[^-]*-security)'", "debian3") ); | 
| 48 | is( $result->return_code, 2, "Debian apt output - should have same result when default security regexp specified via -c" ); | 56 | is( $result->return_code, 2, "Debian apt output - should have same result when default security regexp specified via -c" ); | 
| 49 | like( $result->output, make_result_regexp(19, 4), "Output correct" ); | 57 | like( $result->output, make_result_regexp(19, 4), "Output correct" ); | 
| @@ -52,6 +60,10 @@ $result = NPTest->testCmd( sprintf($testfile_command, "-i libc6", "debian3") ); | |||
| 52 | is( $result->return_code, 1, "Debian apt output, filter for libc6" ); | 60 | is( $result->return_code, 1, "Debian apt output, filter for libc6" ); | 
| 53 | like( $result->output, make_result_regexp(3, 0), "Output correct" ); | 61 | like( $result->output, make_result_regexp(3, 0), "Output correct" ); | 
| 54 | 62 | ||
| 63 | $result = NPTest->testCmd( sprintf($testfile_command, "-i libc6", "debian3") ); | ||
| 64 | is( $result->return_code, 1, "Debian apt output, filter for libc6, not critical" ); | ||
| 65 | like( $result->output, make_result_regexp(3, 0), "Output correct" ); | ||
| 66 | |||
| 55 | $result = NPTest->testCmd( sprintf($testfile_command, "-i libc6 -i xen", "debian3") ); | 67 | $result = NPTest->testCmd( sprintf($testfile_command, "-i libc6 -i xen", "debian3") ); | 
| 56 | is( $result->return_code, 2, "Debian apt output, filter for libc6 and xen" ); | 68 | is( $result->return_code, 2, "Debian apt output, filter for libc6 and xen" ); | 
| 57 | like( $result->output, make_result_regexp(9, 4), "Output correct" ); | 69 | like( $result->output, make_result_regexp(9, 4), "Output correct" ); | 
| @@ -64,6 +76,10 @@ $result = NPTest->testCmd( sprintf($testfile_command, "-e libc6", "debian3") ); | |||
| 64 | is( $result->return_code, 2, "Debian apt output, filter out libc6" ); | 76 | is( $result->return_code, 2, "Debian apt output, filter out libc6" ); | 
| 65 | like( $result->output, make_result_regexp(16, 4), "Output correct" ); | 77 | like( $result->output, make_result_regexp(16, 4), "Output correct" ); | 
| 66 | 78 | ||
| 79 | $result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -o", "debian3") ); | ||
| 80 | is( $result->return_code, 2, "Debian apt output, filter out libc6, critical" ); | ||
| 81 | like( $result->output, make_result_regexp(16, 4), "Output correct" ); | ||
| 82 | |||
| 67 | $result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -e xen", "debian3") ); | 83 | $result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -e xen", "debian3") ); | 
| 68 | is( $result->return_code, 1, "Debian apt output, filter out libc6 and xen" ); | 84 | is( $result->return_code, 1, "Debian apt output, filter out libc6 and xen" ); | 
| 69 | like( $result->output, make_result_regexp(10, 0), "Output correct" ); | 85 | like( $result->output, make_result_regexp(10, 0), "Output correct" ); | 
| diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t index 035e7682..cdfbe60d 100644 --- a/plugins/t/check_dns.t +++ b/plugins/t/check_dns.t | |||
| @@ -10,26 +10,38 @@ use NPTest; | |||
| 10 | 10 | ||
| 11 | plan skip_all => "check_dns not compiled" unless (-x "check_dns"); | 11 | plan skip_all => "check_dns not compiled" unless (-x "check_dns"); | 
| 12 | 12 | ||
| 13 | plan tests => 16; | 13 | plan tests => 19; | 
| 14 | 14 | ||
| 15 | my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; | 15 | my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; | 
| 16 | 16 | ||
| 17 | my $hostname_valid = getTestParameter( | 17 | my $hostname_valid = getTestParameter( | 
| 18 | "NP_HOSTNAME_VALID", | 18 | "NP_HOSTNAME_VALID", | 
| 19 | "A valid (known to DNS) hostname", | 19 | "A valid (known to DNS) hostname", | 
| 20 | "monitoring-plugins.org" | 20 | "monitoring-plugins.org", | 
| 21 | ); | 21 | ); | 
| 22 | 22 | ||
| 23 | my $hostname_valid_ip = getTestParameter( | 23 | my $hostname_valid_ip = getTestParameter( | 
| 24 | "NP_HOSTNAME_VALID_IP", | 24 | "NP_HOSTNAME_VALID_IP", | 
| 25 | "The IP address of the valid hostname $hostname_valid", | 25 | "The IP address of the valid hostname $hostname_valid", | 
| 26 | "66.118.156.50", | 26 | "130.133.8.40", | 
| 27 | ); | ||
| 28 | |||
| 29 | my $hostname_valid_cidr = getTestParameter( | ||
| 30 | "NP_HOSTNAME_VALID_CIDR", | ||
| 31 | "An valid CIDR range containing $hostname_valid_ip", | ||
| 32 | "130.133.8.41/30", | ||
| 33 | ); | ||
| 34 | |||
| 35 | my $hostname_invalid_cidr = getTestParameter( | ||
| 36 | "NP_HOSTNAME_INVALID_CIDR", | ||
| 37 | "An (valid) CIDR range NOT containing $hostname_valid_ip", | ||
| 38 | "130.133.8.39/30", | ||
| 27 | ); | 39 | ); | 
| 28 | 40 | ||
| 29 | my $hostname_valid_reverse = getTestParameter( | 41 | my $hostname_valid_reverse = getTestParameter( | 
| 30 | "NP_HOSTNAME_VALID_REVERSE", | 42 | "NP_HOSTNAME_VALID_REVERSE", | 
| 31 | "The hostname of $hostname_valid_ip", | 43 | "The hostname of $hostname_valid_ip", | 
| 32 | "66-118-156-50.static.sagonet.net.", | 44 | "orwell.monitoring-plugins.org.", | 
| 33 | ); | 45 | ); | 
| 34 | 46 | ||
| 35 | my $hostname_invalid = getTestParameter( | 47 | my $hostname_invalid = getTestParameter( | 
| @@ -87,3 +99,9 @@ $res = NPTest->testCmd("./check_dns -H $hostname_valid_ip -a $hostname_valid_rev | |||
| 87 | cmp_ok( $res->return_code, '==', 0, "Got expected fqdn"); | 99 | cmp_ok( $res->return_code, '==', 0, "Got expected fqdn"); | 
| 88 | like ( $res->output, $successOutput, "Output OK"); | 100 | like ( $res->output, $successOutput, "Output OK"); | 
| 89 | 101 | ||
| 102 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_cidr -t 5"); | ||
| 103 | cmp_ok( $res->return_code, '==', 0, "Got expected address"); | ||
| 104 | |||
| 105 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_invalid_cidr -t 5"); | ||
| 106 | cmp_ok( $res->return_code, '==', 2, "Got wrong address"); | ||
| 107 | like ( $res->output, "/^DNS CRITICAL.*expected '$hostname_invalid_cidr' but got '$hostname_valid_ip'".'$/', "Output OK"); | ||
