Skip to content

Commit

Permalink
test: Add CI support, run basetests, minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jajik committed Jul 27, 2023
1 parent 7659f08 commit 52e7a10
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,43 @@ jobs:
- name: Build
run: |
./native/scripts/windows-build.bat
tests:
runs-on: ubuntu-latest
env:
IMG: local-tomcat
HTTPD_IMG: local-httpd
MPC_CONF: https://raw.githubusercontent.com/jajik/mod_proxy_cluster/rework-test-add-ci/test/httpd/mod_proxy_cluster.conf
DEBUG: on
ITERATION_COUNT: 5
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup dependencies
run: |
sudo apt update -y
sudo apt install -y moby* maven git curl iproute2
cd test
sh setup-dependencies.sh
- name: Setup images
run: |
cd test
source includes/common.sh
httpd_create
tomcat_create
- name: Basic tests
run: |
cd test
mkdir logs
# set vars
export MPC_SOURCES=$(git remote -v | grep "origin.*fetch" | awk ' { print $2 } '
export MPC_BRANCH=$(git branch --show-current)
# run tests
source includes/common.sh
run_test basetests.sh "Basic tests"
- name: Preserve test logs
uses: actions/upload-artifact@v3
if: always()
with:
name: Test logs
path: test/logs/*
retention-days: 7
2 changes: 1 addition & 1 deletion test/basetests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
httpd_all_clean
tomcat_all_remove

httpd_run
httpd_run || clean_and_exit

# Start 2 tomcats, on 8080 and 8081
tomcat_start_two || clean_and_exit
Expand Down
15 changes: 10 additions & 5 deletions test/includes/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@ run_test() {
printf "Running %-42s ..." $1
fi
if [ $DEBUG ]; then
sh $1 &> logs/${2:-$1}.logs
sh $1 &> "logs/${2:-$1}.logs"
else
sh $1 &> /dev/null
fi
if [ $? = 0 ]; then
echo " OK"
else
# if test failed, clean httpd but preserve logs
docker logs $(docker ps -a | grep $HTTPD_IMG | cut -f 1 -d' ') &> logs/${2:-$1}-httpd.logs
if [ $DEBUG ]; then
docker logs $(docker ps -a | grep $HTTPD_IMG | cut -f 1 -d' ') &> "logs/${2:-$1}-httpd.logs"
fi
httpd_shutdown &> /dev/null
echo " NOK"
ret=1
fi
# Clean all after run
tomcat_all_remove &> /dev/null

return $ret
}

Expand Down Expand Up @@ -56,22 +59,24 @@ httpd_run() {
-e BRANCH=${MPC_BRANCH:-main} \
-e CONF=${MPC_CONF:-https://raw.githubusercontent.com/modcluster/mod_proxy_cluster/main/test/httpd/mod_proxy_cluster.conf} \
$HTTPD_IMG

httpd_wait_until_ready
}

httpd_wait_until_ready() {
local i=0
curl localhost:6666 &> /dev/null
while [ $? != 0 ];
curl -s localhost:6666
while [ $? -ne 0 ];
do
i=$(expr $i + 1)
if [ $i -gt 20 ]; then
echo "Failed to run httpd container"
exit 1;
fi
sleep 10;
curl localhost:6666 &> /dev/null
curl -s localhost:6666
done
echo "httpd ready after $i attempts"
}

httpd_shutdown() {
Expand Down
3 changes: 1 addition & 2 deletions test/tomcat/context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
allow="127\.\d+\.\d+\.\d+|172.17.0.0/16|::1|0:0:0:0:0:0:0:1" />

<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
</Context>

0 comments on commit 52e7a10

Please sign in to comment.