Skip to content

Commit 78488af

Browse files
authored
Merge pull request #357 from jajik/issue-348
Tests: Use custom docker/podman network, rework provisioning of containers, and more tweaks
2 parents b0a74e8 + 186b5ab commit 78488af

38 files changed

+721
-579
lines changed

native/common/common.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,8 @@ node_context *find_node_context_host(request_rec *r, const proxy_balancer *balan
393393
continue;
394394
}
395395
context = &context_table->context_info[j];
396-
ap_log_error(APLOG_MARK, APLOG_TRACE4, 0, r->server,
397-
"find_node_context_host: %s node: %d vhost: %d context: %s", uri, context->node, context->vhost,
398-
context->context);
396+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "find_node_context_host: %s node: %d vhost: %d context: %s",
397+
uri, context->node, context->vhost, context->context);
399398
}
400399
#endif
401400

native/mod_manager/mod_manager.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,8 +1216,9 @@ static const proxy_worker_shared *read_shared_by_node(request_rec *r, nodeinfo_t
12161216
workers = (proxy_worker **)balancer->workers->elts;
12171217
for (j = 0; j < balancer->workers->nelts; j++, workers++) {
12181218
proxy_worker *worker = *workers;
1219-
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "read_shared_by_node: Balancer %s worker %s, %s, %d",
1220-
balancer->s->name, worker->s->route, worker->s->hostname, worker->s->port);
1219+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1220+
"read_shared_by_node: Balancer %s worker (%d) %s, %s, %d", balancer->s->name, worker->s->index,
1221+
worker->s->route, worker->s->hostname, worker->s->port);
12211222
if (worker->s->port == port && strcmp(worker->s->hostname, node->mess.Host) == 0 &&
12221223
strcmp(worker->s->route, node->mess.JVMRoute) == 0) {
12231224
return worker->s;
@@ -1904,7 +1905,7 @@ static char *process_info(request_rec *r, int *errtype)
19041905

19051906
proxystat = read_shared_by_node(r, ou);
19061907
if (!proxystat) {
1907-
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "process_config: No proxystat, assum zeros");
1908+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "process_config: No proxystat, assume zeros");
19081909
proxystat = apr_pcalloc(r->pool, sizeof(proxy_worker_shared));
19091910
}
19101911

native/mod_proxy_cluster/mod_proxy_cluster.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ static apr_status_t create_worker_reuse(proxy_server_conf *conf, const char *ptr
291291
helper = *helper_ptr;
292292
if (helper->index == -1) {
293293
/* We are going to reuse a removed one */
294-
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server, "create_worker_reuse: reusing removed worker for %s", url);
294+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server, "create_worker_reuse: reusing removed worker (%d) for %s",
295+
node->mess.id, url);
295296
return APR_SUCCESS;
296297
}
297298

@@ -504,7 +505,7 @@ static apr_status_t create_worker(proxy_server_conf *conf, proxy_balancer *balan
504505
}
505506

506507
/* No, it does not exist, so we will create a new one.
507-
* Note that the ap_proxy_get_worker and ap_proxy_define_worker aren't symetrical, and
508+
* Note that the ap_proxy_get_worker and ap_proxy_define_worker aren't symmetrical, and
508509
* this leaks via the conf->pool
509510
*/
510511
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server, "create_worker: worker for %s Will create %d!!!", url,
@@ -797,13 +798,15 @@ static proxy_worker *get_worker_from_id_stat(const proxy_server_conf *conf, int
797798
for (j = 0; j < balancer->workers->nelts; j++, ptrw = ptrw + sizew) {
798799
proxy_worker **worker = (proxy_worker **)ptrw;
799800
proxy_cluster_helper *helper = (proxy_cluster_helper *)(*worker)->context;
801+
800802
if ((*worker)->s == stat && helper->index == id) {
801803
if (is_worker_empty(*worker)) {
802804
return NULL;
803-
} else {
804-
return *worker;
805805
}
806+
807+
return *worker;
806808
}
809+
807810
if (helper->index == id) {
808811
unpair_worker_node((*worker)->s, node);
809812
helper->shared->index = -1;
@@ -1836,9 +1839,12 @@ static int proxy_node_isup(request_rec *r, int id, int load)
18361839
char *ptr;
18371840

18381841
if (node_storage->read_node(id, &node) != APR_SUCCESS) {
1842+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "proxy_cluster_isup: Can't read node with id %d.", id);
18391843
return HTTP_INTERNAL_SERVER_ERROR;
18401844
}
18411845
if (node->mess.remove) {
1846+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1847+
"proxy_cluster_isup: Node with id %d is marked for removal.", id);
18421848
return HTTP_INTERNAL_SERVER_ERROR;
18431849
}
18441850

test/MODCLUSTER-640/mod_lbmethod_cluster.conf

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,32 @@ LoadModule lbmethod_cluster_module modules/mod_lbmethod_cluster.so
99
LoadModule watchdog_module modules/mod_watchdog.so
1010

1111
LogLevel info
12-
ServerName localhost
12+
ServerName httpd-mod_proxy_cluster
1313
ProxyPreserveHost On
1414
UseNocanon On
1515

16-
<IfModule manager_module>
17-
Listen 8090
18-
ManagerBalancerName mycluster
16+
Listen 8090
17+
ManagerBalancerName mycluster
1918

20-
EnableWsTunnel
21-
WSUpgradeHeader websocket
22-
<VirtualHost *:8090>
23-
EnableMCMPReceive
24-
<Location />
25-
Require ip 127.0.0.1
26-
Require ip ::1
27-
# This one is used in GH Actions
28-
Require ip 172.17.
29-
</Location>
30-
<Location /mod_cluster_manager>
31-
SetHandler mod_cluster-manager
32-
Require ip 127.0.0.1
33-
Require ip ::1
34-
# This one is used in GH Actions
35-
Require ip 172.17.
36-
</Location>
37-
</VirtualHost>
38-
</IfModule>
19+
EnableWsTunnel
20+
WSUpgradeHeader websocket
21+
22+
<VirtualHost *:8090>
23+
EnableMCMPReceive
24+
<Location />
25+
# For podman, this gets changed to IP in httpd/run.sh
26+
Require host .mod_proxy_cluster_testsuite_net
27+
# _gateway is the hostname used through the docker port forward into the custom network
28+
Require host _gateway
29+
Require local
30+
</Location>
31+
<Location /mod_cluster_manager>
32+
SetHandler mod_cluster-manager
33+
# _gateway is the hostname used through the docker port forward into the custom network
34+
Require host _gateway
35+
Require local
36+
</Location>
37+
</VirtualHost>
3938

4039
<Proxy "balancer://mycluster">
4140
ProxySet growth=10

test/MODCLUSTER-640/mod_proxy_cluster.conf

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,34 @@ LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
66
LoadModule manager_module modules/mod_manager.so
77
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
88

9-
LogLevel info
109
UseNocanon On
11-
ServerName localhost
10+
ServerName httpd-mod_proxy_cluster
1211
ProxyPreserveHost On
1312

13+
Listen 8090
14+
ManagerBalancerName mycluster
15+
WSUpgradeHeader websocket
16+
EnableWsTunnel
1417

15-
<IfModule !lbmethod_cluster_module>
16-
UseAlias On
17-
</IfModule>
18+
CreateBalancers 0
19+
EnableOptions On
1820

19-
<IfModule manager_module>
20-
Listen 8090
21-
ManagerBalancerName mycluster
21+
<VirtualHost *:8090>
22+
EnableMCMPReceive
23+
<Location />
24+
# For podman, this gets changed to IP in httpd/run.sh
25+
Require host .mod_proxy_cluster_testsuite_net
26+
# _gateway is the hostname used through the docker port forward into the custom network
27+
Require host _gateway
28+
Require local
29+
</Location>
2230

23-
<IfModule !lbmethod_cluster_module>
24-
CreateBalancers 0
25-
EnableOptions On
26-
</IfModule>
31+
<Location /mod_cluster_manager>
32+
SetHandler mod_cluster-manager
33+
# _gateway is the hostname used through the docker port forward into the custom network
34+
Require host _gateway
35+
Require local
36+
</Location>
37+
</VirtualHost>
2738

28-
EnableWsTunnel
29-
WSUpgradeHeader websocket
30-
<VirtualHost *:8090>
31-
EnableMCMPReceive
32-
<Location />
33-
Require ip 127.0.0.1
34-
Require ip ::1
35-
# This one is used in GH Actions
36-
Require ip 172.17.
37-
</Location>
38-
<Location /mod_cluster_manager>
39-
SetHandler mod_cluster-manager
40-
Require ip 127.0.0.1
41-
Require ip ::1
42-
# This one is used in GH Actions
43-
Require ip 172.17.
44-
</Location>
45-
</VirtualHost>
46-
</IfModule>
47-
48-
<IfModule lbmethod_cluster_module>
49-
<Proxy "balancer://mycluster">
50-
ProxySet growth=10
51-
ProxySet lbmethod=cluster
52-
</Proxy>
53-
</IfModule>
39+
LogLevel info

test/MODCLUSTER-640/testit.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ httpd_remove
1010
rm -f nohup.out
1111

1212
MPC_CONF=${MPC_CONF:-MODCLUSTER-640/mod_proxy_cluster.conf}
13-
MPC_NAME=MODCLUSTER-640 httpd_start
13+
MPC_NAME=MODCLUSTER-640
14+
15+
httpd_start
1416

1517
# wait until httpd is started
1618
httpd_wait_until_ready || exit 1

test/MODCLUSTER-734/mod_lbmethod_cluster.conf

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,32 @@ LoadModule watchdog_module modules/mod_watchdog.so
1111
ProxyHCExpr in_maint {hc('body') !~ /Under maintenance/}
1212
ModProxyClusterHCTemplate hcmethod=GET hcexpr=in_maint hcuri=/status.jsp
1313

14-
Maxnode 505
15-
Maxhost 1010
16-
Maxcontext 1100
1714
Listen 8090
1815
ManagerBalancerName mycluster
19-
ServerName localhost
16+
ServerName httpd-mod_proxy_cluster
2017

2118
<VirtualHost *:8090>
22-
EnableMCMPReceive
23-
<Location />
24-
Require ip 127.0.0.
25-
Require ip ::1
26-
# This one is used in GH Actions
27-
Require ip 172.17.
28-
</Location>
29-
<Location /mod_cluster_manager>
30-
SetHandler mod_cluster-manager
31-
Require ip 127.0.0.
32-
Require ip ::1
33-
# This one is used in GH Actions
34-
Require ip 172.17.
35-
</Location>
19+
EnableMCMPReceive
20+
<Location />
21+
# For podman, this gets changed to IP in httpd/run.sh
22+
Require host .mod_proxy_cluster_testsuite_net
23+
# _gateway is the hostname used through the docker port forward into the custom network
24+
Require host _gateway
25+
Require local
26+
</Location>
27+
<Location /mod_cluster_manager>
28+
SetHandler mod_cluster-manager
29+
# _gateway is the hostname used through the docker port forward into the custom network
30+
Require host _gateway
31+
Require local
32+
</Location>
3633
</VirtualHost>
3734

3835
<Proxy "balancer://mycluster">
39-
ProxySet growth=20
40-
ProxySet lbmethod=cluster
36+
ProxySet growth=20
37+
ProxySet lbmethod=cluster
4138
</Proxy>
39+
40+
Maxnode 505
41+
Maxhost 1010
42+
Maxcontext 1100

test/MODCLUSTER-734/mod_proxy_cluster.conf

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,27 @@ LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
88
ProxyHCExpr in_maint {hc('body') !~ /Under maintenance/}
99
ModProxyClusterHCTemplate hcmethod=GET hcexpr=in_maint hcuri=/status.jsp
1010

11-
Maxnode 505
12-
Maxhost 1010
13-
Maxcontext 1100
1411
Listen 8090
1512
ManagerBalancerName mycluster
16-
ServerName localhost
13+
ServerName httpd-mod_proxy_cluster
1714

1815
<VirtualHost *:8090>
19-
EnableMCMPReceive
20-
<Location />
21-
Require ip 127.0.0.1
22-
Require ip ::1
23-
# This one is used in GH Actions
24-
Require ip 172.17.
25-
</Location>
26-
<Location /mod_cluster_manager>
27-
SetHandler mod_cluster-manager
28-
Require ip 127.0.0.1
29-
Require ip ::1
30-
# This one is used in GH Actions
31-
Require ip 172.17.
32-
</Location>
16+
EnableMCMPReceive
17+
<Location />
18+
# For podman, this gets changed to IP in httpd/run.sh
19+
Require host .mod_proxy_cluster_testsuite_net
20+
# _gateway is the hostname used through the docker port forward into the custom network
21+
Require host _gateway
22+
Require local
23+
</Location>
24+
<Location /mod_cluster_manager>
25+
SetHandler mod_cluster-manager
26+
# _gateway is the hostname used through the docker port forward into the custom network
27+
Require host _gateway
28+
Require local
29+
</Location>
3330
</VirtualHost>
31+
32+
Maxnode 505
33+
Maxhost 1010
34+
Maxcontext 1100

test/MODCLUSTER-734/testit.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ httpd_remove
99
# build httpd + mod_proxy_cluster
1010
rm -f nohup.out
1111

12-
MPC_CONF=${MPC_CONF:-MODCLUSTER-734/mod_proxy_cluster.conf}
13-
MPC_NAME=MODCLUSTER-734 httpd_start
12+
MPC_NAME=MODCLUSTER-734 MPC_CONF=${MPC_CONF:-MODCLUSTER-734/mod_proxy_cluster.conf} httpd_start
1413

1514
# wait until httpd is started
1615
httpd_wait_until_ready || exit 1
1716

1817
sleep 10
1918

2019
# start tomcat1 and tomcat2
21-
tomcat_start_two
20+
MPC_NAME=MODCLUSTER-734 tomcat_start_two
2221

2322
# wait until they are in mod_proxy_cluster tables
2423
tomcat_wait_for_n_nodes 2
@@ -29,7 +28,7 @@ docker cp MODCLUSTER-734/ROOT_OK tomcat2:/usr/local/tomcat/webapps/ROOT
2928

3029
# after a while the health check will get the Under maintenance status.jsp
3130
# and mark the node not OK.
32-
sleep 15
31+
sleep 20
3332

3433
curl -s -m 20 http://localhost:8090/mod_cluster_manager | grep "Status: NOTOK"
3534
if [ $? -eq 0 ]; then

0 commit comments

Comments
 (0)