Files
nginx-ipng-stats-plugin/tests/01-module/lab/server/start.sh
Pim van Pelt 5a7e2f77f1 Add ngx_http_ipng_stats_module: per-VIP, per-device traffic counters
Full implementation of the nginx dynamic module with:
- SO_BINDTODEVICE-based per-interface traffic attribution
- Per-worker lock-free counters flushed to shared memory
- Prometheus text and JSON scrape endpoint at configurable location
- UDP-only global logtail (ipng_stats_logtail) for fire-and-forget
  access log streaming
- $ipng_source_tag nginx variable for use in log_format/map
- Histogram buckets, EWMA rate gauges, zone meta-metrics
- Debian packaging (libnginx-mod-http-ipng-stats)
- Robot Framework end-to-end tests via containerlab
- SPDX Apache-2.0 headers on all source files
2026-04-16 17:41:23 +02:00

43 lines
1.4 KiB
Bash

#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Server container entrypoint: installs nginx + module, waits for
# containerlab to create data-plane interfaces, starts the slow
# Python backend, and runs nginx in the foreground.
# Suppress automatic service start/restart during apt/dpkg.
printf '#!/bin/sh\nexit 101\n' > /usr/sbin/policy-rc.d
chmod +x /usr/sbin/policy-rc.d
apt-get update -qq
apt-get install -y -qq nginx python3 procps iproute2 ncat > /dev/null 2>&1
# Install the module .deb built by `make pkg-deb`.
dpkg -i /opt/build/libnginx-mod-http-ipng-stats_*.deb 2>/dev/null || true
# Re-enable module symlink in case postinst disabled it.
ln -sf /etc/nginx/modules-available/50-mod-http-ipng-stats.conf \
/etc/nginx/modules-enabled/50-mod-http-ipng-stats.conf
# Remove the policy block now that packages are installed.
rm -f /usr/sbin/policy-rc.d
# Wait for containerlab to attach the data-plane veth pairs.
for iface in eth1 eth2; do
echo "Waiting for $iface ..."
while ! ip link show "$iface" > /dev/null 2>&1; do
sleep 0.2
done
ip link set "$iface" up
done
ip addr add 10.0.1.1/24 dev eth1
ip addr add 10.0.2.1/24 dev eth2
# Slow backend: 50 ms sleep per request.
python3 /opt/config/slow-backend.py &
# UDP logtail listener — captures datagrams to a file for test validation.
ncat -u -l -k 127.0.0.1 9514 --recv-only >> /var/log/nginx/logtail-udp.log &
exec nginx -g 'daemon off;' -c /opt/config/nginx.conf