diff --git a/test-perl/t/issues/MODCLUSTER-824.t b/test-perl/t/issues/MODCLUSTER-824.t new file mode 100644 index 00000000..49121024 --- /dev/null +++ b/test-perl/t/issues/MODCLUSTER-824.t @@ -0,0 +1,66 @@ +# Before 'make install' is performed this script should be runnable with +# 'make test'. After 'make install' it should work as 'perl Apache-ModProxyCluster.t' +######################### + +use strict; +use warnings; + +use Apache::Test; +use Apache::TestUtil; +use Apache::TestConfig; + +use ModProxyCluster; + +plan tests => 13; + +Apache::TestRequest::module("mpc_test_host"); +my $hostport = Apache::TestRequest::hostport(); + +my $url = "http://$hostport/"; + +my $resp = CMD 'INFO', $url; +ok $resp->is_success; +my %p = parse_response 'INFO', $resp->content; + +my $host_count = scalar @{$p{Hosts}}; + +$resp = CMD 'CONFIG', $url, ( JVMRoute => 'modcluster824' ); +ok $resp->is_success; + +$resp = CMD 'ENABLE-APP', $url, ( JVMRoute => 'modcluster824', Context => '/news', Alias => "gamma,testalias" ); +ok $resp->is_success; + +$resp = CMD 'INFO', $url; +ok $resp->is_success; +%p = parse_response 'INFO', $resp->content; + +ok (@{$p{Hosts}} == $host_count + 2); + +$resp = CMD 'ENABLE-APP', $url, ( JVMRoute => 'modcluster824', Context => '/news', Alias => "beta,testalias" ); +ok $resp->is_success; + +$resp = CMD 'INFO', $url; +ok $resp->is_success; +%p = parse_response 'INFO', $resp->content; + +# count should increase only by one +ok (@{$p{Hosts}} == $host_count + 3); + +$resp = CMD 'ENABLE-APP', $url, ( JVMRoute => 'modcluster824', Context => '/news', Alias => "completely,unrelated" ); +ok $resp->is_success; + +$resp = CMD 'INFO', $url; +ok $resp->is_success; +%p = parse_response 'INFO', $resp->content; + +# two new vhosts should be created +ok (@{$p{Hosts}} == $host_count + 5); + +# Clean after yourself +CMD 'REMOVE-APP', "$url/*", ( JVMRoute => 'modcluster824' ); +sleep 25; # just to make sure we'll have enough time to get it removed + +$resp = CMD 'INFO', $url; +ok $resp->is_success; +%p = parse_response 'INFO', $resp->content; +ok (@{$p{Hosts}} == $host_count); diff --git a/test-perl/t/mod_proxy_cluster/manager.t b/test-perl/t/mod_proxy_cluster/manager.t index ba052a1a..c3a6c71c 100644 --- a/test-perl/t/mod_proxy_cluster/manager.t +++ b/test-perl/t/mod_proxy_cluster/manager.t @@ -13,10 +13,7 @@ use Apache::TestRequest 'GET_BODY'; # use Test::More; use ModProxyCluster; - -plan tests => 5; - -ok 1; # simple load test +plan tests => 4; Apache::TestRequest::module("mpc_test_host"); my $hostport = Apache::TestRequest::hostport(); @@ -35,3 +32,7 @@ ok $data->is_success; $data = GET_BODY $url; ok (index($data, "Node next") != -1); + +# Clean after yourself +CMD 'REMOVE-APP', "$url/*", ( JVMRoute => 'next' ); +sleep 25; # just to make sure we'll have enough time to get it removed diff --git a/test-perl/t/mod_proxy_cluster/messages_ok.t b/test-perl/t/mod_proxy_cluster/messages_ok.t index 204b1586..b172fa91 100644 --- a/test-perl/t/mod_proxy_cluster/messages_ok.t +++ b/test-perl/t/mod_proxy_cluster/messages_ok.t @@ -13,7 +13,7 @@ use Apache::TestRequest 'GET'; # use Test::More; use ModProxyCluster; -plan tests => 205; +plan tests => 210; Apache::TestRequest::module("mpc_test_host"); my $hostport = Apache::TestRequest::hostport(); @@ -43,16 +43,18 @@ ok (index($resp->as_string, "Node spare") != -1); ##### STATUS ##### ################## -$resp = CMD 'STATUS', $url, ( JVMRoute => 'spare' ); +foreach my $jvmroute ('next', 'spare') { + $resp = CMD 'STATUS', $url, ( JVMRoute => $jvmroute ); -ok $resp->is_success; + ok $resp->is_success; -my %p = parse_response 'CONFIG', $resp->content; + my %p = parse_response 'CONFIG', $resp->content; -ok ($p{JVMRoute} eq 'spare'); -ok ($p{Type} eq 'STATUS-RSP'); -ok (exists $p{id}); -ok (exists $p{State}); + ok ($p{JVMRoute} eq $jvmroute); + ok ($p{Type} eq 'STATUS-RSP'); + ok (exists $p{id}); + ok (exists $p{State}); +} ################## @@ -62,13 +64,12 @@ ok (exists $p{State}); $resp = CMD 'INFO', $url; ok $resp->is_success; -%p = parse_response 'INFO', $resp->content; +my %p = parse_response 'INFO', $resp->content; ok (@{$p{Nodes}} == 2); ok (@{$p{Contexts}} == 0); ok (@{$p{Hosts}} == 0); -# There are two Nodes already, one `spare` added by us and `next` from the previous tests ## TODO: Make this implementation independent, i.e., we should not care whether indexing starts by 0 or 1... ok ($p{Nodes}->[0]{Name} eq 'next'); ok ($p{Nodes}->[1]{Name} eq 'spare'); @@ -362,3 +363,11 @@ ok (@{$p{Balancers}} == 1); ok (@{$p{Nodes}} == 3); ok (@{$p{Contexts}} == 0); ok (@{$p{Hosts}} == 0); + + +# Clean after yourself +foreach my $jvmroute ('next', 'spare') { + CMD 'REMOVE-APP', "$url/*", ( JVMRoute => $jvmroute ); +} + +sleep 25;