SF.net SVN: nagiosplug:[2221] nagiosplug/trunk/plugins-scripts/t

[email protected]
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
Revision: 2221
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2221&view=rev
Author:   dermoth
Date:     2009-06-13 09:20:16 +0000 (Sat, 13 Jun 2009)

Log Message:
-----------
Further test parameters and skip blocks for check_ifoperstatus.t. getTestparam changes for check_ifstatus.t and ifoperstatus.t

Added snmp_interface and snmp_ifxtable test parameters to check_ifoperstatus.t.
Also getTestParameter calls for both plugins were converted to use three arguments
instead of undocumented >3 arg behaviour which led to redundant data in NPTest.cache.

From: Matthias Eble <[email protected]>

Modified Paths:
--------------
    nagiosplug/trunk/plugins-scripts/t/check_ifoperstatus.t
    nagiosplug/trunk/plugins-scripts/t/check_ifstatus.t

Modified: nagiosplug/trunk/plugins-scripts/t/check_ifoperstatus.t
===================================================================
--- nagiosplug/trunk/plugins-scripts/t/check_ifoperstatus.t	2009-06-11 15:30:28 UTC (rev 2220)
+++ nagiosplug/trunk/plugins-scripts/t/check_ifoperstatus.t	2009-06-13 09:20:16 UTC (rev 2221)
@@ -16,18 +16,30 @@
 SKIP: {
 	skip "$plugin is not created", $tests if ( ! -x $plugin );
 
-	my $host_snmp = getTestParameter( "host_snmp",          "NP_HOST_SNMP",      "localhost",
-	                                   "A host providing an SNMP Service");
+	my $host_snmp = getTestParameter( "NP_HOST_SNMP", "A host providing an SNMP Service", "localhost");
 
-	my $snmp_community = getTestParameter( "snmp_community",     "NP_SNMP_COMMUNITY", "public",
-                                           "The SNMP Community string for SNMP Testing (assumes snmp v1)" );
+	my $snmp_community = getTestParameter( "NP_SNMP_COMMUNITY",
+	                                       "The SNMP Community string for SNMP Testing (pick default rather than 'none' when no snmp host is available)",
+	                                       "public");
 
-	my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
-	                                           "The hostname of system not responsive to network requests" );
+	my ($snmp_interface, $snmp_ifxtable);
+	if ($host_snmp) {
+		$snmp_interface   = getTestParameter( "NP_SNMP_INTERFACE", "Name of an active network interface on SNMP server", "lo" );
 
-	my $hostname_invalid   = getTestParameter( "hostname_invalid",   "NP_HOSTNAME_INVALID",   "nosuchhost",
-	                                           "An invalid (not known to DNS) hostname" );
+		$snmp_ifxtable   = getTestParameter( "NP_SNMP_IFXTABLE",   
+		                                     "Is IFXTABLE activated in SNMP server (1: yes, 0: no)? snmpwalk -v1 -c $snmp_community $host_snmp ifxtable",
+		                                     "1" );
+	}
 
+	my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", 
+	                                           "The hostname of system not responsive to network requests", "10.0.0.1" );
+
+	my $hostname_invalid   = getTestParameter( "NP_HOSTNAME_INVALID",
+	                                           "An invalid (not known to DNS) hostname",
+	                                           "nosuchhost" );
+
+
+
 	$res = NPTest->testCmd( "./$plugin" );
 	is( $res->return_code, 3, "No arguments" );
 	like( $res->output, '/usage/', "Output contains usage" );
@@ -47,13 +59,19 @@
 		cmp_ok( $res->return_code, '==', 0, "Exit OK for ifindex 1" ); 
 		like($res->output, '/^OK.*Interface.*is up/', "String contains OK Interface is up");
 
-		$res = NPTest->testCmd( "./$plugin -H $host_snmp -C $snmp_community -d lo");
-		cmp_ok( $res->return_code, '==', 0, "Exit OK for ifdescr lo" ); 
-		like($res->output, '/^OK.*Interface.*is up/', "String contains OK Interface is up");
+		SKIP: {
+			skip "no snmp interface defined", 2 if ( ! $snmp_interface );
+			$res = NPTest->testCmd( "./$plugin -H $host_snmp -C $snmp_community -d $snmp_interface");
+			cmp_ok( $res->return_code, '==', 0, "Exit OK for ifdescr $snmp_interface" );
+			like($res->output, '/^OK.*Interface.*is up/', "String contains OK Interface is up");
+		}
 
-		$res = NPTest->testCmd( "./$plugin -H $host_snmp -C $snmp_community -k 1 -n rubbish");
-		cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN if interface name doesn't match" ); 
-		like($res->output, '/doesn\'t match snmp value/', "String contains 'doesn't match snmp value'");
+		SKIP: {
+			skip "ifxtable not available", 2 if ( ! $snmp_ifxtable );
+			$res = NPTest->testCmd( "./$plugin -H $host_snmp -C $snmp_community -k 1 -n rubbish");
+			cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN if interface name doesn't match" ); 
+			like($res->output, '/doesn\'t match snmp value/', "String contains 'doesn't match snmp value'");
+		}
 
 	}
 

Modified: nagiosplug/trunk/plugins-scripts/t/check_ifstatus.t
===================================================================
--- nagiosplug/trunk/plugins-scripts/t/check_ifstatus.t	2009-06-11 15:30:28 UTC (rev 2220)
+++ nagiosplug/trunk/plugins-scripts/t/check_ifstatus.t	2009-06-13 09:20:16 UTC (rev 2221)
@@ -16,18 +16,20 @@
 SKIP: {
 	skip "$plugin is not created", $tests if ( ! -x $plugin );
 
-	my $host_snmp = getTestParameter( "host_snmp",          "NP_HOST_SNMP",      "localhost",
-	                                   "A host providing an SNMP Service");
+	my $host_snmp = getTestParameter( "NP_HOST_SNMP", "A host providing an SNMP Service", "localhost");
 
-	my $snmp_community = getTestParameter( "snmp_community",     "NP_SNMP_COMMUNITY", "public",
-                                           "The SNMP Community string for SNMP Testing (assumes snmp v1)" );
+	my $snmp_community = getTestParameter( "NP_SNMP_COMMUNITY",
+	                                       "The SNMP Community string for SNMP Testing (pick default rather than 'none' when no snmp host is available)",
+	                                       "public");
 
-	my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
-	                                           "The hostname of system not responsive to network requests" );
+	my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE",
+	                                           "The hostname of system not responsive to network requests", "10.0.0.1" );
 
-	my $hostname_invalid   = getTestParameter( "hostname_invalid",   "NP_HOSTNAME_INVALID",   "nosuchhost",
-	                                           "An invalid (not known to DNS) hostname" );
+	my $hostname_invalid   = getTestParameter( "NP_HOSTNAME_INVALID",
+	                                           "An invalid (not known to DNS) hostname",
+	                                           "nosuchhost" );
 
+
 	$res = NPTest->testCmd( "./$plugin" );
 	is( $res->return_code, 3, "No arguments" );
 	like( $res->output, '/usage/', "Output contains usage" );


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.