Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5465eb8
test: Add custom flags support for HTTPD container
jajik Jan 6, 2025
29280b1
test: Add support for custom httpd flags to the testsuite
jajik Jan 6, 2025
cd90900
test: Add coverage support into the testsuite
jajik Jan 6, 2025
63aa52f
Add coverage directory to gitignore
jajik Jan 6, 2025
4ed08de
ci: Generate coverage report for the testsuite
jajik Jan 14, 2025
1c0b8f1
test: Fix testsuite.sh indentation, clean test/logs/ before each run
jajik Jan 14, 2025
47eb919
test: Use log files for gcovr output, redirect docker cp output to /d…
jajik Jan 14, 2025
dc1ece4
test: Add lcov coverage report as well
jajik Jan 14, 2025
3424b17
WIP
jajik Jan 22, 2025
7c9e16c
WIP silence output
jajik Jan 22, 2025
ae1966e
Add -fPIC
jajik Mar 20, 2025
7e2d37c
WIP: Add more flags
jajik May 14, 2025
4c0f21a
WIP: Try standalone mode for httpd
jajik May 14, 2025
fa63630
WIP: Add sleep before logs are created
jajik May 14, 2025
70df63b
WIP
jajik May 15, 2025
1bce18e
WIP: Run only a subset of tests
jajik May 15, 2025
c1837e0
WIP Add more flags
jajik May 15, 2025
db96485
WIP Run tests only with balancer
jajik May 15, 2025
71fc1ff
wip
jajik May 15, 2025
1dd2dd3
Add CXXFLAGS
jajik May 28, 2025
7a2e11c
WIP fix containerfile
jajik Feb 23, 2026
4c89087
WIP install gcov, lcov
jajik Feb 23, 2026
5023dd4
Fix id for PING and STATUS responses
jajik Mar 20, 2026
09d9e0e
WIP
jajik Mar 20, 2026
5d282e1
WIP2
jajik Mar 20, 2026
507837d
Tweak CMake to build common.c as a static library
jajik May 19, 2026
0c618b2
test: Use CMake in httpd test container
jajik May 19, 2026
c3d22ca
Add APACHE_INCLUDE_DIR
jajik May 19, 2026
349d51e
fixup
jajik May 19, 2026
7fbe8cd
WIP
jajik May 19, 2026
310e892
WIP
jajik May 19, 2026
f9e0bfa
WIP
jajik May 19, 2026
b0cd536
WIP CMAKE
jajik May 19, 2026
7b23f7a
WIP vol. X
jajik May 20, 2026
3fd8a15
wip
jajik May 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ jobs:
FOREVER_PAUSE: ${{ inputs.forever-pause || 100 }}
ITERATION_COUNT: ${{ inputs.iteration-count || 2 }}
TOMCAT_CYCLE_COUNT: ${{ inputs.tomcat-cycle-count || 2 }}
CODE_COVERAGE: 1
steps:
- name: Checkout
uses: actions/checkout@v6
Expand Down Expand Up @@ -302,6 +303,14 @@ jobs:
path: |
test/logs/*
retention-days: 7
# Preserve coverage data if defined
- name: Preserve coverage files
if: env.CODE_COVERAGE
uses: actions/upload-artifact@v4
with:
name: Coverage ${{ matrix.os }}
path: test/coverage/*
retention-days: 7

perl-tests:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ test/httpd/mod_proxy_cluster
# Log files
**/*.log

# Coverage files
test/coverage/
*.gcno
*.gcda
*.gcov

# build files
*.slo
*.so
Expand Down
9 changes: 7 additions & 2 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ IF(WIN32)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /O2 /Wall /Z7")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Od /Wall /Zi")
ELSE()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -std=gnu99 -fPIC -Wall -Wextra -Werror")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -p -O1 -std=gnu99 -fPIC -Wall -Wextra")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -fPIC -Wall -Wextra -Werror --coverage -fprofile-arcs -ftest-coverage -fPIC -g -O0 -lgcov")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -p -std=gnu99 -fPIC -Wall -Wextra --coverage -fprofile-arcs -ftest-coverage -fPIC -O0 -lgcov")
ENDIF()

SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")

SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/modules)
SET(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
Expand All @@ -31,6 +33,9 @@ INCLUDE_DIRECTORIES(${APACHE_INCLUDE_DIR})
INCLUDE_DIRECTORIES("${PROJECT_INCLUDE_DIR}")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}")

ADD_LIBRARY(mod_proxy_cluster_common OBJECT common/common.c)
TARGET_INCLUDE_DIRECTORIES(mod_proxy_cluster_common PUBLIC ${PROJECT_INCLUDE_DIR})

ADD_SUBDIRECTORY(mod_proxy_cluster)
ADD_SUBDIRECTORY(advertise)
ADD_SUBDIRECTORY(mod_manager)
Expand Down
9 changes: 3 additions & 6 deletions native/balancers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
PROJECT(mod_lbmethod_cluster LANGUAGES C)

SET(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
SET(PROJECT_COMMON_SRC ${PROJECT_SOURCE_DIR}/../common)
SET(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

SET(MOD_PROXY_CLUSTER_SRCS ${PROJECT_SOURCE_DIR}/mod_lbmethod_cluster.c
${PROJECT_COMMON_SRC}/common.c
)
SET(MOD_PROXY_CLUSTER_SRCS ${PROJECT_SOURCE_DIR}/mod_lbmethod_cluster.c)

INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
INCLUDE_DIRECTORIES("${PROJECT_INCLUDE_DIR}")
Expand All @@ -24,7 +21,7 @@ ADD_LIBRARY(mod_lbmethod_cluster MODULE ${MOD_PROXY_CLUSTER_SRCS})
SET_TARGET_PROPERTIES(mod_lbmethod_cluster PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(mod_lbmethod_cluster PROPERTIES SUFFIX ".so")
IF(WIN32)
TARGET_LINK_LIBRARIES(mod_lbmethod_cluster ${PROXY_LIBRARY} ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY})
TARGET_LINK_LIBRARIES(mod_lbmethod_cluster $<TARGET_OBJECTS:mod_proxy_cluster_common> ${PROXY_LIBRARY} ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY})
ELSE()
TARGET_LINK_LIBRARIES(mod_lbmethod_cluster ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY})
TARGET_LINK_LIBRARIES(mod_lbmethod_cluster $<TARGET_OBJECTS:mod_proxy_cluster_common> ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY})
ENDIF()
5 changes: 2 additions & 3 deletions native/mod_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ SET(MOD_MANAGER_SRCS ${PROJECT_SOURCE_DIR}/mod_manager.c
${PROJECT_SOURCE_DIR}/host.c
${PROJECT_SOURCE_DIR}/node.c
${PROJECT_SOURCE_DIR}/sessionid.c
${PROJECT_SOURCE_DIR}/../common/common.c
)

INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
Expand All @@ -30,7 +29,7 @@ SET_TARGET_PROPERTIES(mod_manager PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(mod_manager PROPERTIES SUFFIX ".so")

IF(WIN32)
TARGET_LINK_LIBRARIES(mod_manager ${PROXY_LIBRARY} ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY})
TARGET_LINK_LIBRARIES(mod_manager $<TARGET_OBJECTS:mod_proxy_cluster_common> ${PROXY_LIBRARY} ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY})
ELSE()
TARGET_LINK_LIBRARIES(mod_manager ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY})
TARGET_LINK_LIBRARIES(mod_manager $<TARGET_OBJECTS:mod_proxy_cluster_common> ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY})
ENDIF()
4 changes: 2 additions & 2 deletions native/mod_manager/mod_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -2442,7 +2442,7 @@ static char *process_status(request_rec *r, const char *const *ptr, int *errtype

ap_rprintf(r, isnode_up(r, node->mess.id, Load) != OK ? "&State=NOTOK" : "&State=OK");

ap_rprintf(r, "&id=%d", (int)ap_scoreboard_image->global->restart_time);
ap_rprintf(r, "&id=%ld", ap_scoreboard_image->global->restart_time);

ap_rprintf(r, "\n");
return NULL;
Expand Down Expand Up @@ -2544,7 +2544,7 @@ static char *process_ping(request_rec *r, const char *const *ptr, int *errtype)

ap_rprintf(r, isnode_up(r, node->mess.id, -2) != OK ? "&State=NOTOK" : "&State=OK");
}
ap_rprintf(r, "&id=%d", (int)ap_scoreboard_image->global->restart_time);
ap_rprintf(r, "&id=%ld", ap_scoreboard_image->global->restart_time);

ap_rprintf(r, "\n");
return NULL;
Expand Down
7 changes: 3 additions & 4 deletions native/mod_proxy_cluster/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
PROJECT(mod_proxy_cluster LANGUAGES C)

SET(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
SET(PROJECT_COMMON_SRC ${PROJECT_SOURCE_DIR}/../common/common.c)
SET(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

SET(MOD_PROXY_CLUSTER_SRCS ${PROJECT_SOURCE_DIR}/mod_proxy_cluster.c ${PROJECT_COMMON_SRC})
SET(MOD_PROXY_CLUSTER_SRCS ${PROJECT_SOURCE_DIR}/mod_proxy_cluster.c)

INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
INCLUDE_DIRECTORIES("${PROJECT_INCLUDE_DIR}")
Expand All @@ -22,7 +21,7 @@ ADD_LIBRARY(mod_proxy_cluster MODULE ${MOD_PROXY_CLUSTER_SRCS})
SET_TARGET_PROPERTIES(mod_proxy_cluster PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(mod_proxy_cluster PROPERTIES SUFFIX ".so")
IF(WIN32)
TARGET_LINK_LIBRARIES(mod_proxy_cluster ${PROXY_LIBRARY} ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY})
TARGET_LINK_LIBRARIES(mod_proxy_cluster $<TARGET_OBJECTS:mod_proxy_cluster_common> ${PROXY_LIBRARY} ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY})
ELSE()
TARGET_LINK_LIBRARIES(mod_proxy_cluster ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY})
TARGET_LINK_LIBRARIES(mod_proxy_cluster $<TARGET_OBJECTS:mod_proxy_cluster_common> ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY})
ENDIF()
36 changes: 18 additions & 18 deletions test/httpd/Containerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
FROM fedora:42 AS builder

ARG HTTPD_SOURCES="https://dlcdn.apache.org/httpd/httpd-2.4.67.tar.gz"
ARG CFLAGS=""
ARG LDFLAGS=""
ARG HTTPD_DEFAULT_FLAGS="--enable-proxy --enable-proxy-http --enable-proxy-ajp --enable-proxy-wstunnel --enable-proxy-hcheck --with-port=8000"
ARG HTTPD_EXTRA_FLAGS=""

RUN dnf install gcc apr-devel apr-util-devel openssl-devel pcre-devel redhat-rpm-config autoconf wcstools -y
RUN yum install gcc wget apr-devel apr-util-devel openssl-devel pcre-devel redhat-rpm-config wcstools git autoconf gcovr lcov cmake -y

ENV HTTPD=${HTTPD_SOURCES}
ENV CFLAGS="${CFLAGS}"
ENV LDFLAGS="${LDFLAGS}"
ENV HTTPD_FLAGS="${HTTPD_DEFAULT_FLAGS} ${HTTPD_EXTRA_FLAGS}"
ENV CXXFLAGS="-fprofile-arcs -ftest-coverage"

# make sure you have copy of the local repository at place
# (our function "httpd_create" takes care of that)
Expand All @@ -16,11 +24,7 @@ RUN mkdir /httpd && tar xvf $(filename $HTTPD) --strip 1 -C /httpd

WORKDIR /httpd

RUN ./configure --enable-proxy \
--enable-proxy-http \
--enable-proxy-ajp \
--enable-proxy-wstunnel \
--enable-proxy-hcheck
RUN ./configure ${HTTPD_FLAGS}
RUN make
RUN make install
# we don't need any other listeners except the ones we define in our config files
Expand All @@ -29,27 +33,23 @@ RUN sed -i 's/\(Listen 80\)/#\1/' /usr/local/apache2/conf/httpd.conf
# httpd is installed in /usr/local/apache2/bin/
# build and install mod_proxy_cluster *.so files.
WORKDIR /native
RUN for m in advertise mod_proxy_cluster balancers mod_manager; \
do \
cd $m; \
echo "Building $m"; \
./buildconf; \
./configure --with-apxs=/usr/local/apache2/bin/apxs; \
make clean; \
make || exit 1; \
cp *.so /usr/local/apache2/modules; \
cd $OLDPWD; \
done;

RUN mkdir build || true

RUN cd build && rm -rf * && cmake .. -DAPACHE_INCLUDE_DIR=/usr/local/apache2/include && make && for f in modules/*.so; do ln -s "$PWD/$f" /usr/local/apache2/$f; done;

RUN rm -rf /test/httpd/mod_proxy_cluster

FROM fedora:42

ENV CONF=httpd/mod_proxy_cluster.conf
ENV GCOV_PREFIX=/
ENV GCOV_PREFIX_STRIP=3

RUN dnf install pcre apr-util wcstools -y
RUN dnf install pcre apr-util wcstools gcovr lcov -y

COPY --from=builder /usr/local/apache2 /usr/local/apache2
COPY --from=builder /native /native

COPY --from=builder /test /test

Expand Down
7 changes: 6 additions & 1 deletion test/httpd/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ fi
if [ ! -z "$MPC_NAME" ]; then
sed -i "s/ServerName httpd-mod_proxy_cluster/ServerName ${MPC_NAME}/g" /usr/local/apache2/conf/$FILECONF
fi
mkdir /coverage

# start apache httpd server in foreground
echo "Starting httpd..."
/usr/local/apache2/bin/apachectl start
/usr/local/apache2/bin/httpd -X &
sleep 1
tail -f /usr/local/apache2/logs/error_log

while true; do cat /dev/null; done;

32 changes: 29 additions & 3 deletions test/includes/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ IMG=${IMG:-mod_proxy_cluster-testsuite-tomcat}
HTTPD_IMG=${HTTPD_IMG:-mod_proxy_cluster-testsuite-httpd}
MPC_NAME=${MPC_NAME:-httpd-mod_proxy_cluster}

if [ $CODE_COVERAGE ]; then
MPC_CFLAGS="$MPC_CFLAGS --coverage -fprofile-arcs -ftest-coverage -fPIC -g -O0"
MPC_LDFLAGS="$MPC_LDFLAGS -lgcov -fprofile-arcs -ftest-coverage --coverage"
HTTPD_EXTRA_FLAGS="$HTTPD_EXTRA_FLAGS --enable-debugger-mode --enable-so"
fi

# Runs a test file ($1) under given name ($2, if given)
run_test() {
local ret=0
Expand All @@ -23,12 +29,28 @@ run_test() {
echo " NOK"
ret=1
fi

local httpd_cont=$(docker ps -a | grep $HTTPD_IMG | cut -f 1 -d' ')
# preserve httpd's logs too if DEBUG
if [ $DEBUG ]; then
local httpd_cont=$(docker ps -a | grep $HTTPD_IMG | cut -f 1 -d' ')
docker logs $httpd_cont > "logs/${2:-$1}-httpd.log" 2>&1
docker logs ${httpd_cont} > "logs/${2:-$1}-httpd.log" 2>&1
docker cp ${httpd_cont}:/usr/local/apache2/logs/access_log "logs/${2:-$1}-httpd_access.log" 2> /dev/null || true
fi

if [ $CODE_COVERAGE ]; then
docker exec ${httpd_cont} /usr/local/apache2/bin/apachectl stop
# preserve the coverage files
# docker has problems with names containing spaces
f=$(echo ${2:-1} | sed 's/ /-/g')
docker exec ${httpd_cont} find / -name "*.gcda" -exec stat -c "%d %y" {} \;
docker exec ${httpd_cont} sh -c "cd /; gcovr --gcov-ignore-errors=no_working_dir_found --json /coverage/coverage-$f.json > /coverage/coverage-$f.log 2>&1"
docker exec ${httpd_cont} sh -c "cd /; lcov --capture --directory . --output-file /coverage/coverage-$f.info > /coverage/coverage-lcov-$f.log 2>&1"

for f in $(docker exec ${httpd_cont} ls /coverage/); do
docker cp ${httpd_cont}:/coverage/$f $PWD/coverage/$f > /dev/null
done
fi

# Clean all after run
httpd_remove > /dev/null 2>&1
tomcat_all_remove > /dev/null 2>&1
Expand All @@ -54,7 +76,11 @@ httpd_create() {
done
cp -r ../native ../test /tmp/mod_proxy_cluster/
mv /tmp/mod_proxy_cluster httpd/
docker build -t $HTTPD_IMG -f httpd/Containerfile httpd/

docker build -t $HTTPD_IMG --build-arg CFLAGS="$MPC_CFLAGS" \
--build-arg LDFLAGS="$MPC_LDFLAGS" \
--build-arg HTTPD_EXTRA_FLAGS="$HTTPD_EXTRA_FLAGS" \
-f httpd/Containerfile httpd/
}

# Build and run httpd container
Expand Down
Loading
Loading