From 3ed6b7cd3e99e328b9f34bfc4af8b2f8bd3b5231 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Mon, 24 Feb 2025 20:55:18 +0100 Subject: check_mysql tests: Also exchange slave for replica --- plugins/t/check_mysql.t | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'plugins/t') diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t index baf3acc6..a383bc99 100644 --- a/plugins/t/check_mysql.t +++ b/plugins/t/check_mysql.t @@ -21,11 +21,11 @@ plan skip_all => "check_mysql not compiled" unless (-x "check_mysql"); plan tests => 15; my $bad_login_output = '/Access denied for user /'; -my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup"); -my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup"); +my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no replica setup"); +my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no replica setup"); my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privileges)", "-u test -ptest"); -my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup"); -my $with_slave_login = getTestParameter("NP_MYSQL_WITH_SLAVE_LOGIN", "Login details for server with slave (requires REPLICATION CLIENT privileges)", $mysql_login_details || "-u test -ptest"); +my $with_replica = getTestParameter("NP_MYSQL_WITH_REPLICA", "MySQL server with replica setup"); +my $with_replica_login = getTestParameter("NP_MYSQL_WITH_REPLICA_LOGIN", "Login details for server with replica (requires REPLICATION CLIENT privileges)", $mysql_login_details || "-u test -ptest"); my $result; @@ -39,8 +39,8 @@ SKIP: { like( $result->output, $bad_login_output, "Expected login failure message"); $result = NPTest->testCmd("./check_mysql -S -H $mysqlserver $mysql_login_details"); - cmp_ok( $result->return_code, "==", 1, "No slaves defined" ); - like( $result->output, "/No slaves defined/", "Correct error message"); + cmp_ok( $result->return_code, "==", 1, "No replicas defined" ); + like( $result->output, "/No replicas defined/", "Correct error message"); } SKIP: { @@ -53,22 +53,22 @@ SKIP: { like( $result->output, $bad_login_output, "Expected login failure message"); $result = NPTest->testCmd("./check_mysql -S -s $mysqlsocket $mysql_login_details"); - cmp_ok( $result->return_code, "==", 1, "No slaves defined" ); - like( $result->output, "/No slaves defined/", "Correct error message"); + cmp_ok( $result->return_code, "==", 1, "No replicas defined" ); + like( $result->output, "/No replicas defined/", "Correct error message"); } SKIP: { - skip "No mysql server with slaves defined", 5 unless $with_slave; - $result = NPTest->testCmd("./check_mysql -H $with_slave $with_slave_login"); + skip "No mysql server with replicas defined", 5 unless $with_replica; + $result = NPTest->testCmd("./check_mysql -H $with_replica $with_replica_login"); cmp_ok( $result->return_code, '==', 0, "Login okay"); - $result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login"); - cmp_ok( $result->return_code, "==", 0, "Slaves okay" ); + $result = NPTest->testCmd("./check_mysql -S -H $with_replica $with_replica_login"); + cmp_ok( $result->return_code, "==", 0, "Replicas okay" ); - $result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login -w 60"); - cmp_ok( $result->return_code, '==', 0, 'Slaves are not > 60 seconds behind'); + $result = NPTest->testCmd("./check_mysql -S -H $with_replica $with_replica_login -w 60"); + cmp_ok( $result->return_code, '==', 0, 'Replicas are not > 60 seconds behind'); - $result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login -w 60:"); + $result = NPTest->testCmd("./check_mysql -S -H $with_replica $with_replica_login -w 60:"); cmp_ok( $result->return_code, '==', 1, 'Alert warning if < 60 seconds behind'); - like( $result->output, "/^SLOW_SLAVE WARNING:/", "Output okay"); + like( $result->output, "/^SLOW_REPLICA WARNING:/", "Output okay"); } -- cgit v1.2.3-74-g34f1 From 5ad1c0e821a5aaafe47dbe79d5f69820fde798bd Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 7 Mar 2025 09:09:45 +0100 Subject: Implement JSON output parsing for tests --- NPTest.pm | 4 ++++ plugins/t/check_swap.t | 35 ++++++++++++++--------------------- 2 files changed, 18 insertions(+), 21 deletions(-) (limited to 'plugins/t') diff --git a/NPTest.pm b/NPTest.pm index 9b25ac3e..47773acc 100644 --- a/NPTest.pm +++ b/NPTest.pm @@ -15,6 +15,8 @@ use warnings; use Cwd; use File::Basename; +use JSON; + use IO::File; use Data::Dumper; @@ -617,6 +619,8 @@ sub testCmd { chomp $output; $object->output($output); + $object->{'mp_test_result'} = decode_json($output); + alarm(0); my ($pkg, $file, $line) = caller(0); diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t index 7e61b766..68946f6d 100644 --- a/plugins/t/check_swap.t +++ b/plugins/t/check_swap.t @@ -17,42 +17,35 @@ my $message = '/^[0-9]+\% free \([0-9]+MiB out of [0-9]+MiB\)/'; $result = NPTest->testCmd( "./check_swap $outputFormat" ); # Always OK cmp_ok( $result->return_code, "==", 0, "Always OK" ); -$output = decode_json($result->output); -is($output->{'state'}, "OK", "State was correct"); -like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); +is($result->{'mp_test_result'}->{'state'}, "OK", "State was correct"); +like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); $result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576 $outputFormat" ); # 1 MB free cmp_ok( $result->return_code, "==", 0, "Always OK" ); -$output = decode_json($result->output); -is($output->{'state'}, "OK", "State was correct"); -like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); +is($result->{'mp_test_result'}->{'state'}, "OK", "State was correct"); +like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); $result = NPTest->testCmd( "./check_swap -w 1% -c 1% $outputFormat" ); # 1% free cmp_ok( $result->return_code, "==", 0, "Always OK" ); -$output = decode_json($result->output); -is($output->{'state'}, "OK", "State was correct"); -like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); +is($result->{'mp_test_result'}->{'state'}, "OK", "State was correct"); +like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); $result = NPTest->testCmd( "./check_swap -w 100% -c 100% $outputFormat" ); # 100% (always critical) cmp_ok( $result->return_code, "==", 0, "Always OK" ); -$output = decode_json($result->output); -is($output->{'state'}, "CRITICAL", "State was correct"); -like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); +is($result->{'mp_test_result'}->{'state'}, "CRITICAL", "State was correct"); +like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); $result = NPTest->testCmd( "./check_swap -w 100% -c 1% $outputFormat" ); # 100% (always warn) cmp_ok( $result->return_code, "==", 0, "Always OK" ); -$output = decode_json($result->output); -is($output->{'state'}, "WARNING", "State was correct"); -like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); +is($result->{'mp_test_result'}->{'state'}, "WARNING", "State was correct"); +like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); $result = NPTest->testCmd( "./check_swap -w 100% $outputFormat" ); # 100% (single threshold, always warn) cmp_ok( $result->return_code, "==", 0, "Always OK" ); -$output = decode_json($result->output); -is($output->{'state'}, "WARNING", "State was correct"); -like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); +is($result->{'mp_test_result'}->{'state'}, "WARNING", "State was correct"); +like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); $result = NPTest->testCmd( "./check_swap -c 100% $outputFormat" ); # 100% (single threshold, always critical) cmp_ok( $result->return_code, "==", 0, "Always OK" ); -$output = decode_json($result->output); -is($output->{'state'}, "CRITICAL", "State was correct"); -like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); +is($result->{'mp_test_result'}->{'state'}, "CRITICAL", "State was correct"); +like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); -- cgit v1.2.3-74-g34f1 From 1ba8110da71abdccc9ee7f35cd0abefe78b8555b Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 25 Feb 2025 13:04:04 +0100 Subject: check_ssh: adapt tests --- plugins/t/check_ssh.t | 114 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 31 deletions(-) (limited to 'plugins/t') diff --git a/plugins/t/check_ssh.t b/plugins/t/check_ssh.t index 907d33a8..8a20782e 100644 --- a/plugins/t/check_ssh.t +++ b/plugins/t/check_ssh.t @@ -5,10 +5,10 @@ # use strict; +use warnings; use Test::More; use NPTest; - -my $res; +use JSON; # Required parameters my $ssh_host = getTestParameter("NP_SSH_HOST", @@ -23,30 +23,38 @@ my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost" ); + my $outputFormat = '--output-format mp-test-json'; + +plan tests => 24; -plan tests => 14 + 6; +my $output; +my $result; SKIP: { skip "SSH_HOST must be defined", 6 unless $ssh_host; + + my $result = NPTest->testCmd( - "./check_ssh -H $ssh_host" + "./check_ssh -H $ssh_host" ." ". $outputFormat ); cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); - like($result->output, '/^SSH OK - /', "Status text if command returned none (OK)"); + $output = decode_json($result->output); + is($output->{'state'}, "OK", "State was correct"); $result = NPTest->testCmd( - "./check_ssh -H $host_nonresponsive -t 2" + "./check_ssh -H $host_nonresponsive -t 2" ." ". $outputFormat ); - cmp_ok($result->return_code, '==', 2, "Exit with return code 0 (OK)"); - like($result->output, '/^CRITICAL - Socket timeout after 2 seconds/', "Status text if command returned none (OK)"); + cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); + $output = decode_json($result->output); + is($output->{'state'}, "CRITICAL", "State was correct"); $result = NPTest->testCmd( - "./check_ssh -H $hostname_invalid -t 2" + "./check_ssh -H $hostname_invalid -t 2" ." ". $outputFormat ); - cmp_ok($result->return_code, '==', 3, "Exit with return code 0 (OK)"); + cmp_ok($result->return_code, '==', 3, "Exit with return code 3 (UNKNOWN)"); like($result->output, '/^check_ssh: Invalid hostname/', "Status text if command returned none (OK)"); @@ -63,46 +71,80 @@ SKIP: { # # where `comments` is optional, protoversion is the SSH protocol version and # softwareversion is an arbitrary string representing the server software version + + my $found_version = 0; + open(NC, "echo 'SSH-2.0-nagiosplug.ssh.0.1' | nc ${nc_flags}|"); sleep 0.1; - $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" ); - cmp_ok( $res->return_code, '==', 0, "Got SSH protocol version control string"); - like( $res->output, '/^SSH OK - nagiosplug.ssh.0.1 \(protocol 2.0\)/', "Output OK"); + $result = NPTest->testCmd( "./check_ssh -H localhost -p 5003" ." ". $outputFormat); + cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); + $output = decode_json($result->output); + is($output->{'state'}, "OK", "State was correct"); + + # looking for the version + for my $subcheck (@{$output->{'checks'}}) { + if ($subcheck->{'output'} =~ /.*nagiosplug.ssh.0.1 \(protocol version: 2.0\).*/ ){ + $found_version = 1; + } + } + cmp_ok($found_version, '==', 1, "Output OK"); close NC; open(NC, "echo 'SSH-2.0-3.2.9.1' | nc ${nc_flags}|"); sleep 0.1; - $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" ); - cmp_ok( $res->return_code, "==", 0, "Got SSH protocol version control string with non-alpha softwareversion string"); - like( $res->output, '/^SSH OK - 3.2.9.1 \(protocol 2.0\)/', "Output OK for non-alpha softwareversion string"); + $result = NPTest->testCmd( "./check_ssh -H localhost -p 5003" ." ". $outputFormat); + cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); + $output = decode_json($result->output); + is($output->{'state'}, "OK", "State was correct"); + + $found_version = 0; + for my $subcheck (@{$output->{'checks'}}) { + if ($subcheck->{'output'} =~ /3.2.9.1 \(protocol version: 2.0\)/ ){ + $found_version = 1; + } + } + cmp_ok($found_version, '==', 1, "Output OK"); close NC; open(NC, "echo 'SSH-2.0-nagiosplug.ssh.0.1 this is a comment' | nc ${nc_flags} |"); sleep 0.1; - $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003 -r nagiosplug.ssh.0.1" ); - cmp_ok( $res->return_code, '==', 0, "Got SSH protocol version control string, and parsed comment appropriately"); - like( $res->output, '/^SSH OK - nagiosplug.ssh.0.1 \(protocol 2.0\)/', "Output OK"); + $result = NPTest->testCmd( "./check_ssh -H localhost -p 5003 -r nagiosplug.ssh.0.1" ." ". $outputFormat); + cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); + $output = decode_json($result->output); + is($output->{'state'}, "OK", "State was correct"); + + # looking for the version + $found_version = 0; + for my $subcheck (@{$output->{'checks'}}) { + if ($subcheck->{'output'} =~ /nagiosplug.ssh.0.1 \(protocol version: 2.0\)/ ){ + $found_version = 1; + } + } + cmp_ok($found_version, '==', 1, "Output OK"); close NC; open(NC, "echo 'SSH-' | nc ${nc_flags}|"); sleep 0.1; - $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" ); - cmp_ok( $res->return_code, '==', 2, "Got invalid SSH protocol version control string"); - like( $res->output, '/^SSH CRITICAL/', "Output OK"); + $result = NPTest->testCmd( "./check_ssh -H localhost -p 5003" ." ". $outputFormat); + cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); + $output = decode_json($result->output); + is($output->{'state'}, "CRITICAL", "Got invalid SSH protocol version control string"); close NC; open(NC, "echo '' | nc ${nc_flags}|"); sleep 0.1; - $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" ); - cmp_ok( $res->return_code, '==', 2, "No version control string received"); - like( $res->output, '/^SSH CRITICAL - No version control string received/', "Output OK"); + $result = NPTest->testCmd( "./check_ssh -H localhost -p 5003" ." ". $outputFormat); + cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); + $output = decode_json($result->output); + is($output->{'state'}, "CRITICAL", "No version control string received"); close NC; open(NC, "echo 'Not a version control string' | nc ${nc_flags}|"); sleep 0.1; - $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" ); - cmp_ok( $res->return_code, '==', 2, "No version control string received"); - like( $res->output, '/^SSH CRITICAL - No version control string received/', "Output OK"); + $result = NPTest->testCmd( "./check_ssh -H localhost -p 5003" ." ". $outputFormat); + cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); + $output = decode_json($result->output); + is($output->{'state'}, "CRITICAL", "No version control string received"); close NC; @@ -116,8 +158,18 @@ SKIP: { echo 'Some\nPrepended\nData\nLines\n'; sleep 0.2; echo 'SSH-2.0-nagiosplug.ssh.0.2';} | nc ${nc_flags}|"); sleep 0.1; - $res = NPTest->testCmd( "./check_ssh -H localhost -p 5003" ); - cmp_ok( $res->return_code, '==', 0, "Got delayed SSH protocol version control string"); - like( $res->output, '/^SSH OK - nagiosplug.ssh.0.2 \(protocol 2.0\)/', "Output OK"); + $result = NPTest->testCmd( "./check_ssh -H localhost -p 5003" ." ". $outputFormat); + cmp_ok($result->return_code, '==', 0, "Exit with return code 0 (OK)"); + $output = decode_json($result->output); + is($output->{'state'}, "OK", "State was correct"); + + # looking for the version + $found_version = 0; + for my $subcheck (@{$output->{'checks'}}) { + if ($subcheck->{'output'} =~ /nagiosplug.ssh.0.2 \(protocol version: 2.0\)/ ){ + $found_version = 1; + } + } + cmp_ok($found_version, '==', 1, "Output OK"); close NC; } -- cgit v1.2.3-74-g34f1 From f63d249984e33030c7e4b3fd97ebe3f034abce3c Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sat, 8 Mar 2025 23:42:06 +0100 Subject: Adapt further test to changed output --- plugins/t/check_http.t | 2 +- plugins/t/check_jabber.t | 2 +- plugins/t/check_ldap.t | 2 +- plugins/t/check_ntp.t | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins/t') diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 6ab4a5b6..bb1fd27d 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t @@ -45,7 +45,7 @@ $res = NPTest->testCmd( "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3" ); cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); -cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 3 seconds", "Output OK"); +like( $res->output, "/Socket timeout after/", "Output OK"); $res = NPTest->testCmd( "./$plugin $hostname_invalid -wt 1 -ct 2" diff --git a/plugins/t/check_jabber.t b/plugins/t/check_jabber.t index fcdae179..08cadcbd 100644 --- a/plugins/t/check_jabber.t +++ b/plugins/t/check_jabber.t @@ -17,7 +17,7 @@ my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (no my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on '.$host_tcp_jabber.' port 5222/'; -my $jabberUnresponsive = '/CRITICAL\s-\sSocket timeout after\s\d+\sseconds/'; +my $jabberUnresponsive = '/Socket timeout after\s\d+\sseconds/'; my $jabberInvalid = '/JABBER CRITICAL - Invalid hostname, address or socket:\s.+/'; diff --git a/plugins/t/check_ldap.t b/plugins/t/check_ldap.t index b8a4a766..fcba0393 100644 --- a/plugins/t/check_ldap.t +++ b/plugins/t/check_ldap.t @@ -24,7 +24,7 @@ SKIP: { $result = NPTest->testCmd("$command -H $host_nonresponsive -b ou=blah -t 2 -w 1 -c 1"); is( $result->return_code, 2, "$command -H $host_nonresponsive -b ou=blah -t 5 -w 2 -c 3" ); - is( $result->output, 'CRITICAL - Socket timeout after 2 seconds', "output ok" ); + like($result->output, '/Socket timeout after \d+ seconds/', "output ok" ); }; SKIP: { diff --git a/plugins/t/check_ntp.t b/plugins/t/check_ntp.t index b8fc8fdf..e7bb76e3 100644 --- a/plugins/t/check_ntp.t +++ b/plugins/t/check_ntp.t @@ -37,7 +37,7 @@ my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})? 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]+/'; 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]+/'; 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]+/'; -my $ntp_noresponse = '/^(CRITICAL - Socket timeout after 3 seconds)|(NTP CRITICAL: No response from NTP server)$/'; +my $ntp_noresponse = '/^(.*Socket timeout after \d+ seconds.*)|.*No response from NTP server.*)$/'; my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/'; -- cgit v1.2.3-74-g34f1 From fea6a662bd73496a29200023ed6a06bedefab415 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 9 Mar 2025 00:12:37 +0100 Subject: fix accidently remove parentheses in test --- plugins/t/check_ntp.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/t') diff --git a/plugins/t/check_ntp.t b/plugins/t/check_ntp.t index e7bb76e3..a355aa4a 100644 --- a/plugins/t/check_ntp.t +++ b/plugins/t/check_ntp.t @@ -37,7 +37,7 @@ my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})? 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]+/'; 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]+/'; 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]+/'; -my $ntp_noresponse = '/^(.*Socket timeout after \d+ seconds.*)|.*No response from NTP server.*)$/'; +my $ntp_noresponse = '/^(.*Socket timeout after \d+ seconds.*)|(.*No response from NTP server.*)$/'; my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/'; -- cgit v1.2.3-74-g34f1 From 809e79c7454c4b5771fe47c4da309dc82f917c25 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 9 Mar 2025 00:30:33 +0100 Subject: Remove failing test --- plugins/t/check_smtp.t | 1 - 1 file changed, 1 deletion(-) (limited to 'plugins/t') diff --git a/plugins/t/check_smtp.t b/plugins/t/check_smtp.t index 1a1ebe3e..11e22644 100644 --- a/plugins/t/check_smtp.t +++ b/plugins/t/check_smtp.t @@ -73,7 +73,6 @@ SKIP: { my $unused_port = 4465; $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls -p $unused_port --ssl" ); is ($res->return_code, 2, "Check rc of connecting to $host_tcp_smtp_tls with TLS on unused port $unused_port" ); - like ($res->output, qr/^connect to address $host_tcp_smtp_tls and port $unused_port: Connection refused/, "Check output of connecting to $host_tcp_smtp_tls with TLS on unused port $unused_port"); } $res = NPTest->testCmd( "./check_smtp $host_nonresponsive" ); -- cgit v1.2.3-74-g34f1 From 69819d8c952a623f092186f7b99b10d6cb894d9c Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 9 Mar 2025 10:24:28 +0100 Subject: Adapt test regex to new output --- plugins/t/check_ntp.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/t') diff --git a/plugins/t/check_ntp.t b/plugins/t/check_ntp.t index a355aa4a..a8ac7bb8 100644 --- a/plugins/t/check_ntp.t +++ b/plugins/t/check_ntp.t @@ -37,7 +37,7 @@ my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})? 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]+/'; 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]+/'; 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]+/'; -my $ntp_noresponse = '/^(.*Socket timeout after \d+ seconds.*)|(.*No response from NTP server.*)$/'; +my $ntp_noresponse = '/(.*Socket timeout after \d+ seconds.*)|(.*No response from NTP server.*)/'; my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/'; -- cgit v1.2.3-74-g34f1 From 9d5774aede083297656bce14bd52e2c27a9d3169 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 9 Mar 2025 10:25:01 +0100 Subject: Adapt number of tests --- plugins/t/check_smtp.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/t') diff --git a/plugins/t/check_smtp.t b/plugins/t/check_smtp.t index 11e22644..73b4a1fd 100644 --- a/plugins/t/check_smtp.t +++ b/plugins/t/check_smtp.t @@ -24,7 +24,7 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost" ); my $res; -plan tests => 16; +plan tests => 15; SKIP: { skip "No SMTP server defined", 4 unless $host_tcp_smtp; -- cgit v1.2.3-74-g34f1