Skip to content

Commit 07feed7

Browse files
authored
Merge pull request #294 from jajik/MODCLUSTER-824-tests
Add a test for MODCLUSTER-824
2 parents c96ba2b + 677472f commit 07feed7

File tree

3 files changed

+90
-14
lines changed

3 files changed

+90
-14
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Before 'make install' is performed this script should be runnable with
2+
# 'make test'. After 'make install' it should work as 'perl Apache-ModProxyCluster.t'
3+
#########################
4+
5+
use strict;
6+
use warnings;
7+
8+
use Apache::Test;
9+
use Apache::TestUtil;
10+
use Apache::TestConfig;
11+
12+
use ModProxyCluster;
13+
14+
plan tests => 13;
15+
16+
Apache::TestRequest::module("mpc_test_host");
17+
my $hostport = Apache::TestRequest::hostport();
18+
19+
my $url = "http://$hostport/";
20+
21+
my $resp = CMD 'INFO', $url;
22+
ok $resp->is_success;
23+
my %p = parse_response 'INFO', $resp->content;
24+
25+
my $host_count = scalar @{$p{Hosts}};
26+
27+
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'modcluster824' );
28+
ok $resp->is_success;
29+
30+
$resp = CMD 'ENABLE-APP', $url, ( JVMRoute => 'modcluster824', Context => '/news', Alias => "gamma,testalias" );
31+
ok $resp->is_success;
32+
33+
$resp = CMD 'INFO', $url;
34+
ok $resp->is_success;
35+
%p = parse_response 'INFO', $resp->content;
36+
37+
ok (@{$p{Hosts}} == $host_count + 2);
38+
39+
$resp = CMD 'ENABLE-APP', $url, ( JVMRoute => 'modcluster824', Context => '/news', Alias => "beta,testalias" );
40+
ok $resp->is_success;
41+
42+
$resp = CMD 'INFO', $url;
43+
ok $resp->is_success;
44+
%p = parse_response 'INFO', $resp->content;
45+
46+
# count should increase only by one
47+
ok (@{$p{Hosts}} == $host_count + 3);
48+
49+
$resp = CMD 'ENABLE-APP', $url, ( JVMRoute => 'modcluster824', Context => '/news', Alias => "completely,unrelated" );
50+
ok $resp->is_success;
51+
52+
$resp = CMD 'INFO', $url;
53+
ok $resp->is_success;
54+
%p = parse_response 'INFO', $resp->content;
55+
56+
# two new vhosts should be created
57+
ok (@{$p{Hosts}} == $host_count + 5);
58+
59+
# Clean after yourself
60+
CMD 'REMOVE-APP', "$url/*", ( JVMRoute => 'modcluster824' );
61+
sleep 25; # just to make sure we'll have enough time to get it removed
62+
63+
$resp = CMD 'INFO', $url;
64+
ok $resp->is_success;
65+
%p = parse_response 'INFO', $resp->content;
66+
ok (@{$p{Hosts}} == $host_count);

test-perl/t/mod_proxy_cluster/manager.t

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ use Apache::TestRequest 'GET_BODY';
1313
# use Test::More;
1414
use ModProxyCluster;
1515

16-
17-
plan tests => 5;
18-
19-
ok 1; # simple load test
16+
plan tests => 4;
2017

2118
Apache::TestRequest::module("mpc_test_host");
2219
my $hostport = Apache::TestRequest::hostport();
@@ -35,3 +32,7 @@ ok $data->is_success;
3532
$data = GET_BODY $url;
3633

3734
ok (index($data, "Node next") != -1);
35+
36+
# Clean after yourself
37+
CMD 'REMOVE-APP', "$url/*", ( JVMRoute => 'next' );
38+
sleep 25; # just to make sure we'll have enough time to get it removed

test-perl/t/mod_proxy_cluster/messages_ok.t

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use Apache::TestRequest 'GET';
1313
# use Test::More;
1414
use ModProxyCluster;
1515

16-
plan tests => 205;
16+
plan tests => 210;
1717

1818
Apache::TestRequest::module("mpc_test_host");
1919
my $hostport = Apache::TestRequest::hostport();
@@ -43,16 +43,18 @@ ok (index($resp->as_string, "Node spare") != -1);
4343
##### STATUS #####
4444
##################
4545

46-
$resp = CMD 'STATUS', $url, ( JVMRoute => 'spare' );
46+
foreach my $jvmroute ('next', 'spare') {
47+
$resp = CMD 'STATUS', $url, ( JVMRoute => $jvmroute );
4748

48-
ok $resp->is_success;
49+
ok $resp->is_success;
4950

50-
my %p = parse_response 'CONFIG', $resp->content;
51+
my %p = parse_response 'CONFIG', $resp->content;
5152

52-
ok ($p{JVMRoute} eq 'spare');
53-
ok ($p{Type} eq 'STATUS-RSP');
54-
ok (exists $p{id});
55-
ok (exists $p{State});
53+
ok ($p{JVMRoute} eq $jvmroute);
54+
ok ($p{Type} eq 'STATUS-RSP');
55+
ok (exists $p{id});
56+
ok (exists $p{State});
57+
}
5658

5759

5860
##################
@@ -62,13 +64,12 @@ ok (exists $p{State});
6264
$resp = CMD 'INFO', $url;
6365

6466
ok $resp->is_success;
65-
%p = parse_response 'INFO', $resp->content;
67+
my %p = parse_response 'INFO', $resp->content;
6668

6769
ok (@{$p{Nodes}} == 2);
6870
ok (@{$p{Contexts}} == 0);
6971
ok (@{$p{Hosts}} == 0);
7072

71-
# There are two Nodes already, one `spare` added by us and `next` from the previous tests
7273
## TODO: Make this implementation independent, i.e., we should not care whether indexing starts by 0 or 1...
7374
ok ($p{Nodes}->[0]{Name} eq 'next');
7475
ok ($p{Nodes}->[1]{Name} eq 'spare');
@@ -362,3 +363,11 @@ ok (@{$p{Balancers}} == 1);
362363
ok (@{$p{Nodes}} == 3);
363364
ok (@{$p{Contexts}} == 0);
364365
ok (@{$p{Hosts}} == 0);
366+
367+
368+
# Clean after yourself
369+
foreach my $jvmroute ('next', 'spare') {
370+
CMD 'REMOVE-APP', "$url/*", ( JVMRoute => $jvmroute );
371+
}
372+
373+
sleep 25;

0 commit comments

Comments
 (0)