Initial commit: mod_reqin_log Apache module
Features: - JSON logging of HTTP requests to Unix domain socket - Configurable HTTP headers logging (flat JSON structure) - Header value truncation and count limits - Automatic reconnect on socket disconnection - Error reporting with throttling Configuration directives: - JsonSockLogEnabled: Enable/disable logging - JsonSockLogSocket: Unix socket path - JsonSockLogHeaders: List of headers to log - JsonSockLogMaxHeaders: Maximum headers to log - JsonSockLogMaxHeaderValueLen: Max header value length - JsonSockLogReconnectInterval: Reconnect delay - JsonSockLogErrorReportInterval: Error log throttle Includes: - Module source code (src/) - Unit and integration tests (tests/, scripts/) - Documentation (README.md, architecture.yml) - Build configuration (CMakeLists.txt, Makefile) - Packaging (deb/rpm) Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
202
.github/workflows/ci.yml
vendored
Normal file
202
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
# Build on Rocky Linux 8
|
||||
build-rocky-8:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: rockylinux:8
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
dnf install -y epel-release
|
||||
dnf install -y gcc make httpd httpd-devel apr-devel apr-util-devel rpm-build
|
||||
|
||||
- name: Build module
|
||||
run: |
|
||||
make APXS=/usr/bin/apxs
|
||||
|
||||
- name: Verify module
|
||||
run: |
|
||||
ls -la modules/mod_reqin_log.so
|
||||
|
||||
- name: Upload module artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mod_reqin_log-rocky8
|
||||
path: modules/mod_reqin_log.so
|
||||
|
||||
# Build on Debian
|
||||
build-debian:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: debian:stable
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y build-essential apache2 apache2-dev
|
||||
|
||||
- name: Build module
|
||||
run: |
|
||||
make APXS=/usr/bin/apxs
|
||||
|
||||
- name: Verify module
|
||||
run: |
|
||||
ls -la modules/mod_reqin_log.so
|
||||
|
||||
- name: Upload module artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mod_reqin_log-debian
|
||||
path: modules/mod_reqin_log.so
|
||||
|
||||
# Unit tests
|
||||
unit-tests:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: debian:stable
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y build-essential cmake libcmocka-dev apache2-dev
|
||||
|
||||
- name: Configure tests
|
||||
run: |
|
||||
mkdir -p build/tests
|
||||
cd build/tests
|
||||
cmake ../../
|
||||
|
||||
- name: Build tests
|
||||
run: |
|
||||
make -C build/tests
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
make -C build/tests run_tests
|
||||
|
||||
# Build RPM package
|
||||
build-rpm:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: rockylinux:8
|
||||
needs: [build-rocky-8]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
dnf install -y epel-release
|
||||
dnf install -y gcc make httpd httpd-devel apr-devel apr-util-devel rpm-build rpmlint
|
||||
|
||||
- name: Create source tarball
|
||||
run: |
|
||||
tar -czf mod_reqin_log-1.0.0.tar.gz --transform 's,^,mod_reqin_log-1.0.0/,' .
|
||||
|
||||
- name: Setup rpmbuild
|
||||
run: |
|
||||
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
||||
cp mod_reqin_log-1.0.0.tar.gz ~/rpmbuild/SOURCES/
|
||||
cp packaging/rpm/mod_reqin_log.spec ~/rpmbuild/SPECS/
|
||||
|
||||
- name: Build RPM
|
||||
run: |
|
||||
rpmbuild -ba ~/rpmbuild/SPECS/mod_reqin_log.spec
|
||||
|
||||
- name: Upload RPM artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: rpm-packages
|
||||
path: ~/rpmbuild/RPMS/x86_64/*.rpm
|
||||
|
||||
# Build DEB package
|
||||
build-deb:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: debian:stable
|
||||
needs: [build-debian]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y build-essential apache2 apache2-dev debhelper devscripts dpkg-dev
|
||||
|
||||
- name: Setup package metadata
|
||||
run: |
|
||||
cp -r packaging/deb/* ./debian/
|
||||
echo "1.0.0" > debian/changelog
|
||||
echo "mod_reqin_log (1.0.0) stable; urgency=medium" >> debian/changelog
|
||||
echo "" >> debian/changelog
|
||||
echo " * Initial release" >> debian/changelog
|
||||
echo "" >> debian/changelog
|
||||
echo " -- Developer <dev@example.com> $(date -R)" >> debian/changelog
|
||||
|
||||
- name: Build DEB
|
||||
run: |
|
||||
debuild -us -uc -b
|
||||
|
||||
- name: Upload DEB artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: deb-packages
|
||||
path: ../*.deb
|
||||
|
||||
# Integration tests
|
||||
integration-tests:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: rockylinux:8
|
||||
needs: [build-rocky-8]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
dnf install -y epel-release
|
||||
dnf install -y gcc make httpd httpd-devel apr-devel apr-util-devel python3 curl
|
||||
|
||||
- name: Build module
|
||||
run: |
|
||||
make APXS=/usr/bin/apxs
|
||||
|
||||
- name: Setup Apache configuration
|
||||
run: |
|
||||
mkdir -p /var/run/mod_reqin_log
|
||||
cp conf/mod_reqin_log.conf /etc/httpd/conf.d/
|
||||
echo "LoadModule reqin_log_module /github/workspace/modules/mod_reqin_log.so" > /etc/httpd/conf.d/00-mod_reqin_log.conf
|
||||
|
||||
- name: Start socket consumer
|
||||
run: |
|
||||
python3 scripts/socket_consumer.py &
|
||||
sleep 2
|
||||
|
||||
- name: Start Apache
|
||||
run: |
|
||||
httpd -t
|
||||
httpd -DFOREGROUND &
|
||||
sleep 3
|
||||
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
curl -H "X-Request-Id: test-123" http://localhost/
|
||||
curl -H "X-Trace-Id: trace-456" http://localhost/api
|
||||
sleep 2
|
||||
|
||||
- name: Verify logs
|
||||
run: |
|
||||
echo "Integration test completed"
|
||||
Reference in New Issue
Block a user