Author: stas Date: Mon Dec 20 15:42:20 2004 New Revision: 122906 URL: http://svn.apache.org/viewcvs?view=rev&rev=122906 Log: - fix a bug in A-T config generation, when a vhost entry was in autogenerated httpd.conf (e.g. coming from .pm file) and another from extra.conf.in. We used to have a ports collision, since extra.conf wasn't reparsed and the same port was getting assigned to more than one vhost entry, preventing server startup: default_ VirtualHost overlap on port 8530, the first has precedence (98)Address already in use: make_sock: could not bind to address 0.0.0.0:8530 no listening sockets available, shutting down could be reproduced with t/TEST -conf followed by t/TEST -maxclients 1 in the mp2 test suite (or the new Apache-TestMe test suite, which now includes a special setup for this bug). - added a test reproducing this problem in Apache-TestItSelf - added the setup required to reproduce this problem in Apache-TestMe
Added: httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/basic/vhost.t (contents, props changed) httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/extra.conf.in httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/response/TestBasic/Vhost.pm (contents, props changed) httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/t/minmaxclients.t (contents, props changed) Modified: httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/ (props changed) httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Changes httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/ (props changed) httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Changes httpd/test/trunk/perl-framework/Apache-Test/Changes httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm Modified: httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Changes Url: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Changes?view=diff&rev=122906&p1=httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Changes&r1=122905&p2=httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Changes&r2=122906 ============================================================================== --- httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Changes (original) +++ httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/Changes Mon Dec 20 15:42:20 2004 @@ -8,9 +8,13 @@ =item 0.01 -write a basic mod_perl test: basic/hello.t +new test basic/vhost.t which introduces a vhost entry in .pm. also +added a dummy vhost entry in t/conf/extra.conf.in, the setup needed by +t/minmaxclients.t from Apache-TestItSelf [Stas] -starting the config test suite used by Apache::TestItSelf +write a basic mod_perl test: basic/hello.t [Stas] + +starting the config test suite used by Apache::TestItSelf [Stas] =back Added: httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/basic/vhost.t Url: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/basic/vhost.t?view=auto&rev=122906 ============================================================================== --- (empty file) +++ httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/basic/vhost.t Mon Dec 20 15:42:20 2004 @@ -0,0 +1,7 @@ +use Apache::TestUtil; +use Apache::TestRequest 'GET_BODY_ASSERT'; + +my $module = 'TestBasic::Vhost'; +my $url = Apache::TestRequest::module2url($module); +t_debug("connecting to $url"); +print GET_BODY_ASSERT $url; Added: httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/extra.conf.in Url: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/extra.conf.in?view=auto&rev=122906 ============================================================================== --- (empty file) +++ httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/conf/extra.conf.in Mon Dec 20 15:42:20 2004 @@ -0,0 +1,16 @@ +# this vhost entry is needed to check that when t/TEST -maxclients 1 +# or similar is called after t/TEST -conf was run, and extra.conf +# includes a vhost entry and httpd.conf includes an autogenerated +# vhost entry from some .pm file, we used to have a collision, since +# extra.conf wasn't reparsed and the same port was getting assigned to +# more than one vhost entry, preventing server startup: +# +#default_ VirtualHost overlap on port 8530, the first has precedence +#(98)Address already in use: make_sock: could not bind to address +#0.0.0.0:8530 no listening sockets available, shutting down +# +# XXX: for now using a dummy vhost entry. later if needed to put a +# real vhost entry in ths file, the dummy one can be removed +# +<VirtualHost foo_bar_tar> +</VirtualHost> Added: httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/response/TestBasic/Vhost.pm Url: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/response/TestBasic/Vhost.pm?view=auto&rev=122906 ============================================================================== --- (empty file) +++ httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Apache-TestMe/t/response/TestBasic/Vhost.pm Mon Dec 20 15:42:20 2004 @@ -0,0 +1,28 @@ +package TestBasic::Vhost; + +use Apache::Const -compile => qw(OK); +use Apache::Test; + +# XXX: adjust the test that it'll work under mp1 as well + +sub handler { + + my $r = shift; + + plan $r, tests => 1; + + ok 1; + + return Apache::OK; +} + +1; +__END__ +<NoAutoConfig> +<VirtualHost TestBasic::Vhost> + <Location /TestBasic__Vhost> + SetHandler modperl + PerlResponseHandler TestBasic::Vhost + </Location> +</VirtualHost> +</NoAutoConfig> Modified: httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Changes Url: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Changes?view=diff&rev=122906&p1=httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Changes&r1=122905&p2=httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Changes&r2=122906 ============================================================================== --- httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Changes (original) +++ httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/Changes Mon Dec 20 15:42:20 2004 @@ -8,12 +8,15 @@ =item 0.01 -new test: interactive.t: the interactive config +new test: minmaxclients.t: testing a bug with vhosts reproducable by +t/TEST -conf followed by t/TEST -maxclients 1 [Stas] + +new test: interactive.t: the interactive config [Stas] new test: httpd_arg.t: passing -httpd argument to 'perl Makefile.PL' -and to 't/TEST' +and to 't/TEST' [Stas] -starting the config test suite +starting the config test suite [Stas] =back Added: httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/t/minmaxclients.t Url: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/t/minmaxclients.t?view=auto&rev=122906 ============================================================================== --- (empty file) +++ httpd/test/trunk/perl-framework/Apache-Test/Apache-TestItSelf/t/minmaxclients.t Mon Dec 20 15:42:20 2004 @@ -0,0 +1,101 @@ +# +# -minclients / -maxclients argument passed explicitly (to +# Makefile.PL, to t/TEST, etc.) +# + +use strict; +use warnings FATAL => 'all'; + +use Test::More; +use MyTest::Util qw(myrun3 go_in go_out test_configs); +use Apache::TestConfig (); + +my @configs = test_configs(); +my $tests_per_config = 18; +plan tests => $tests_per_config * @configs; + +my $orig_dir = go_in(); + +# min/maxclients of 10 should work for pretty much any test suite, so +# for now hardcoded the number in this test +my $clients = 10; +for my $c (@configs) { + for my $opt_name (qw(minclients maxclients)) { + my $opt = "-$opt_name $clients"; + makefile_pl_plus_opt($c, $opt); + t_TEST_plus_opt($c, $opt); + } +} + +go_out($orig_dir); + +# 4 sub tests +# explicit Makefile.PL -(mix|max)clients +sub makefile_pl_plus_opt { + my $c = shift; + my $opt = shift; + + my($cmd, $out, $err); + + # clean and ignore the results + $cmd = "make clean"; + ($out, $err) = myrun3($cmd); + + my $makepl_arg = $c->{makepl_arg} || ''; + $cmd = "$c->{perl_exec} Makefile.PL $makepl_arg $opt " . + "-httpd $c->{httpd_exec} -httpd_conf $c->{httpd_conf}"; + ($out, $err) = myrun3($cmd); + unlike $err, qr/\[ error\]/, $cmd; + + $cmd = "make"; + ($out, $err) = myrun3($cmd); + is $err, "", $cmd; + + my $test_verbose = $c->{test_verbose} ? "TEST_VERBOSE=1" : ""; + $cmd = "make test $test_verbose"; + ($out, $err) = myrun3($cmd); + like $out, qr/All tests successful/, $cmd; + unlike $err, qr/\[ error\]/, $cmd; +} + +# 5 tests +# explicit t/TEST -(mix|max)clients +sub t_TEST_plus_opt { + my $c = shift; + my $opt = shift; + + my($cmd, $out, $err); + + # clean and ignore the results + $cmd = "make clean"; + ($out, $err) = myrun3($cmd); + + my $makepl_arg = $c->{makepl_arg} || ''; + $cmd = "$c->{perl_exec} Makefile.PL $makepl_arg"; + ($out, $err) = myrun3($cmd); + unlike $err, qr/\[ error\]/, $cmd; + + $cmd = "make"; + ($out, $err) = myrun3($cmd); + is $err, "", $cmd; + + # the bug was: + # t/TEST -conf + # t/TEST -maxclients 1 + #default_ VirtualHost overlap on port 8530, the first has precedence + #(98)Address already in use: make_sock: could not bind to address + #0.0.0.0:8530 no listening sockets available, shutting down + + my $test_verbose = $c->{test_verbose} ? "-v " : ""; + $cmd = "t/TEST -httpd $c->{httpd_exec} $test_verbose -conf"; + ($out, $err) = myrun3($cmd); + unlike $err, qr/\[ error\]/, $cmd; + + $cmd = "t/TEST -httpd $c->{httpd_exec} $test_verbose $opt"; + ($out, $err) = myrun3($cmd); + like $out, qr/All tests successful/, $cmd; + unlike $err, qr/\[ error\]/, $cmd; +} + +__END__ + Modified: httpd/test/trunk/perl-framework/Apache-Test/Changes Url: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/Changes?view=diff&rev=122906&p1=httpd/test/trunk/perl-framework/Apache-Test/Changes&r1=122905&p2=httpd/test/trunk/perl-framework/Apache-Test/Changes&r2=122906 ============================================================================== --- httpd/test/trunk/perl-framework/Apache-Test/Changes (original) +++ httpd/test/trunk/perl-framework/Apache-Test/Changes Mon Dec 20 15:42:20 2004 @@ -8,6 +8,17 @@ =item 1.18-dev +fix a bug in A-T config generation, when a vhost entry was in +autogenerated httpd.conf (e.g. coming from .pm file) and another from +extra.conf.in. We used to have a ports collision, since extra.conf +wasn't reparsed and the same port was getting assigned to more than +one vhost entry, preventing server startup: + default_ VirtualHost overlap on port 8530, the first has precedence + (98)Address already in use: make_sock: could not bind to address + 0.0.0.0:8530 no listening sockets available, shutting down +could be reproduced with t/TEST -conf followed by t/TEST -maxclients 1 +in the mp2 test suite (or the new Apache-TestMe test suite, which now +includes a special setup for this bug). [Stas] new TestConfig wrapper find_and_load_module [Chia-Liang Kao <chialiang gmail.com>] Modified: httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm Url: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm?view=diff&rev=122906&p1=httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm&r1=122905&p2=httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm&r2=122906 ============================================================================== --- httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm (original) +++ httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm Mon Dec 20 15:42:20 2004 @@ -1371,25 +1371,21 @@ push @extra_conf, $generated; } - # if at least one .in file was modified or the derivative is - # missing, regenerate them all (so information like assigned port - # numbers will be correct) - if ($self->extra_conf_files_needing_update) { - for my $file (@conf_files) { - local $Apache::TestConfig::File = $file; + # regenerate .conf files + for my $file (@conf_files) { + local $Apache::TestConfig::File = $file; - my $in = Symbol::gensym(); - open($in, $file) or next; + my $in = Symbol::gensym(); + open($in, $file) or next; - (my $generated = $file) =~ s/\.in$//; - my $out = $self->genfile($generated, $file); - $self->replace_vars($in, $out); + (my $generated = $file) =~ s/\.in$//; + my $out = $self->genfile($generated, $file); + $self->replace_vars($in, $out); - close $in; - close $out; + close $in; + close $out; - $self->check_vars; - } + $self->check_vars; } #we changed order to give ssl the first port after DEFAULT_PORT