diff options
Diffstat (limited to 'plugins/t')
| -rw-r--r-- | plugins/t/NPTest.cache.travis | 2 | ||||
| -rw-r--r-- | plugins/t/check_dns.t | 14 | ||||
| -rw-r--r-- | plugins/t/check_hpjd.t | 35 | ||||
| -rw-r--r-- | plugins/t/check_ntp.t | 4 | ||||
| -rw-r--r-- | plugins/t/negate.t | 5 | 
5 files changed, 47 insertions, 13 deletions
| diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis index c1007deb..4ebfb90e 100644 --- a/plugins/t/NPTest.cache.travis +++ b/plugins/t/NPTest.cache.travis | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | 'NP_HOST_SNMP' => '', | 14 | 'NP_HOST_SNMP' => '', | 
| 15 | 'NP_HOST_TCP_FTP' => '', | 15 | 'NP_HOST_TCP_FTP' => '', | 
| 16 | 'NP_HOST_TCP_HPJD' => '', | 16 | 'NP_HOST_TCP_HPJD' => '', | 
| 17 | 'NP_HOST_HPJD_PORT_INVALID' => '161', | ||
| 18 | 'NP_HOST_HPJD_PORT_VALID' => '', | ||
| 17 | 'NP_HOST_TCP_HTTP' => 'localhost', | 19 | 'NP_HOST_TCP_HTTP' => 'localhost', | 
| 18 | 'NP_HOST_TCP_HTTP2' => 'labs.consol.de', | 20 | 'NP_HOST_TCP_HTTP2' => 'labs.consol.de', | 
| 19 | 'NP_HOST_TCP_IMAP' => 'imap.web.de', | 21 | 'NP_HOST_TCP_IMAP' => 'imap.web.de', | 
| diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t index 4ff553f7..035e7682 100644 --- a/plugins/t/check_dns.t +++ b/plugins/t/check_dns.t | |||
| @@ -10,7 +10,7 @@ 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 => 14; | 13 | plan tests => 16; | 
| 14 | 14 | ||
| 15 | my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; | 15 | my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; | 
| 16 | 16 | ||
| @@ -43,6 +43,12 @@ my $dns_server = getTestParameter( | |||
| 43 | "A non default (remote) DNS server", | 43 | "A non default (remote) DNS server", | 
| 44 | ); | 44 | ); | 
| 45 | 45 | ||
| 46 | my $host_nonresponsive = getTestParameter( | ||
| 47 | "NP_HOST_NONRESPONSIVE", | ||
| 48 | "The hostname of system not responsive to network requests", | ||
| 49 | "10.0.0.1", | ||
| 50 | ); | ||
| 51 | |||
| 46 | my $res; | 52 | my $res; | 
| 47 | 53 | ||
| 48 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5"); | 54 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5"); | 
| @@ -54,7 +60,7 @@ cmp_ok( $res->return_code, '==', 2, "Critical threshold passed"); | |||
| 54 | 60 | ||
| 55 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5"); | 61 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5"); | 
| 56 | cmp_ok( $res->return_code, '==', 1, "Warning threshold passed"); | 62 | cmp_ok( $res->return_code, '==', 1, "Warning threshold passed"); | 
| 57 | like( $res->output, "/\|time=[\d\.]+s;0.0*;5\.0*;0\.0*/", "Output performance data OK" ); | 63 | like( $res->output, '/\|time=[\d\.]+s;0.0*;5\.0*;0\.0*/', "Output performance data OK" ); | 
| 58 | 64 | ||
| 59 | $res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1"); | 65 | $res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1"); | 
| 60 | cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid"); | 66 | cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid"); | 
| @@ -66,6 +72,10 @@ like ( $res->output, $successOutput, "Output OK" ); | |||
| 66 | $res = NPTest->testCmd("./check_dns -H $hostname_invalid -s $dns_server -t 1"); | 72 | $res = NPTest->testCmd("./check_dns -H $hostname_invalid -s $dns_server -t 1"); | 
| 67 | cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid on $dns_server"); | 73 | cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid on $dns_server"); | 
| 68 | 74 | ||
| 75 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -s $host_nonresponsive -t 2"); | ||
| 76 | cmp_ok( $res->return_code, '==', 2, "Got no answer from unresponsive server"); | ||
| 77 | like ( $res->output, "/CRITICAL - /", "Output OK"); | ||
| 78 | |||
| 69 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -t 5"); | 79 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -t 5"); | 
| 70 | cmp_ok( $res->return_code, '==', 0, "Got expected address"); | 80 | cmp_ok( $res->return_code, '==', 0, "Got expected address"); | 
| 71 | 81 | ||
| diff --git a/plugins/t/check_hpjd.t b/plugins/t/check_hpjd.t index 10ded54a..4d64852a 100644 --- a/plugins/t/check_hpjd.t +++ b/plugins/t/check_hpjd.t | |||
| @@ -10,7 +10,6 @@ use NPTest; | |||
| 10 | 10 | ||
| 11 | plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd"); | 11 | plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd"); | 
| 12 | 12 | ||
| 13 | plan tests => 5; | ||
| 14 | 13 | ||
| 15 | my $successOutput = '/^Printer ok - /'; | 14 | my $successOutput = '/^Printer ok - /'; | 
| 16 | my $failureOutput = '/Timeout: No [Rr]esponse from /'; | 15 | my $failureOutput = '/Timeout: No [Rr]esponse from /'; | 
| @@ -20,31 +19,53 @@ my $host_tcp_hpjd = getTestParameter( | |||
| 20 | "A host (usually a printer) providing the HP-JetDirect Services" | 19 | "A host (usually a printer) providing the HP-JetDirect Services" | 
| 21 | ); | 20 | ); | 
| 22 | 21 | ||
| 22 | my $host_hpjd_port_invalid = getTestParameter( | ||
| 23 | "NP_HOST_HPJD_PORT_INVALID", | ||
| 24 | "A port that HP-JetDirect Services is not listening on", | ||
| 25 | "162" | ||
| 26 | ); | ||
| 27 | |||
| 28 | my $host_hpjd_port_valid = getTestParameter( | ||
| 29 | "NP_HOST_HPJD_PORT_VALID", | ||
| 30 | "The port that HP-JetDirect Services is currently listening on", | ||
| 31 | "161" | ||
| 32 | ); | ||
| 33 | |||
| 23 | my $host_nonresponsive = getTestParameter( | 34 | my $host_nonresponsive = getTestParameter( | 
| 24 | "NP_HOST_NONRESPONSIVE", | 35 | "NP_HOST_NONRESPONSIVE", | 
| 25 | "The hostname of system not responsive to network requests", | 36 | "The hostname of system not responsive to network requests", | 
| 26 | "10.0.0.1", | 37 | "10.0.0.1" | 
| 27 | ); | 38 | ); | 
| 28 | 39 | ||
| 29 | my $hostname_invalid = getTestParameter( | 40 | my $hostname_invalid = getTestParameter( | 
| 30 | "NP_HOSTNAME_INVALID", | 41 | "NP_HOSTNAME_INVALID", | 
| 31 | "An invalid (not known to DNS) hostname", | 42 | "An invalid (not known to DNS) hostname", | 
| 32 | "nosuchhost", | 43 | "nosuchhost" | 
| 33 | ); | 44 | ); | 
| 34 | 45 | ||
| 46 | my $tests = $host_tcp_hpjd ? 9 : 5; | ||
| 47 | plan tests => $tests; | ||
| 35 | my $res; | 48 | my $res; | 
| 36 | 49 | ||
| 37 | SKIP: { | 50 | SKIP: { | 
| 38 | skip "No HP JetDirect defined", 2 unless $host_tcp_hpjd; | 51 | skip "No HP JetDirect defined", 2 unless $host_tcp_hpjd; | 
| 39 | $res = NPTest->testCmd("./check_hpjd $host_tcp_hpjd"); | 52 | $res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd"); | 
| 40 | cmp_ok( $res->return_code, '==', 0, "Jetdirect responding" ); | 53 | cmp_ok( $res->return_code, 'eq', 0, "Jetdirect responding" ); | 
| 41 | like ( $res->output, $successOutput, "Output correct" ); | 54 | like ( $res->output, $successOutput, "Output correct" ); | 
| 55 | |||
| 56 | $res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd -p $host_hpjd_port_valid"); | ||
| 57 | cmp_ok( $res->return_code, 'eq', 0, "Jetdirect responding on port $host_hpjd_port_valid" ); | ||
| 58 | like ( $res->output, $successOutput, "Output correct" ); | ||
| 59 | |||
| 60 | $res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd -p $host_hpjd_port_invalid"); | ||
| 61 | cmp_ok( $res->return_code, 'eq', 2, "Jetdirect not responding on port $host_hpjd_port_invalid" ); | ||
| 62 | like ( $res->output, $failureOutput, "Output correct" ); | ||
| 42 | } | 63 | } | 
| 43 | 64 | ||
| 44 | $res = NPTest->testCmd("./check_hpjd $host_nonresponsive"); | 65 | $res = NPTest->testCmd("./check_hpjd -H $host_nonresponsive"); | 
| 45 | cmp_ok( $res->return_code, 'eq', 2, "Host not responding"); | 66 | cmp_ok( $res->return_code, 'eq', 2, "Host not responding"); | 
| 46 | like ( $res->output, $failureOutput, "Output OK" ); | 67 | like ( $res->output, $failureOutput, "Output OK" ); | 
| 47 | 68 | ||
| 48 | $res = NPTest->testCmd("./check_hpjd $hostname_invalid"); | 69 | $res = NPTest->testCmd("./check_hpjd -H $hostname_invalid"); | 
| 49 | cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid"); | 70 | cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid"); | 
| 50 | 71 | ||
| diff --git a/plugins/t/check_ntp.t b/plugins/t/check_ntp.t index 74d890fa..b8fc8fdf 100644 --- a/plugins/t/check_ntp.t +++ b/plugins/t/check_ntp.t | |||
| @@ -35,8 +35,8 @@ my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/' | |||
| 35 | my $ntp_warnmatch1 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; | 35 | my $ntp_warnmatch1 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; | 
| 36 | my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; | 36 | my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; | 
| 37 | my $ntp_okmatch2 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/'; | 37 | my $ntp_okmatch2 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/'; | 
| 38 | my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/'; | 38 | my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2}\s\(WARNING\),\struechimers=[0-9]+/'; | 
| 39 | my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/'; | 39 | my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+\s\(CRITICAL\),\sstratum=[0-9]{1,2},\struechimers=[0-9]+/'; | 
| 40 | my $ntp_noresponse = '/^(CRITICAL - Socket timeout after 3 seconds)|(NTP CRITICAL: No response from NTP server)$/'; | 40 | my $ntp_noresponse = '/^(CRITICAL - Socket timeout after 3 seconds)|(NTP CRITICAL: No response from NTP server)$/'; | 
| 41 | my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/'; | 41 | my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/'; | 
| 42 | 42 | ||
| diff --git a/plugins/t/negate.t b/plugins/t/negate.t index f18acc39..d96a109b 100644 --- a/plugins/t/negate.t +++ b/plugins/t/negate.t | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | use strict; | 7 | use strict; | 
| 8 | use Test::More; | 8 | use Test::More; | 
| 9 | use Cwd; | ||
| 9 | use NPTest; | 10 | use NPTest; | 
| 10 | 11 | ||
| 11 | # 15 tests in the first part, 9 in timeout tests and 2 * 32 in the last loops | 12 | # 15 tests in the first part, 9 in timeout tests and 2 * 32 in the last loops | 
| @@ -13,7 +14,7 @@ plan tests => 88; | |||
| 13 | 14 | ||
| 14 | my $res; | 15 | my $res; | 
| 15 | 16 | ||
| 16 | my $PWD = $ENV{PWD}; | 17 | my $PWD = getcwd(); | 
| 17 | 18 | ||
| 18 | $res = NPTest->testCmd( "./negate" ); | 19 | $res = NPTest->testCmd( "./negate" ); | 
| 19 | is( $res->return_code, 3, "Not enough parameters"); | 20 | is( $res->return_code, 3, "Not enough parameters"); | 
| @@ -50,7 +51,7 @@ is( $res->output, "OK: a dummy okay", "The quoted string is passed through to su | |||
| 50 | $res = NPTest->testCmd( "./negate '$PWD/check_dummy 0' 'a dummy okay'" ); | 51 | $res = NPTest->testCmd( "./negate '$PWD/check_dummy 0' 'a dummy okay'" ); | 
| 51 | is( $res->output, "No data returned from command", "Bad command, as expected (trying to execute './check_dummy 0')"); | 52 | is( $res->output, "No data returned from command", "Bad command, as expected (trying to execute './check_dummy 0')"); | 
| 52 | 53 | ||
| 53 | $res = NPTest->testCmd( './negate $PWD/check_dummy 0 \'$$ a dummy okay\'' ); | 54 | $res = NPTest->testCmd( './negate '.$PWD.'/check_dummy 0 \'$$ a dummy okay\'' ); | 
| 54 | is( $res->output, 'OK: $$ a dummy okay', 'Proves that $$ is not being expanded again' ); | 55 | is( $res->output, 'OK: $$ a dummy okay', 'Proves that $$ is not being expanded again' ); | 
| 55 | 56 | ||
| 56 | my %state = ( | 57 | my %state = ( | 
