Skip to content

Commit d3c758b

Browse files
committed
test: Change containers configs to use hostnames
Set HostNameLookups On to get hostname in %{REMOTE_HOST}, no IP Drop hardcoded IP addresses, no localhost (except client <-> proxy) Tomcat container now does not exit when tomcat process is stopped Minor files & format clean ups
1 parent e2886e9 commit d3c758b

File tree

4 files changed

+30
-89
lines changed

4 files changed

+30
-89
lines changed

test/httpd/run.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22

33
# copy the prepared conf file and include it
44
cd /test/
5+
FILECONF=$(filename $CONF)
56
if [ -f $CONF ]; then
6-
FILECONF=$(filename $CONF)
77
cp $CONF /usr/local/apache2/conf/
88
echo "Include conf/$FILECONF" >> /usr/local/apache2/conf/httpd.conf
99
else
1010
echo "The given CONF file: $CONF does not exist"
1111
exit 1
1212
fi
1313

14+
if [ ! -z "$MPC_NAME" ]; then
15+
sed -i "s/ServerName httpd-mod_proxy_cluster/ServerName ${MPC_NAME}/g" /usr/local/apache2/conf/$FILECONF
16+
fi
17+
1418
# start apache httpd server in foreground
1519
echo "Starting httpd..."
1620
/usr/local/apache2/bin/apachectl start
1721
tail -f /usr/local/apache2/logs/error_log
18-

test/tomcat/Containerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ COPY target/mod_cluster-distribution-*-tomcat-${TESTSUITE_TOMCAT_VERSION}.zip /t
1313
RUN unzip /tmp/mod_cluster-distribution-*-tomcat-${TESTSUITE_TOMCAT_VERSION}.zip && \
1414
cp mod_cluster-distribution-*/lib/*.jar /usr/local/tomcat/lib/
1515

16-
COPY $TESTSUITE_TOMCAT_CONFIG ./conf/server.xml
17-
COPY $TESTSUITE_TOMCAT_CONTEXT ./conf/context.xml
16+
COPY $TESTSUITE_TOMCAT_CONFIG ./conf/server.xml
1817
COPY --chmod=755 start.sh ./
1918

20-
ENV cluster_port=8090
21-
ENV cluster_address=127.0.0.1
19+
ENV proxy_port=8090
20+
ENV proxy_address=httpd-mod_proxy_cluster
2221
ENV jvm_route=
23-
ENV tomcat_address=
22+
ENV tomcat_address=localhost
23+
ENV tomcat_port=8080
24+
ENV tomcat_shutdown_port=8005
25+
ENV tomcat_ajp_port=8900
2426
ENV tomcat_port_offset=0
2527

2628
CMD ["./start.sh"]
27-

test/tomcat/server.xml

Lines changed: 6 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
define subcomponents such as "Valves" at this level.
2020
Documentation at /docs/config/server.html
2121
-->
22-
<Server port="8005" shutdown="SHUTDOWN" address="tomcat_address" portOffset="port_offset">
22+
<Server port="tomcat_shutdown_port" shutdown="SHUTDOWN" address="tomcat_address" portOffset="port_offset">
2323
<Listener className="org.jboss.modcluster.container.tomcat.ModClusterListener"
24-
connectorPort="8080"
24+
connectorPort="tomcat_port"
2525
proxyList="proxy_address:proxy_port" />
2626
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
27-
<!-- Security listener. Documentation at /docs/config/listeners.html
28-
<Listener className="org.apache.catalina.security.SecurityListener" />
29-
-->
27+
3028
<!--APR library loader. Documentation at /docs/apr.html -->
3129
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
3230
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
@@ -55,75 +53,18 @@
5553
-->
5654
<Service name="Catalina">
5755

58-
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
59-
<!--
60-
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
61-
maxThreads="150" minSpareThreads="4"/>
62-
-->
63-
6456

65-
<!-- A "Connector" represents an endpoint by which requests are received
66-
and responses are returned. Documentation at :
67-
Java HTTP Connector: /docs/config/http.html
68-
Java AJP Connector: /docs/config/ajp.html
69-
APR (HTTP/AJP) Connector: /docs/apr.html
70-
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
71-
-->
72-
<Connector port="8080" protocol="HTTP/1.1"
57+
<Connector port="tomcat_port" protocol="HTTP/1.1"
7358
address="tomcat_address"
7459
connectionTimeout="20000"
75-
redirectPort="8443"
7660
portOffset="port_offset" />
77-
<!-- A "Connector" using the shared thread pool-->
78-
<!--
79-
<Connector executor="tomcatThreadPool"
80-
port="8080" protocol="HTTP/1.1"
81-
connectionTimeout="20000"
82-
redirectPort="8443" />
83-
-->
84-
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443
85-
This connector uses the NIO implementation. The default
86-
SSLImplementation will depend on the presence of the APR/native
87-
library and the useOpenSSL attribute of the
88-
AprLifecycleListener.
89-
Either JSSE or OpenSSL style configuration may be used regardless of
90-
the SSLImplementation selected. JSSE style configuration is used below.
91-
-->
92-
<!--
93-
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
94-
maxThreads="150" SSLEnabled="true">
95-
<SSLHostConfig>
96-
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
97-
type="RSA" />
98-
</SSLHostConfig>
99-
</Connector>
100-
-->
101-
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
102-
This connector uses the APR/native implementation which always uses
103-
OpenSSL for TLS.
104-
Either JSSE or OpenSSL style configuration may be used. OpenSSL style
105-
configuration is used below.
106-
-->
107-
<!--
108-
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
109-
maxThreads="150" SSLEnabled="true" >
110-
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
111-
<SSLHostConfig>
112-
<Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
113-
certificateFile="conf/localhost-rsa-cert.pem"
114-
certificateChainFile="conf/localhost-rsa-chain.pem"
115-
type="RSA" />
116-
</SSLHostConfig>
117-
</Connector>
118-
-->
11961

12062
<!-- Define an AJP 1.3 Connector on port 8900 -->
12163

12264
<Connector protocol="AJP/1.3"
12365
address="tomcat_address"
124-
port="8900"
66+
port="tomcat_ajp_port"
12567
secretRequired="false"
126-
redirectPort="8443"
12768
portOffset="port_offset" />
12869

12970

@@ -156,15 +97,9 @@
15697
resourceName="UserDatabase"/>
15798
</Realm>
15899

159-
<Host name="localhost" appBase="webapps"
100+
<Host name="tomcat_address" appBase="webapps"
160101
unpackWARs="true" autoDeploy="true">
161102

162-
<!-- SingleSignOn valve, share authentication between web applications
163-
Documentation at: /docs/config/valve.html -->
164-
<!--
165-
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
166-
-->
167-
168103
<!-- Access log processes all example.
169104
Documentation at: /docs/config/valve.html
170105
Note: The pattern used is equivalent to using pattern="common" -->

test/tomcat/start.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
#!/bin/bash
22

3-
sed -i "s/tomcat_address/${tomcat_address:-127.0.0.1}/g" ./conf/server.xml
4-
sed -i "s/port_offset/${tomcat_port_offset:-0}/g" ./conf/server.xml
5-
sed -i "s/proxy_port/${cluster_port:-8090}/g" ./conf/server.xml
6-
sed -i "s/proxy_address/${cluster_address:-127.0.0.1}/g" ./conf/server.xml
7-
sed -i "s/proxy_address/${cluster_address:-127.0.0.1}/g" ./conf/context.xml
8-
93
if [ ! -z ${jvm_route} ]; then
10-
sed -i "/<Engine name=\"Catalina\"/c\<Engine name=\"Catalina\" defaultHost=\"localhost\" jvmRoute=\"${jvm_route}\">" ./conf/server.xml
4+
sed -i "/<Engine name=\"Catalina\"/c\ <Engine name=\"Catalina\" defaultHost=\"tomcat_address\" jvmRoute=\"${jvm_route}\">" ./conf/server.xml
115
fi
126

7+
sed -i "s/tomcat_address/${tomcat_address}/g" ./conf/server.xml
8+
sed -i "s/tomcat_port/${tomcat_port}/g" ./conf/server.xml
9+
sed -i "s/tomcat_shutdown_port/${tomcat_shutdown_port}/g" ./conf/server.xml
10+
sed -i "s/tomcat_ajp_port/${tomcat_ajp_port}/g" ./conf/server.xml
11+
sed -i "s/port_offset/${tomcat_port_offset}/g" ./conf/server.xml
12+
sed -i "s/proxy_port/${proxy_port}/g" ./conf/server.xml
13+
sed -i "s/proxy_address/${proxy_address}/g" ./conf/server.xml
14+
1315
ls lib/jakartaee-migration-*.jar
1416
if [ $? = 0 ]; then
15-
rm lib/mod_cluster-container-tomcat-9.0-*.Final-SNAPSHOT.jar
1617
mkdir webapps-javaee
17-
else
18-
rm lib/mod_cluster-container-tomcat-10.1-*.Final-SNAPSHOT.jar
1918
fi
2019

20+
# spawn the tomcat in a separate shell
2121
bin/catalina.sh run
22+
# just stay around even when the tomcat process gets killed
23+
while true; do cat /dev/null; done;

0 commit comments

Comments
 (0)