You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by "Philip M. Gollucci" <pg...@p6m7g8.com> on 2006/08/03 13:41:41 UTC

Re: svn commit: r428355 - in /perl/Apache-SizeLimit/trunk/t: apache/check_n_requests.t apache/check_n_requests2.t response/TestApache/check_n_requests.pm response/TestApache/check_n_requests2.pm

Now,
  is there a way to programatically check the t/logs/error_log for the existance / non existance of the A::SL child
killed message ?  In the mean time, this at least exercises the code that caused David Wheeler's error.




pgollucci@apache.org wrote:
> Author: pgollucci
> Date: Thu Aug  3 04:33:24 2006
> New Revision: 428355
> 
> URL: http://svn.apache.org/viewvc?rev=428355&view=rev
> Log:
> Adding Tests for recent $class->_exit_if_too_big(shift) fix
> 
> 
> Added:
>     perl/Apache-SizeLimit/trunk/t/apache/check_n_requests.t
>     perl/Apache-SizeLimit/trunk/t/apache/check_n_requests2.t
>     perl/Apache-SizeLimit/trunk/t/response/TestApache/check_n_requests.pm
>     perl/Apache-SizeLimit/trunk/t/response/TestApache/check_n_requests2.pm
> 
> Added: perl/Apache-SizeLimit/trunk/t/apache/check_n_requests.t
> URL: http://svn.apache.org/viewvc/perl/Apache-SizeLimit/trunk/t/apache/check_n_requests.t?rev=428355&view=auto
> ==============================================================================
> --- perl/Apache-SizeLimit/trunk/t/apache/check_n_requests.t (added)
> +++ perl/Apache-SizeLimit/trunk/t/apache/check_n_requests.t Thu Aug  3 04:33:24 2006
> @@ -0,0 +1,11 @@
> +use strict;
> +use warnings FATAL => 'all';
> +
> +use Apache::Test;
> +use Apache::TestUtil;
> +use Apache::TestRequest;
> +
> +my $module = 'TestApache::check_n_requests';
> +my $url    = Apache::TestRequest::module2url($module);
> +
> +print GET_BODY_ASSERT $url;
> 
> Added: perl/Apache-SizeLimit/trunk/t/apache/check_n_requests2.t
> URL: http://svn.apache.org/viewvc/perl/Apache-SizeLimit/trunk/t/apache/check_n_requests2.t?rev=428355&view=auto
> ==============================================================================
> --- perl/Apache-SizeLimit/trunk/t/apache/check_n_requests2.t (added)
> +++ perl/Apache-SizeLimit/trunk/t/apache/check_n_requests2.t Thu Aug  3 04:33:24 2006
> @@ -0,0 +1,11 @@
> +use strict;
> +use warnings FATAL => 'all';
> +
> +use Apache::Test;
> +use Apache::TestUtil;
> +use Apache::TestRequest;
> +
> +my $module = 'TestApache::check_n_requests2';
> +my $url    = Apache::TestRequest::module2url($module);
> +
> +print GET_BODY_ASSERT $url;
> 
> Added: perl/Apache-SizeLimit/trunk/t/response/TestApache/check_n_requests.pm
> URL: http://svn.apache.org/viewvc/perl/Apache-SizeLimit/trunk/t/response/TestApache/check_n_requests.pm?rev=428355&view=auto
> ==============================================================================
> --- perl/Apache-SizeLimit/trunk/t/response/TestApache/check_n_requests.pm (added)
> +++ perl/Apache-SizeLimit/trunk/t/response/TestApache/check_n_requests.pm Thu Aug  3 04:33:24 2006
> @@ -0,0 +1,46 @@
> +package TestApache::check_n_requests;
> +
> +use strict;
> +use warnings;
> +
> +use Apache::Constants;
> +
> +use Apache::Test qw(-withtestmore);
> +use Apache::TestUtil;
> +
> +use Apache::SizeLimit;
> +
> +use constant ONE_MB    => 1024;
> +use constant TEN_MB    => ONE_MB * 10;
> +use constant TWENTY_MB => TEN_MB * 2;
> +
> +my $i = 0;
> +my %hash = ();
> +
> +sub handler {
> +    my $r = shift;
> +
> +    plan $r, tests => 10;
> +
> +    Apache::SizeLimit->add_cleanup_handler($r);
> +    Apache::SizeLimit->set_max_process_size(TEN_MB);
> +    ## this should cause us to fire
> +    Apache::SizeLimit->set_check_interval();
> +
> +    # We can assume this will use _at least_ 1MB of memory, based on
> +    # assuming a scalar consumes >= 1K.
> +    # and after 10 requests, we should be _at least_ 10MB of memory
> +    for (0..9) {
> +        my @big = ('x') x ONE_MB;
> +        $hash{$i++} = \@big;
> +        is(
> +           $i,
> +           $i,
> +           "now using $i MB of memory (at least)"
> +          );
> +    }
> +
> +    return Apache::Constants::OK;
> +}
> +
> +1;
> 
> Added: perl/Apache-SizeLimit/trunk/t/response/TestApache/check_n_requests2.pm
> URL: http://svn.apache.org/viewvc/perl/Apache-SizeLimit/trunk/t/response/TestApache/check_n_requests2.pm?rev=428355&view=auto
> ==============================================================================
> --- perl/Apache-SizeLimit/trunk/t/response/TestApache/check_n_requests2.pm (added)
> +++ perl/Apache-SizeLimit/trunk/t/response/TestApache/check_n_requests2.pm Thu Aug  3 04:33:24 2006
> @@ -0,0 +1,43 @@
> +package TestApache::check_n_requests2;
> +
> +use strict;
> +use warnings;
> +
> +use Apache::Constants;
> +use Apache::Log;
> +
> +use Apache::Test qw(-withtestmore);
> +
> +use Apache::SizeLimit;
> +
> +use constant ONE_MB    => 1024;
> +use constant TEN_MB    => ONE_MB * 10;
> +use constant TWENTY_MB => TEN_MB * 2;
> +
> +my $i = 0;
> +my %hash = ();
> +
> +sub handler {
> +    my $r = shift;
> +
> +    plan $r, tests => 10;
> +
> +    Apache::SizeLimit->add_cleanup_handler($r);
> +    Apache::SizeLimit->set_max_process_size(TEN_MB);
> +    ## this should cause us _NOT_ to fire
> +    Apache::SizeLimit->set_check_interval(5);
> +
> +    # We can assume this will use _at least_ 1MB of memory, based on
> +    # assuming a scalar consumes >= 1K.
> +    # and after 10 requests, we should be _at least_ 10MB of memory
> +    for (0..9) {
> +        my @big = ('x') x ONE_MB;
> +        $hash{$i++} = \@big;
> +
> +        is($i, $i, "now using $i MB of memory (at least)");
> +    }
> +
> +    return Apache::Constants::OK;
> +}
> +
> +1;
> 


-- 
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/A79997FA F357 0FDD 2301 6296 690F  6A47 D55A 7172 A799 97F

"In all that I've done wrong I know I must have done something right to
deserve a hug every morning and butterfly kisses at night."

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: svn commit: r428355 - in /perl/Apache-SizeLimit/trunk/t: apache/check_n_requests.t apache/check_n_requests2.t response/TestApache/check_n_requests.pm response/TestApache/check_n_requests2.pm

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Philip M. Gollucci wrote:
> Now,
>   is there a way to programatically check the t/logs/error_log for the existance / non existance of the A::SL child
> killed message ?  In the mean time, this at least exercises the code that caused David Wheeler's error.

I _swore_ that stas had something for this, but I couldn't find it last
I looked.  stas?

--Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: svn commit: r428355 - in /perl/Apache-SizeLimit/trunk/t: apache/check_n_requests.t apache/check_n_requests2.t response/TestApache/check_n_requests.pm response/TestApache/check_n_requests2.pm

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Torsten Foertsch wrote:
> On Thursday 03 August 2006 13:41, Philip M. Gollucci wrote:
>> Now,
>>   is there a way to programatically check the t/logs/error_log for the
>> existance / non existance of the A::SL child killed message ?  In the mean
>> time, this at least exercises the code that caused David Wheeler's error.
Thanks.  I've not heard anything from Stas, so I'm in favor of adding this to Apache-Test.
any reason you didn't use SEEK_CUR instead of 2 ?

Of course we'll then have to add need_Apache_Test 1.29+ for this test.

> 
> In one of my tests I use this:
> 
> {
>   my $f;
>   sub t_start_error_log_watch {
>     my $name=File::Spec->catfile( Apache::Test::vars->{t_logs}, 'error_log' );
>     open $f, "$name" or die "ERROR: Cannot open $name: $!\n";
>     seek $f, 0, 2;
>   }
> 
>   sub t_finish_error_log_watch {
>     local $/="\n";
>     my @lines=<$f>;
>     undef $f;
>     return @lines;
>   }
> }
> 
> then
> 
> t_start_error_log_watch;
> do_it;
> ok grep {...} t_finish_error_log_watch;
> 
> Torsten


-- 
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/A79997FA F357 0FDD 2301 6296 690F  6A47 D55A 7172 A799 97F

"In all that I've done wrong I know I must have done something right to
deserve a hug every morning and butterfly kisses at night."

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: svn commit: r428355 - in /perl/Apache-SizeLimit/trunk/t: apache/check_n_requests.t apache/check_n_requests2.t response/TestApache/check_n_requests.pm response/TestApache/check_n_requests2.pm

Posted by Torsten Foertsch <to...@gmx.net>.
On Thursday 03 August 2006 13:41, Philip M. Gollucci wrote:
> Now,
>   is there a way to programatically check the t/logs/error_log for the
> existance / non existance of the A::SL child killed message ?  In the mean
> time, this at least exercises the code that caused David Wheeler's error.

In one of my tests I use this:

{
  my $f;
  sub t_start_error_log_watch {
    my $name=File::Spec->catfile( Apache::Test::vars->{t_logs}, 'error_log' );
    open $f, "$name" or die "ERROR: Cannot open $name: $!\n";
    seek $f, 0, 2;
  }

  sub t_finish_error_log_watch {
    local $/="\n";
    my @lines=<$f>;
    undef $f;
    return @lines;
  }
}

then

t_start_error_log_watch;
do_it;
ok grep {...} t_finish_error_log_watch;

Torsten