Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions test-perl/t/issues/MODCLUSTER-824.t
Original file line number Diff line number Diff line change
@@ -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);
9 changes: 5 additions & 4 deletions test-perl/t/mod_proxy_cluster/manager.t
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
29 changes: 19 additions & 10 deletions test-perl/t/mod_proxy_cluster/messages_ok.t
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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});
}


##################
Expand All @@ -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');
Expand Down Expand Up @@ -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;