cvs commit: modperl-2.0/Apache-Test/lib/Apache TestServer.pm

2001-07-23 Thread dougm

dougm   01/07/23 13:31:23

  Modified:Apache-Test/lib/Apache TestServer.pm
  Log:
  avoid cannot connect ... warnings when waiting for server to warmup
  
  Revision  ChangesPath
  1.13  +4 -1  modperl-2.0/Apache-Test/lib/Apache/TestServer.pm
  
  Index: TestServer.pm
  ===
  RCS file: /home/cvs/modperl-2.0/Apache-Test/lib/Apache/TestServer.pm,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- TestServer.pm 2001/07/20 01:48:11 1.12
  +++ TestServer.pm 2001/07/23 20:31:23 1.13
  @@ -346,7 +346,10 @@
   return 0;
   }
   
  -my $server_up = sub { $self-{config}-http_raw_get('/index.html') };
  +my $server_up = sub {
  +local $SIG{__WARN__} = sub {}; #avoid cannot connect ... warnings
  +$self-{config}-http_raw_get('/index.html');
  +};
   
   if ($server_up-()) {
   return 1;
  
  
  



cvs commit: modperl-2.0/Apache-Test/lib/Apache TestServer.pm

2001-07-23 Thread dougm

dougm   01/07/23 13:38:22

  Modified:Apache-Test/lib/Apache TestServer.pm
  Log:
  wait a bit longer for test server to start
  
  Revision  ChangesPath
  1.14  +1 -1  modperl-2.0/Apache-Test/lib/Apache/TestServer.pm
  
  Index: TestServer.pm
  ===
  RCS file: /home/cvs/modperl-2.0/Apache-Test/lib/Apache/TestServer.pm,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TestServer.pm 2001/07/23 20:31:23 1.13
  +++ TestServer.pm 2001/07/23 20:38:22 1.14
  @@ -310,7 +310,7 @@
   $mpm = ($mpm MPM) if $mpm;
   print using $version $mpm\n;
   
  -my $tries = 6;
  +my $tries = 8;
   
   for (1..$tries) {
   my $pid = $self-pid;
  
  
  



cvs commit: modperl-2.0/Apache-Test/lib/Apache TestServer.pm

2001-04-10 Thread dougm

dougm   01/04/10 09:48:50

  Modified:Apache-Test/lib/Apache TestServer.pm
  Log:
  include -d ServerRoot in the args to start test httpd
  
  Revision  ChangesPath
  1.4   +2 -1  modperl-2.0/Apache-Test/lib/Apache/TestServer.pm
  
  Index: TestServer.pm
  ===
  RCS file: /home/cvs/modperl-2.0/Apache-Test/lib/Apache/TestServer.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestServer.pm 2001/04/03 17:17:10 1.3
  +++ TestServer.pm 2001/04/10 16:48:49 1.4
  @@ -57,7 +57,8 @@
   
   sub args {
   my $self = shift;
  -"-f $self-{config}-{vars}-{t_conf_file}";
  +my $vars = $self-{config}-{vars};
  +"-d $vars-{serverroot} -f $vars-{t_conf_file}";
   }
   
   my %one_process = (1 = '-X', 2 = '-DONE_PROCESS');
  
  
  



cvs commit: modperl-2.0/Apache-Test/lib/Apache TestServer.pm

2001-04-02 Thread dougm

dougm   01/04/02 01:58:38

  Added:   Apache-Test/lib/Apache TestServer.pm
  Log:
  methods to configure/control test server
  
  Revision  ChangesPath
  1.1  modperl-2.0/Apache-Test/lib/Apache/TestServer.pm
  
  Index: TestServer.pm
  ===
  package Apache::TestServer;
  
  use strict;
  use warnings FATAL = 'all';
  
  use Socket ();
  use File::Spec::Functions qw(catfile);
  
  use Apache::TestConfig ();
  
  sub trace {
  shift-{config}-trace(@_);
  }
  
  sub new {
  my $class = shift;
  my $config = shift;
  
  my $self = bless {
  config = $config || Apache::TestConfig-thaw,
  }, $class;
  
  $self-{name} = join ':',
map { $self-{config}-{vars}-{$_} } qw(servername port);
  
  $self-{port_counter} = $self-{config}-{vars}-{port};
  
  $self-{version} = $self-{config}-httpd_version || '';
  ($self-{rev}) = $self-{version} =~ m:^Apache/(\d)\.:;
  $self-{rev} ||= 2;
  
  $self;
  }
  
  sub version_of {
  my($self, $thing) = @_;
  $thing-{$self-{rev}};
  }
  
  sub clean {
  my $self = shift;
  
  my $dir = $self-{config}-{vars}-{t_logs};
  
  for (qw(error_log access_log httpd.pid)) {
  my $file = catfile $dir, $_;
  if (unlink $file) {
  $self-trace("unlink $file");
  }
  }
  }
  
  sub pid_file {
  my $self = shift;
  catfile $self-{config}-{vars}-{t_logs}, 'httpd.pid';
  }
  
  sub args {
  my $self = shift;
  "-f $self-{config}-{vars}-{t_conf_file}";
  }
  
  my %one_process = (1 = '-X', 2 = '-DONE_PROCESS');
  
  sub start_cmd {
  my $self = shift;
  #XXX: threaded mpm does not respond to SIGTERM with -DONE_PROCESS
  my $one = $self-{rev} == 1 ? '-X' : '';
  my $args = $self-args;
  return "$self-{config}-{vars}-{httpd} $one $args";
  }
  
  sub start_gdb {
  my $self = shift;
  
  my $config = $self-{config};
  my $args = $self-args;
  my $one_process = $self-version_of(\%one_process);
  
  my $file = catfile $config-{vars}-{serverroot}, '.gdb-test-start';
  my $fh = $config-genfile($file);
  print $fh "run $one_process $args";
  close $fh;
  
  system "gdb $config-{vars}-{httpd} -command $file";
  
  unlink $file;
  }
  
  sub start_debugger {
  shift-start_gdb; #XXX support dbx and others
  }
  
  sub pid {
  my $self = shift;
  my $file = $self-pid_file;
  open my $fh, $file or do {
  return 0;
  };
  chomp(my $pid = $fh);
  $pid;
  }
  
  sub select_port {
  my $self = shift;
  
  my $max_tries = 100; #XXX
  
  while (! $self-port_available(++$self-{port_counter})) {
  return 0 if --$max_tries = 0;
  }
  
  return $self-{port_counter};
  }
  
  sub port_available {
  my $self = shift;
  my $port = shift || $self-{config}-{vars}-{port};
  local *S;
  
  my $proto = getprotobyname('tcp');
  
  socket(S, Socket::PF_INET(),
 Socket::SOCK_STREAM(), $proto) || die "socket: $!";
  setsockopt(S, Socket::SOL_SOCKET(),
 Socket::SO_REUSEADDR(),
 pack("l", 1)) || die "setsockopt: $!";
  
  if (bind(S, Socket::sockaddr_in($port, Socket::INADDR_ANY( {
  close S;
  return 1;
  }
  else {
  return 0;
  }
  }
  
  sub stop {
  my $self = shift;
  my $aborted = shift;
  
  my $pid = 0;
  my $tries = 3;
  my $tried_kill = 0;
  
  my $port = $self-{config}-{vars}-{port};
  
  while ($self-ping) {
  #my $state = $tried_kill ? "still" : "already";
  #print "Port $port $state in use\n";
  
  if ($pid = $self-pid and !$tried_kill++) {
  if (kill TERM = $pid) {
  print "server $self-{name} shutdown (pid=$pid)\n";
  sleep 1;
  
  for (1..4) {
  if (! $self-ping) {
  return $pid if $_ == 1;
  last;
  }
  if ($_ == 1) {
  print "port $port still in use...";
  }
  else {
  print "...";
  }
  sleep $_;
  }
  
  if ($self-ping) {
  print "\nserver was shutdown but port $port ",
"is still in use, please shutdown the service ",
"using this port or select another port ",
"for the tests\n";
  }
  else {
  print "done\n";
  }
  }
  else {
  print "kill $pid failed: $!\n";
  }
  }
  else {
  print "port $port is in use, ",
"cannot