|
| 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); |
0 commit comments