You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by David Arnold <da...@northcoast.com> on 2004/07/02 21:04:26 UTC
Strange
All,
I get so confused keeping track of everything. I've got some modules that I
swear checked for syntax a few days ago. Here's one that starts:
package Apache::AuthAnon;
# file: Apache/AuthAnon.pm
use strict;
use Apache::Constants qw(:common);
my $email_pat='[.\w-]+\@\w+\.[.\w]*[^.]';
my $anon_id="anonymous";
sub handler {
my $r=shift;
my($res,$sent_pwd)=$r->get_basic_auth_pw;
return $res if $res!=OK;
my $user=lc $r->connection->user;
my $reason="";
my $check_id=$r->dir_config("Anonymous") || $anon_id;
$reason="user did not enter a valid anonymous username: "
But this morning, suddenly I can't check the syntax:
[darnold@ps-114a-2k Apache]$perl -wc AuthAny.pm
Can't locate Apache/Constants.pm in @INC (@INC contains:
/usr/lib/perl5/5.8.4/i686-linux-thread-multi /usr/lib/perl5/5.8.4
/usr/lib/perl5/site_perl/5.8.4/i686-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.6.1
/usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at AuthAny.pm
line 5.
BEGIN failed--compilation aborted at AuthAny.pm line 5.
I've got the following in my httpd.conf:
LoadModule perl_module modules/mod_perl.so
PerlModule Apache2
PerlModule Apache::compat
<Location /protected>
PerlOptions +GlobalRequest
AuthName Anonymous
AuthType Basic
PerlAuthenHandler Apache::AuthAnon
require valid-user
PerlSetVar Anonymous anonymous|anybody
</Location>
So the handler runs fine and does what it should. I tried changing to:
use Apache::Const qw(:common);
But that didn't work either.
[darnold@ps-114a-2k Apache]$perl -wc AuthAnon.pm
Can't locate Apache/Const.pm in @INC (@INC contains:
/usr/lib/perl5/5.8.4/i686-linux-thread-multi /usr/lib/perl5/5.8.4
/usr/lib/perl5/site_perl/5.8.4/i686-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.6.1
/usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at AuthAnon.pm
line 5.
BEGIN failed--compilation aborted at AuthAnon.pm line 5.
Here's where the file is on my system:
[root@ps-114a-2k apache2]$locate Apache/Const.pm
/usr/lib/perl5/site_perl/5.8.4/i686-linux-thread-multi/Apache2/Apache/Const.pm
Should I add /usr/lib/perl5/site_perl/5.8.4/i686-linux-thread-multi/Apache2
to @INC?
What's the best way to do I do that on a permanent basis?
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Strange
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> May be we should use a more generic name for those tarballs? So that you
> don't have to explain that it's useful for other things as well?
>
> e.g., test-suite-skeleton-mp(1).tar.gz?
I probably should create a separate package for that, including pointers to
A-T documentation and placeholders for modules and other foo that aren't
named "bug".
I'll report back when I have some skeletons available.
--Geoff
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Strange
Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>>I'd recommend reading Geoffrey's article on perl.com[1] before launching
>>into the perl.apache.org documentation.
>
>
> thanks :)
>
> note that the article has links to other sources of documentation at the end
> as well.
>
>
>>Geoffrey has also put together a
>>skeleton for testing which I cannot find a link to at present.
>
>
> http://perl.apache.org/~geoff/bug-reporting-skeleton-mp2.tar.gz
>
> while the name indicates it is for bugs, I use it as the starting point for
> all the Apache-Test-based modules I write now.
May be we should use a more generic name for those tarballs? So that you don't
have to explain that it's useful for other things as well?
e.g., test-suite-skeleton-mp(1).tar.gz?
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Strange
Posted by William McKee <wi...@knowmad.com>.
On Tue, Jul 06, 2004 at 01:09:01PM -0400, Geoffrey Young wrote:
> > Geoffrey has also put together a
> > skeleton for testing which I cannot find a link to at present.
>
> http://perl.apache.org/~geoff/bug-reporting-skeleton-mp2.tar.gz
>
> while the name indicates it is for bugs, I use it as the starting point for
> all the Apache-Test-based modules I write now.
For those of us stilling using mp1, he also has a skeleton for that
system at:
http://perl.apache.org/~geoff/bug-reporting-skeleton-mp1.tar.gz
William
--
Knowmad Services Inc.
http://www.knowmad.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Strange
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> I'd recommend reading Geoffrey's article on perl.com[1] before launching
> into the perl.apache.org documentation.
thanks :)
note that the article has links to other sources of documentation at the end
as well.
> Geoffrey has also put together a
> skeleton for testing which I cannot find a link to at present.
http://perl.apache.org/~geoff/bug-reporting-skeleton-mp2.tar.gz
while the name indicates it is for bugs, I use it as the starting point for
all the Apache-Test-based modules I write now.
HTH
--Geoff
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Strange
Posted by William McKee <wi...@knowmad.com>.
On Fri, Jul 02, 2004 at 05:59:11PM -0400, Perrin Harkins wrote:
> It's on CPAN. Geoffrey Young announced the latest release on this list
> four days ago.
Hi David,
I'd recommend reading Geoffrey's article on perl.com[1] before launching
into the perl.apache.org documentation. Geoffrey has also put together a
skeleton for testing which I cannot find a link to at present. Try
searching the archives of the test-dev mailing list[2] or perhaps
someone on the list can post the location of those resources.
Good luck,
William
[1] http://www.perl.com/pub/a/2003/05/22/testing.html
[2] http://httpd.apache.org/test/
--
Knowmad Services Inc.
http://www.knowmad.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Strange
Posted by Stas Bekman <st...@stason.org>.
Perrin Harkins wrote:
> On Fri, 2004-07-02 at 17:18, David Arnold wrote:
>
>>I did a little searching and saw very little on Apache-Test.
>
>
> Really? It's all over the mod_perl site. This would be a good place to
> start:
> http://perl.apache.org/docs/general/testing/testing.html
>
>
>>Is it a current CVS project?
>
>
> It's on CPAN. Geoffrey Young announced the latest release on this list
> four days ago.
Thanks Perrin.
From Apache-Test/README:
#########
# About #
#########
Apache::Test is a test toolkit for testing an Apache server with any
configuration. It works with Apache 1.3 and Apache 2.0 and any of its
modules, including mod_perl 1.0 and 2.0. It was originally developed
for testing mod_perl 2.0.
#################
# Documentation #
#################
For an extensive documentation see the tutorial:
http://perl.apache.org/docs/general/testing/testing.html
and the documentation of the specific Apache::Test modules, which can
be read using 'perldoc', for example:
% perldoc Apache::TestUtil
and the 'Testing mod_perl 2.0' article:
http://www.perl.com/pub/a/2003/05/22/testing.html
###################
# Got a question? #
###################
Post it to the test-dev <at> httpd.apache.org list. The list is
moderated, so unless you are subscribed to it it may take some time
for your post to make it to the list.
For more information see: http://httpd.apache.org/test/.
List's archive http://marc.theaimsgroup.com/?l=apache-test-dev
##############
# Cheat List #
##############
see Makefile.PL for howto enable 'make test'
see t/TEST as an example test harness
see t/*.t for example tests
if the file t/conf/httpd.conf.in exists, it will be used instead of
the default template (in Apache/TestConfig.pm);
if the file t/conf/extra.conf.in exists, it will be used to generate
t/conf/extra.conf with @variable@ substitutions
if the file t/conf/extra.conf exists, it will be included by
httpd.conf
if the file t/conf/modperl_extra.pl exists, it will be included by
httpd.conf as a mod_perl file (PerlRequire)
##################
# Handy examples #
##################
some examples of what i find handy:
see TEST -help for more options
test verbosely
% t/TEST -verbose
start the server
% t/TEST -start
run just this test (if server is running, will not be re-started)
% t/TEST t/apr/table
run just the apr tests
% t/TEST t/apr
run all tests without start/stop of server (e.g. server was started with -d)
% t/TEST -run
stop the server
% t/TEST -stop
ping the server to see whether it runs
% t/TEST -ping
ping the server and wait until the server starts, report waiting time
% t/TEST -ping=block
reconfigure the server, do not run tests
% t/TEST -configure
run as user nobody:
% t/TEST -User nobody
run on a different port:
% t/TEST -Port 8799
let the program pick the next available port (useful when running a
few test sessions on parallel)
% t/TEST -Port select
run on a different server:
% t/TEST -servername example.com
configure an httpd other than the default (that apxs figures out)
% t/TEST -httpd ~/ap/httpd-2.0/httpd
configure a DSO mod_perl object other than the default (that stored in
Apache::BuildConfig)
% t/TEST -libmodperl ~/ap/httpd-2.0/modules/mod_perl-5.8.0.so
or one that can be found relative to LIBEXECDIR
% t/TEST -libmodperl mod_perl-5.6.1.so
switch to another apxs
% t/TEST -apxs ~/ap/httpd-2.0-prefork/bin/apxs
turn on tracing
% t/TEST -preamble "PerlTrace all"
GET url
% t/TEST -get /server-info
HEAD url
% t/TEST -head /server-info
HEAD (no url defaults to /)
% t/TEST -head
GET url with authentication credentials
% t/TEST -get /server-info -username dougm -password foo
POST url (read content from string)
% t/TEST -post /TestApache::post -content 'name=dougm&company=covalent'
POST url (read content from stdin)
% t/TEST -post /TestApache::post -content - < foo.txt
POST url (generate a body of data 1024 bytes in length)
% t/TEST -post /TestApache::post -content x1024
POST url (only print headers, e.g. useful to just check Content-length)
% t/TEST -post -head /TestApache::post -content x100000
GET url (only print headers, e.g. useful to just check Content-length)
% t/TEST -get -head /foo
start server under gdb
% t/TEST -debug
start server under strace (outputs to t/logs/strace.log)
% t/TEST -d strace
run .t test under the perl debugger
% t/TEST -d perl t/modules/access.t
run .t test under the perl debugger (nonstop mode, output to t/logs/perldb.out)
% t/TEST -d perl=nostop t/modules/access.t
control how much noise Apache::Test should produce. to print all the
debug messages:
% t/TEST -trace=debug
to print only warnings and higher trace levels:
% t/TEST -trace=warning
the available modes are:
emerg alert crit error warning notice info debug
turn on -v and LWP trace (1 is the default) mode in Apache::TestRequest
% t/TEST -d lwp t/modules/access.t
turn on -v and LWP trace mode (level 2) in Apache::TestRequest
% t/TEST -d lwp=2 t/modules/access.t
run all tests through mod_ssl
% t/TEST -ssl
run all tests with HTTP/1.1 (keep alive) requests
% t/TEST -http11 -ssl
run all tests with HTTP/1.1 (keep alive) requests through mod_ssl
% t/TEST -http11
run all tests through mod_proxy
% t/TEST -proxy
##################
# Stress testing #
##################
run all tests 10 times in a random order (the seed is autogenerated
and reported)
% t/TEST -times=10 -order=random
run all tests 10 times in a random order using the seed obtained from
the previous random run (e.g. 2352211):
% t/TEST -times=10 -order=2352211
rotate all tests 10 times (a, b, c, a, b, c)
% t/TEST -times=10 -order=rotate
repeat all tests 10 times (a, a, b, b, c, c)
% t/TEST -times=10 -order=repeat
When certain tests fail when running with -times option, you want to
find out the minimal sequence of tests that lead to the
failure. Apache::TestSmoke helps to ease this task, simply run:
% t/SMOKE
which tries various sequences of tests and at the end reports the
shortest sequences found that lead to the same failure.
for more options do:
% t/SMOKE -help
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Strange
Posted by Perrin Harkins <pe...@elem.com>.
On Fri, 2004-07-02 at 17:18, David Arnold wrote:
> I did a little searching and saw very little on Apache-Test.
Really? It's all over the mod_perl site. This would be a good place to
start:
http://perl.apache.org/docs/general/testing/testing.html
> Is it a current CVS project?
It's on CPAN. Geoffrey Young announced the latest release on this list
four days ago.
- Perrin
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Strange
Posted by David Arnold <da...@northcoast.com>.
Stas,
>Again, do not test your modperl code w/o running modperl, which you
accomplish
>with help of Apache-Test.
I did a little searching and saw very little on Apache-Test. Is it a
current CVS project? If so, I've never participated or downloaded such a
thing.
However, you seem to think it would help me in my work, so maybe I should
give it a try.
How do I start?
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Strange
Posted by Stas Bekman <st...@stason.org>.
David Arnold wrote:
> Stas,
>
>
>>>package Apache::AuthAnon;
>>># file: Apache/AuthAnon.pm
>>>
>>>use strict;
>>>use Apache::Constants qw(:common);
>>>
>>>my $email_pat='[.\w-]+\@\w+\.[.\w]*[^.]';
>>>my $anon_id="anonymous";
>>>
>>>sub handler {
>>> my $r=shift;
>>>
>>> my($res,$sent_pwd)=$r->get_basic_auth_pw;
>>> return $res if $res!=OK;
>>>
>>> my $user=lc $r->connection->user;
>>> my $reason="";
>>>
>>> my $check_id=$r->dir_config("Anonymous") || $anon_id;
>>>
>>> $reason="user did not enter a valid anonymous username: "
>>>
>>
>>Because you didn't load the right modules. Try again with:
>>
>>perl -wc -MApache2 -MApache::compat AuthAny.pm
>>
>>in general it's not possible to test code relying on mod_perl run time from
>>the command line.
>
>
> I got this:
>
> [darnold@ps-114a-2k Apache]$perl -wc -MApache2 -MApache::compat AuthAny.pm
> Bareword "Apache::server_root" not allowed while "strict subs" in use at
> /usr/lib/perl5/site_perl/5.8.4/i686-linux-thread-multi/Apache2/Apache/compat
> .pm line 255.
> Compilation failed in require.
> BEGIN failed--compilation aborted.
>
> Is this right?
Yes, David, this is right for the majority of the API.
Again, do not test your modperl code w/o running modperl, which you accomplish
with help of Apache-Test.
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Strange
Posted by David Arnold <da...@northcoast.com>.
Stas,
>> package Apache::AuthAnon;
>> # file: Apache/AuthAnon.pm
>>
>> use strict;
>> use Apache::Constants qw(:common);
>>
>> my $email_pat='[.\w-]+\@\w+\.[.\w]*[^.]';
>> my $anon_id="anonymous";
>>
>> sub handler {
>> my $r=shift;
>>
>> my($res,$sent_pwd)=$r->get_basic_auth_pw;
>> return $res if $res!=OK;
>>
>> my $user=lc $r->connection->user;
>> my $reason="";
>>
>> my $check_id=$r->dir_config("Anonymous") || $anon_id;
>>
>> $reason="user did not enter a valid anonymous username: "
>>
>Because you didn't load the right modules. Try again with:
>
>perl -wc -MApache2 -MApache::compat AuthAny.pm
>
>in general it's not possible to test code relying on mod_perl run time from
>the command line.
I got this:
[darnold@ps-114a-2k Apache]$perl -wc -MApache2 -MApache::compat AuthAny.pm
Bareword "Apache::server_root" not allowed while "strict subs" in use at
/usr/lib/perl5/site_perl/5.8.4/i686-linux-thread-multi/Apache2/Apache/compat
.pm line 255.
Compilation failed in require.
BEGIN failed--compilation aborted.
Is this right?
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Strange
Posted by Stas Bekman <st...@stason.org>.
David Arnold wrote:
> All,
>
> I get so confused keeping track of everything. I've got some modules that I
> swear checked for syntax a few days ago. Here's one that starts:
>
> package Apache::AuthAnon;
> # file: Apache/AuthAnon.pm
>
> use strict;
> use Apache::Constants qw(:common);
>
> my $email_pat='[.\w-]+\@\w+\.[.\w]*[^.]';
> my $anon_id="anonymous";
>
> sub handler {
> my $r=shift;
>
> my($res,$sent_pwd)=$r->get_basic_auth_pw;
> return $res if $res!=OK;
>
> my $user=lc $r->connection->user;
> my $reason="";
>
> my $check_id=$r->dir_config("Anonymous") || $anon_id;
>
> $reason="user did not enter a valid anonymous username: "
>
> But this morning, suddenly I can't check the syntax:
>
> [darnold@ps-114a-2k Apache]$perl -wc AuthAny.pm
> Can't locate Apache/Constants.pm in @INC (@INC contains:
> /usr/lib/perl5/5.8.4/i686-linux-thread-multi /usr/lib/perl5/5.8.4
> /usr/lib/perl5/site_perl/5.8.4/i686-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.6.1
> /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at AuthAny.pm
> line 5.
> BEGIN failed--compilation aborted at AuthAny.pm line 5.
Because you didn't load the right modules. Try again with:
perl -wc -MApache2 -MApache::compat AuthAny.pm
in general it's not possible to test code relying on mod_perl run time from
the command line.
> I've got the following in my httpd.conf:
>
> LoadModule perl_module modules/mod_perl.so
> PerlModule Apache2
> PerlModule Apache::compat
[...]
> What's the best way to do I do that on a permanent basis?
Write a test suite using Apache-Test, as many modules are moving to.
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html