Apache-Test

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


Don't attempt to run the test suite as root.  The workarounds needed
to facilitate root testing cause large maintenance costs, and return
no tangible benefits.
[Fred Moyer]

=item 1.33 September 14, 2010

Propagate APACHE_TEST_NO_STICKY_PREFERENCES to the Apache environment
for mod_perl configurations (Apache::TestConfigPerl),
http://www.gossamer-threads.com/lists/modperl/dev/101929
[Torsten Foertsch]

Provide build/test environment for modules bundled with mod_perl like
Apache::Reload and Apache::SizeLimit
[Torsten Foertsch]

The CN in server certificates generated by Apache::TestSSLCA will now
match the servername passed to t/TEST.
[Joe Orton]

Changes  view on Meta::CPAN

When APACHE_TEST_NO_STICKY_PREFERENCES=1 is used don't even try to
interactively configure the server, as we don't save any config it was
entering an infinite loop. [Stas]

If a directory t/lib exists from where the tests are run, adjust
@INC so that this directory is added when running the tests,
both within t/TEST and within t/conf/modperl_inc.pl.
This allows inclusion of modules specific to the tests that 
aren't intended to be installed. [Stas, Randy]

make a special case for threaded mpm configuration, to ensure that
unless maxclients was specified, MaxClients will be exactly twice
bigger than ThreadsPerChild (minclients), since if we don't do that,
Apache will reduce MaxClients to the same value as
ThreadsPerChild. [Stas]

Renamed generate_test_script() to generate_script() in Apache::TestMB
to match the naming convention used in Apache::TestMM and elsewhere.
[David]

Apache::TestMB now only prints the "Generating test running script"

Changes  view on Meta::CPAN


Apache::Test now can run 'make test' under 'root', without permission
problems (e.g. when files need to be written), it'll chown all the
files under t/ to the user chosen to run the server with, before
running the tests and will restore the permissions at the end. [Stas]

don't inherit loading of the mod_perl object from the system-wide
config, since Apache::TestRunPerl already configures it [Stas]

Support two new shortcuts for skip functionality:
 - have_threads: checks whether both Apache and Perl support threads
 - under_construction: to print a consistent/clear skip reason
[Stas]

Support <NoAutoConfig> </NoAutoConfig> blocks in .pm files, so we can
have a full manual control over generated config sections. These
sections are fully parsed and variables are substituted, including
vhosts. [Stas]

Implement a more robust autogenerated client .t test in
Apache::TestConfigPerl. Before this fix if the server side returned

ToDo  view on Meta::CPAN

nd";

- general config: adjust Apache/TestConfig.pm not to write irrelevant
  httpd.conf sections (e.g. <IfModule prefork.c> for win32, and vice
  versa, A-T knows exactly what mpm it needs to write the config for).
  Thus reducing the clutter.

- winnt case: Apache/TestConfig.pm config for <IfModule mpm_winnt.c>
  before Apache-2.0.50 ThreadsPerChild had to be at least as big as
  the number of Vhosts. This was fixed in 2.0.50. Since A-T knows the
  httpd version, it shouldn't start so many threads for httpd >=
  2.0.50, but @MinClients@. Also add BACK_COMPAT_MARKER in the logic
  so when no longer support httpd < 2.0.50, this logic could be removed.

- sometimes the server aborts completely after the test suite has run
  some of the tests (e.g. win32's server has crashed and no
  replacement is available), but the client part continues to run
  tests unaware of that problem. what would be nice to be able to
  detect that the server is gone and somehow abort the test suite

- Custom sticky config: invalidate invalid bits of the saved config,

lib/Apache/Test.pm  view on Meta::CPAN

    delete $INC{'mod_perl.pm'};
}

use vars qw(@ISA @EXPORT %EXPORT_TAGS $VERSION %SubTests @SkipReasons);

$VERSION = '1.43';

my @need = qw(need_lwp need_http11 need_cgi need_access need_auth
              need_module need_apache need_min_apache_version need_min_apache_fix
              need_apache_version need_perl need_min_perl_version
              need_min_module_version need_threads need_fork need_apache_mpm
              need_php need_php4 need_ssl need_imagemap need_cache_disk);

my @have = map { (my $need = $_) =~ s/need/have/; $need } @need;

@ISA = qw(Exporter);
@EXPORT = (qw(sok plan skip_reason under_construction need),
           @need, @have);

%SubTests = ();
@SkipReasons = ();

lib/Apache/Test.pm  view on Meta::CPAN

        }
    }

    push @SkipReasons, $config ?
      "Perl was not built with $config enabled" :
        "$thing is not available with this version of Perl";

    return 0;
}

sub need_threads {
    my $status = 1;

    # check APR support
    my $build_config = Apache::TestConfig->modperl_build_config;

    if ($build_config) {
        my $apr_config = $build_config->get_apr_config();
        unless ($apr_config->{HAS_THREADS}) {
            $status = 0;
            push @SkipReasons, "Apache/APR was built without threads support";
        }
    }

    # check Perl's useithreads
    my $key = 'useithreads';
    unless (exists $Config{$key} and config_enabled($key)) {
        $status = 0;
        push @SkipReasons, "Perl was not built with 'ithreads' enabled";
    }

    return $status;
}

sub need_fork {
    my $have_fork = $Config{d_fork} ||
                    $Config{d_pseudofork} ||
                    (($^O eq 'MSWin32' || $^O eq 'NetWare') &&
                     $Config{useithreads} &&
                     $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/);

     if (!$have_fork) {
         push @SkipReasons, 'The fork function is unimplemented';
         return 0;
     }
     else {
         return 1;
     }
}

lib/Apache/Test.pm  view on Meta::CPAN


For example:

  plan tests => 5, need_apache_mpm('prefork');

requires the prefork MPM.

=item need_perl

  plan tests => 5, need_perl 'iolayers';
  plan tests => 5, need_perl 'ithreads';

Requires a perl extension to be present, or perl compiled with certain
capabilities.

The first example tests whether C<PerlIO> is available, the second
whether:

  $Config{useithread} eq 'define';

=item need_min_perl_version

Used to require a minimum version of Perl.

For example:

  plan tests => 5, need_min_perl_version("5.008001");

requires Perl 5.8.1 or higher.

lib/Apache/Test.pm  view on Meta::CPAN

  plan tests => 5, need_min_module_version(CGI => 2.81);

requires C<CGI.pm> version 2.81 or higher.

Currently works only for perl modules.

=item need

  plan tests => 5,
      need 'LWP',
           { "perl >= 5.8.0 and w/ithreads is required" =>
             ($Config{useperlio} && $] >= 5.008) },
           { "not Win32"                 => sub { $^O eq 'MSWin32' },
             "foo is disabled"           => \&is_foo_enabled,
           },
           'cgid';

need() is more generic function which can impose multiple requirements
at once. All requirements must be satisfied.

need()'s argument is a list of things to test. The list can include

lib/Apache/TestConfig.pm  view on Meta::CPAN

   bindir           => 'Apache bin/ dir (default is apxs -q BINDIR)',
   sbindir          => 'Apache sbin/ dir (default is apxs -q SBINDIR)',
   httpd            => 'server to use for testing (default is $bindir/httpd)',
   target           => 'name of server binary (default is apxs -q TARGET)',
   apxs             => 'location of apxs (default is from Apache2::BuildConfig)',
   startup_timeout  => 'seconds to wait for the server to start (default is 60)',
   httpd_conf       => 'inherit config from this file (default is apxs derived)',
   httpd_conf_extra => 'inherit additional config from this file',
   minclients       => 'minimum number of concurrent clients (default is 1)',
   maxclients       => 'maximum number of concurrent clients (default is minclients+1)',
   threadsperchild  => 'number of threads per child when using threaded MPMs (default is 10)',
   limitrequestline => 'global LimitRequestLine setting (default is 128)',
   perlpod          => 'location of perl pod documents (for testing downloads)',
   proxyssl_url     => 'url for testing ProxyPass / https (default is localhost)',
   sslca            => 'location of SSL CA (default is $t_conf/ssl/ca)',
   sslcaorg         => 'SSL CA organization to use for tests (default is asf)',
   sslproto         => 'SSL/TLS protocol version(s) to test',
   libmodperl       => 'path to mod_perl\'s .so (full or relative to LIBEXECDIR)',
   defines          => 'values to add as -D defines (for example, "VAR1 VAR2")',
   (map { $_ . '_module_name', "$_ module name"} qw(cgi ssl thread access auth php)),
);

my %filepath_conf_opts = map { $_ => 1 }
    qw(top_dir t_dir t_conf t_logs t_state t_pid_file t_conf_file src_dir serverroot
       documentroot bindir sbindir httpd apxs httpd_conf httpd_conf_extra
       perlpod sslca libmodperl);

sub conf_opt_is_a_filepath {
    my $opt = shift;
    $opt && exists $filepath_conf_opts{$opt};

lib/Apache/TestConfig.pm  view on Meta::CPAN


    $vars->{scheme}       ||= 'http';
    $vars->{servername}   ||= $self->default_servername;
    $vars->{port}           = $self->select_first_port;
    $vars->{remote_addr}  ||= $self->our_remote_addr;

    $vars->{user}         ||= $self->default_user;
    $vars->{group}        ||= $self->default_group;
    $vars->{serveradmin}  ||= $self->default_serveradmin;

    $vars->{threadsperchild} ||= 10;
    $vars->{minclients}   ||= 1;
    $vars->{maxclients_preset} = $vars->{maxclients} || 0;
    # if maxclients wasn't explicitly passed try to
    # prevent 'server reached MaxClients setting' errors
    $vars->{maxclients}   ||= $vars->{minclients} + 1;

    # if a preset maxclients valus is smaller than minclients,
    # maxclients overrides minclients
    if ($vars->{maxclients_preset} &&
        $vars->{maxclients_preset} < $vars->{minclients}) {

lib/Apache/TestConfig.pm  view on Meta::CPAN

    }
    if ($vars->{minclients} < 2) {
        $vars->{maxspare} = 2;
    } else {
        $vars->{maxspare} = $vars->{minclients};
    }
    if ($vars->{maxclients} < $vars->{maxspare} + 1) {
        $vars->{maxclients} = $vars->{maxspare} + 1;
    }

    # for threaded mpms MinClients and MaxClients must be a
    # multiple of ThreadsPerChild
    {
        use integer;
        $vars->{minclientsthreadedmpm} = ($vars->{minclients} + $vars->{threadsperchild} - 1) /
            $vars->{threadsperchild} * $vars->{threadsperchild};
        $vars->{maxclientsthreadedmpm} = ($vars->{maxclients} + $vars->{threadsperchild} - 1) /
            $vars->{threadsperchild} * $vars->{threadsperchild};
        $vars->{maxsparethreadedmpm} = ($vars->{maxspare} + $vars->{threadsperchild} - 1) /
            $vars->{threadsperchild} * $vars->{threadsperchild};
        $vars->{startserversthreadedmpm} = $vars->{minclientsthreadedmpm} / $vars->{threadsperchild};
    }
    if ($vars->{maxsparethreadedmpm} < 2 * $vars->{threadsperchild}) {
        $vars->{maxsparethreadedmpm} = 2 * $vars->{threadsperchild};
    }
    if ($vars->{maxclientsthreadedmpm} < $vars->{maxsparethreadedmpm} + $vars->{threadsperchild}) {
        $vars->{maxclientsthreadedmpm} = $vars->{maxsparethreadedmpm} + $vars->{threadsperchild};
    }

    $vars->{limitrequestline} ||= 128;
    $vars->{limitrequestlinex2} = 2 * $vars->{limitrequestline};

    $vars->{proxy}        ||= 'off';
    $vars->{proxyssl_url} ||= '';
    $vars->{defines}      ||= '';

    $self->{hostport} = $self->hostport;

lib/Apache/TestConfig.pm  view on Meta::CPAN


    }
    else {
        debug "Using httpd: $vars->{httpd}";
    }

    $self->inherit_config; #see TestConfigParse.pm
    $self->configure_httpd_eapi; #must come after inherit_config

    $self->default_module(cgi    => [qw(mod_cgi mod_cgid)]);
    $self->default_module(thread => [qw(worker threaded)]);
    $self->default_module(ssl    => [qw(mod_ssl)]);
    $self->default_module(access => [qw(mod_access mod_authz_host)]);
    $self->default_module(auth   => [qw(mod_auth mod_auth_basic)]);
    $self->default_module(php    => [qw(sapi_apache2 mod_php4 mod_php5)]);

    $self->{server}->post_config;

    return $self;
}

lib/Apache/TestConfig.pm  view on Meta::CPAN

sub configure_proxy {
    my $self = shift;
    my $vars = $self->{vars};

    #if we proxy to ourselves, must bump the maxclients
    if ($vars->{proxy} =~ /^on$/i) {
        unless ($vars->{maxclients_preset}) {
            $vars->{minclients}++;
            $vars->{maxclients}++;
            $vars->{maxspare}++;
            $vars->{startserversthreadedmpm} ++;
            $vars->{minclientsthreadedmpm} += $vars->{threadsperchild};
            $vars->{maxclientsthreadedmpm} += $vars->{threadsperchild};
            $vars->{maxsparethreadedmpm} += $vars->{threadsperchild};
            #In addition allow for some backend processes
            #in keep-alive state. For threaded MPMs we
            #already should be fine.
            $vars->{maxclients} += 3;
        }
        $vars->{proxy} = $self->{vhosts}->{'mod_proxy'}->{hostport};
        return $vars->{proxy};
    }

    return undef;
}

lib/Apache/TestConfig.pm  view on Meta::CPAN

        my $ssl = $self->{vhosts}->{ $vars->{ssl_module_name} };
        if ($ssl) {
            $vars->{proxyssl_url} ||= $ssl->{hostport};
        }

        if ($vars->{proxyssl_url}) {
            unless ($vars->{maxclients_preset}) {
                $vars->{minclients}++;
                $vars->{maxclients}++;
                $vars->{maxspare}++;
                $vars->{startserversthreadedmpm} ++;
                $vars->{minclientsthreadedmpm} += $vars->{threadsperchild};
                $vars->{maxclientsthreadedmpm} += $vars->{threadsperchild};
                $vars->{maxsparethreadedmpm} += $vars->{threadsperchild};
                #In addition allow for some backend processes
                #in keep-alive state. For threaded MPMs we
                #already should be fine.
                $vars->{maxclients} += 3;
            }
        }
    }
}

sub extra_conf_files_needing_update {
    my $self = shift;

lib/Apache/TestReport.pm  view on Meta::CPAN

    my $gdb = new Devel::GDB ();
    my $test_config = Apache::TestConfig->new({thaw=>1});
    my $httpd = $test_config->{vars}->{httpd};

    return unless defined $httpd;

    $core_dump .= join '',
           $gdb->get("file $httpd"),
           $gdb->get('sharedlibrary'),
           $gdb->get("core $core"),
           $gdb->get('info threads'),
           $gdb->get('thread apply all bt');
}

sub date { scalar gmtime() . " GMT" }

sub template {
<<'EOI'
-------------8<---------- Start Bug Report ------------8<----------
1. Problem Description:

  [DESCRIBE THE PROBLEM HERE]

lib/Apache/TestServer.pm  view on Meta::CPAN

    }

    return $dv;
}

sub config_defines {
    my $self = shift;

    my @defines = ();

    for my $item (qw(useithreads)) {
        next unless $Config{$item} and $Config{$item} eq 'define';
        push @defines, "-D PERL_\U$item";
    }

    if (my $defines = $self->{config}->{vars}->{defines}) {
        push @defines, map { "-D $_" } split " ", $defines;
    }

    "@defines";
}

lib/Apache/TestServer.pm  view on Meta::CPAN


    my $args   = $self->args;
    my $config = $self->{config};
    my $vars   = $config->{vars};
    my $httpd  = $vars->{httpd};

    my $one_process = $self->{run}->{opts}->{'one-process'}
        ? $self->version_of(\%one_process)
        : '';

    #XXX: threaded mpm does not respond to SIGTERM with -D ONE_PROCESS

    return "$httpd $one_process $args";
}

sub default_gdbinit {
    my $gdbinit = "";
    my @sigs = qw(PIPE);

    for my $sig (@sigs) {
        for my $flag (qw(pass nostop)) {



( run in 0.925 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )