diff options
Diffstat (limited to 'plugins-scripts/t')
-rw-r--r-- | plugins-scripts/t/check_ifoperstatus.t | 48 | ||||
-rw-r--r-- | plugins-scripts/t/check_ifstatus.t | 18 |
2 files changed, 43 insertions, 23 deletions
diff --git a/plugins-scripts/t/check_ifoperstatus.t b/plugins-scripts/t/check_ifoperstatus.t index 1267f41..1d6114f 100644 --- a/plugins-scripts/t/check_ifoperstatus.t +++ b/plugins-scripts/t/check_ifoperstatus.t | |||
@@ -16,17 +16,29 @@ my $plugin = "check_ifoperstatus"; | |||
16 | SKIP: { | 16 | SKIP: { |
17 | skip "$plugin is not created", $tests if ( ! -x $plugin ); | 17 | skip "$plugin is not created", $tests if ( ! -x $plugin ); |
18 | 18 | ||
19 | my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost", | 19 | my $host_snmp = getTestParameter( "NP_HOST_SNMP", "A host providing an SNMP Service", "localhost"); |
20 | "A host providing an SNMP Service"); | ||
21 | 20 | ||
22 | my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public", | 21 | my $snmp_community = getTestParameter( "NP_SNMP_COMMUNITY", |
23 | "The SNMP Community string for SNMP Testing (assumes snmp v1)" ); | 22 | "The SNMP Community string for SNMP Testing (pick default rather than 'none' when no snmp host is available)", |
23 | "public"); | ||
24 | |||
25 | my ($snmp_interface, $snmp_ifxtable); | ||
26 | if ($host_snmp) { | ||
27 | $snmp_interface = getTestParameter( "NP_SNMP_INTERFACE", "Name of an active network interface on SNMP server", "lo" ); | ||
28 | |||
29 | $snmp_ifxtable = getTestParameter( "NP_SNMP_IFXTABLE", | ||
30 | "Is IFXTABLE activated in SNMP server (1: yes, 0: no)? snmpwalk -v1 -c $snmp_community $host_snmp ifxtable", | ||
31 | "1" ); | ||
32 | } | ||
33 | |||
34 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", | ||
35 | "The hostname of system not responsive to network requests", "10.0.0.1" ); | ||
36 | |||
37 | my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", | ||
38 | "An invalid (not known to DNS) hostname", | ||
39 | "nosuchhost" ); | ||
24 | 40 | ||
25 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
26 | "The hostname of system not responsive to network requests" ); | ||
27 | 41 | ||
28 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
29 | "An invalid (not known to DNS) hostname" ); | ||
30 | 42 | ||
31 | $res = NPTest->testCmd( "./$plugin" ); | 43 | $res = NPTest->testCmd( "./$plugin" ); |
32 | is( $res->return_code, 3, "No arguments" ); | 44 | is( $res->return_code, 3, "No arguments" ); |
@@ -47,13 +59,19 @@ SKIP: { | |||
47 | cmp_ok( $res->return_code, '==', 0, "Exit OK for ifindex 1" ); | 59 | cmp_ok( $res->return_code, '==', 0, "Exit OK for ifindex 1" ); |
48 | like($res->output, '/^OK.*Interface.*is up/', "String contains OK Interface is up"); | 60 | like($res->output, '/^OK.*Interface.*is up/', "String contains OK Interface is up"); |
49 | 61 | ||
50 | $res = NPTest->testCmd( "./$plugin -H $host_snmp -C $snmp_community -d lo"); | 62 | SKIP: { |
51 | cmp_ok( $res->return_code, '==', 0, "Exit OK for ifdescr lo" ); | 63 | skip "no snmp interface defined", 2 if ( ! $snmp_interface ); |
52 | like($res->output, '/^OK.*Interface.*is up/', "String contains OK Interface is up"); | 64 | $res = NPTest->testCmd( "./$plugin -H $host_snmp -C $snmp_community -d $snmp_interface"); |
53 | 65 | cmp_ok( $res->return_code, '==', 0, "Exit OK for ifdescr $snmp_interface" ); | |
54 | $res = NPTest->testCmd( "./$plugin -H $host_snmp -C $snmp_community -k 1 -n rubbish"); | 66 | like($res->output, '/^OK.*Interface.*is up/', "String contains OK Interface is up"); |
55 | cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN if interface name doesn't match" ); | 67 | } |
56 | like($res->output, '/doesn\'t match snmp value/', "String contains 'doesn't match snmp value'"); | 68 | |
69 | SKIP: { | ||
70 | skip "ifxtable not available", 2 if ( ! $snmp_ifxtable ); | ||
71 | $res = NPTest->testCmd( "./$plugin -H $host_snmp -C $snmp_community -k 1 -n rubbish"); | ||
72 | cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN if interface name doesn't match" ); | ||
73 | like($res->output, '/doesn\'t match snmp value/', "String contains 'doesn't match snmp value'"); | ||
74 | } | ||
57 | 75 | ||
58 | } | 76 | } |
59 | 77 | ||
diff --git a/plugins-scripts/t/check_ifstatus.t b/plugins-scripts/t/check_ifstatus.t index c5169d9..fc7052a 100644 --- a/plugins-scripts/t/check_ifstatus.t +++ b/plugins-scripts/t/check_ifstatus.t | |||
@@ -16,17 +16,19 @@ my $plugin = "check_ifstatus"; | |||
16 | SKIP: { | 16 | SKIP: { |
17 | skip "$plugin is not created", $tests if ( ! -x $plugin ); | 17 | skip "$plugin is not created", $tests if ( ! -x $plugin ); |
18 | 18 | ||
19 | my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost", | 19 | my $host_snmp = getTestParameter( "NP_HOST_SNMP", "A host providing an SNMP Service", "localhost"); |
20 | "A host providing an SNMP Service"); | ||
21 | 20 | ||
22 | my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public", | 21 | my $snmp_community = getTestParameter( "NP_SNMP_COMMUNITY", |
23 | "The SNMP Community string for SNMP Testing (assumes snmp v1)" ); | 22 | "The SNMP Community string for SNMP Testing (pick default rather than 'none' when no snmp host is available)", |
23 | "public"); | ||
24 | 24 | ||
25 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | 25 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", |
26 | "The hostname of system not responsive to network requests" ); | 26 | "The hostname of system not responsive to network requests", "10.0.0.1" ); |
27 | |||
28 | my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", | ||
29 | "An invalid (not known to DNS) hostname", | ||
30 | "nosuchhost" ); | ||
27 | 31 | ||
28 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
29 | "An invalid (not known to DNS) hostname" ); | ||
30 | 32 | ||
31 | $res = NPTest->testCmd( "./$plugin" ); | 33 | $res = NPTest->testCmd( "./$plugin" ); |
32 | is( $res->return_code, 3, "No arguments" ); | 34 | is( $res->return_code, 3, "No arguments" ); |