check_http.t 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #! /usr/bin/perl -w -I ..
  2. #
  3. # HyperText Transfer Protocol (HTTP) Test via check_http
  4. #
  5. # $Id$
  6. #
  7. use strict;
  8. use Test;
  9. use NPTest;
  10. use vars qw($tests);
  11. BEGIN {$tests = 4; plan tests => $tests}
  12. my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost",
  13. "A host providing the HTTP Service (a web server)" );
  14. my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
  15. "The hostname of system not responsive to network requests" );
  16. my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
  17. "An invalid (not known to DNS) hostname" );
  18. my $successOutput = '/(HTTP\s[o|O][k|K]\s)?\s?HTTP\/1.[01]\s[0-9]{3}\s(OK|Found)\s-\s+[0-9]+\sbytes\sin\s+([0-9]+|[0-9]+\.[0-9]+)\sseconds/';
  19. my %exceptions = ( 2 => "No Web Server present?" );
  20. my $t;
  21. $t += checkCmd( "./check_http $host_tcp_http -wt 300 -ct 600", { 0 => 'continue', 2 => 'skip' }, $successOutput, %exceptions );
  22. $t += checkCmd( "./check_http $host_nonresponsive -wt 1 -ct 2", 2 );
  23. $t += checkCmd( "./check_http $hostname_invalid -wt 1 -ct 2", 2 );
  24. exit(0) if defined($Test::Harness::VERSION);
  25. exit($tests - $t);