diff options
| author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-11-10 17:42:44 +0000 |
|---|---|---|
| committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-11-10 17:42:44 +0000 |
| commit | a22c1454b6ff2a943a69d9985651469b2631f635 (patch) | |
| tree | 1e21232b3e347e2f4e67ca6c5ce91faf27fe47bb /plugins/t | |
| parent | cecee3b342dddc4050f205f6b8f29c59f82fabd3 (diff) | |
| download | monitoring-plugins-a22c1454b6ff2a943a69d9985651469b2631f635.tar.gz | |
Commiting current work (check_ntpd.c mainly completed, check_time_ntp.c not started yet)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/branches/dermoth_ntp_rework@1823 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t')
| -rw-r--r-- | plugins/t/check_ntpd.t | 57 | ||||
| -rw-r--r-- | plugins/t/check_time_ntp.t | 57 |
2 files changed, 114 insertions, 0 deletions
diff --git a/plugins/t/check_ntpd.t b/plugins/t/check_ntpd.t new file mode 100644 index 00000000..3c5fe2ed --- /dev/null +++ b/plugins/t/check_ntpd.t | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | #! /usr/bin/perl -w -I .. | ||
| 2 | # | ||
| 3 | # Testing NTP | ||
| 4 | # | ||
| 5 | # $Id: check_ntp.t 1468 2006-08-14 08:42:23Z tonvoon $ | ||
| 6 | # | ||
| 7 | |||
| 8 | use strict; | ||
| 9 | use Test::More; | ||
| 10 | use NPTest; | ||
| 11 | |||
| 12 | plan tests => 4; | ||
| 13 | |||
| 14 | my $res; | ||
| 15 | |||
| 16 | my $ntp_service = getTestParameter( "NP_GOOD_NTP_SERVICE", | ||
| 17 | "A host providing NTP service", | ||
| 18 | "pool.ntp.org"); | ||
| 19 | |||
| 20 | my $no_ntp_service = getTestParameter( "NP_NO_NTP_SERVICE", | ||
| 21 | "A host NOT providing the NTP service", | ||
| 22 | "localhost" ); | ||
| 23 | |||
| 24 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", | ||
| 25 | "The hostname of system not responsive to network requests", | ||
| 26 | "10.0.0.1" ); | ||
| 27 | |||
| 28 | my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", | ||
| 29 | "An invalid (not known to DNS) hostname", | ||
| 30 | "nosuchhost"); | ||
| 31 | |||
| 32 | SKIP: { | ||
| 33 | skip "No NTP server defined", 1 unless $ntp_service; | ||
| 34 | $res = NPTest->testCmd( | ||
| 35 | "./check_ntp -H $ntp_service" | ||
| 36 | ); | ||
| 37 | cmp_ok( $res->return_code, '==', 0, "Got good NTP result"); | ||
| 38 | } | ||
| 39 | |||
| 40 | SKIP: { | ||
| 41 | skip "No bad NTP server defined", 1 unless $no_ntp_service; | ||
| 42 | $res = NPTest->testCmd( | ||
| 43 | "./check_ntp -H $no_ntp_service" | ||
| 44 | ); | ||
| 45 | cmp_ok( $res->return_code, '==', 2, "Got bad NTP result"); | ||
| 46 | } | ||
| 47 | |||
| 48 | $res = NPTest->testCmd( | ||
| 49 | "./check_ntp -H $host_nonresponsive" | ||
| 50 | ); | ||
| 51 | cmp_ok( $res->return_code, '==', 2, "Got critical if server not responding"); | ||
| 52 | |||
| 53 | $res = NPTest->testCmd( | ||
| 54 | "./check_ntp -H $hostname_invalid" | ||
| 55 | ); | ||
| 56 | cmp_ok( $res->return_code, '==', 3, "Got critical if server hostname invalid"); | ||
| 57 | |||
diff --git a/plugins/t/check_time_ntp.t b/plugins/t/check_time_ntp.t new file mode 100644 index 00000000..3c5fe2ed --- /dev/null +++ b/plugins/t/check_time_ntp.t | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | #! /usr/bin/perl -w -I .. | ||
| 2 | # | ||
| 3 | # Testing NTP | ||
| 4 | # | ||
| 5 | # $Id: check_ntp.t 1468 2006-08-14 08:42:23Z tonvoon $ | ||
| 6 | # | ||
| 7 | |||
| 8 | use strict; | ||
| 9 | use Test::More; | ||
| 10 | use NPTest; | ||
| 11 | |||
| 12 | plan tests => 4; | ||
| 13 | |||
| 14 | my $res; | ||
| 15 | |||
| 16 | my $ntp_service = getTestParameter( "NP_GOOD_NTP_SERVICE", | ||
| 17 | "A host providing NTP service", | ||
| 18 | "pool.ntp.org"); | ||
| 19 | |||
| 20 | my $no_ntp_service = getTestParameter( "NP_NO_NTP_SERVICE", | ||
| 21 | "A host NOT providing the NTP service", | ||
| 22 | "localhost" ); | ||
| 23 | |||
| 24 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", | ||
| 25 | "The hostname of system not responsive to network requests", | ||
| 26 | "10.0.0.1" ); | ||
| 27 | |||
| 28 | my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", | ||
| 29 | "An invalid (not known to DNS) hostname", | ||
| 30 | "nosuchhost"); | ||
| 31 | |||
| 32 | SKIP: { | ||
| 33 | skip "No NTP server defined", 1 unless $ntp_service; | ||
| 34 | $res = NPTest->testCmd( | ||
| 35 | "./check_ntp -H $ntp_service" | ||
| 36 | ); | ||
| 37 | cmp_ok( $res->return_code, '==', 0, "Got good NTP result"); | ||
| 38 | } | ||
| 39 | |||
| 40 | SKIP: { | ||
| 41 | skip "No bad NTP server defined", 1 unless $no_ntp_service; | ||
| 42 | $res = NPTest->testCmd( | ||
| 43 | "./check_ntp -H $no_ntp_service" | ||
| 44 | ); | ||
| 45 | cmp_ok( $res->return_code, '==', 2, "Got bad NTP result"); | ||
| 46 | } | ||
| 47 | |||
| 48 | $res = NPTest->testCmd( | ||
| 49 | "./check_ntp -H $host_nonresponsive" | ||
| 50 | ); | ||
| 51 | cmp_ok( $res->return_code, '==', 2, "Got critical if server not responding"); | ||
| 52 | |||
| 53 | $res = NPTest->testCmd( | ||
| 54 | "./check_ntp -H $hostname_invalid" | ||
| 55 | ); | ||
| 56 | cmp_ok( $res->return_code, '==', 3, "Got critical if server hostname invalid"); | ||
| 57 | |||
