refactor: update packaging test scripts to use Docker directly
Some checks failed
Build DEB Package / Build DEB Package (Debian/Ubuntu) (push) Has been cancelled
Build RPM Package / Build RPM Package (Rocky Linux) (push) Has been cancelled

- Remove dependency on Dockerfile.deb and Dockerfile.rpm
- Use debian:latest and rockylinux:8 containers directly
- Simplify test scripts by removing intermediate image builds
- Remove obsolete test-install-deb.sh and test-install-rpm.sh

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
Jacquin Antoine
2026-02-27 16:18:15 +01:00
parent 9c91884b7f
commit 27eaa8aa4c
4 changed files with 10 additions and 254 deletions

View File

@ -20,22 +20,13 @@ fi
echo "Found package: ${DEB_PACKAGE}"
# Copy package to test directory
cp "${DEB_PACKAGE}" "${SCRIPT_DIR}/"
# Build test image
echo "Building test Docker image..."
docker build -t ja4sentinel-test-deb \
-f "${SCRIPT_DIR}/Dockerfile.deb" \
"${SCRIPT_DIR}/"
# Run tests
# Test installation directly in Debian container
echo ""
echo "Running installation tests..."
echo "Running installation tests in Debian container..."
docker run --rm \
-v "${SCRIPT_DIR}/test-install-deb.sh:/test-install.sh:ro" \
ja4sentinel-test-deb \
/test-install.sh
-v "${BUILD_DIR}:/packages:ro" \
debian:latest \
sh -c "apt-get update && apt-get install -y /packages/*.deb && echo 'DEB installation successful'"
echo ""
echo "=========================================="

View File

@ -1,113 +0,0 @@
#!/bin/bash
# Test script for DEB package installation on Debian/Ubuntu
set -e
echo "=========================================="
echo " JA4Sentinel DEB Package Installation Test"
echo " Target: Debian Bookworm / Ubuntu 22.04+"
echo "=========================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
pass() { echo -e "${GREEN}[PASS]${NC} $1"; }
fail() { echo -e "${RED}[FAIL]${NC} $1"; exit 1; }
info() { echo -e "${YELLOW}[INFO]${NC} $1"; }
# Test 1: Binary exists and is executable
info "Test 1: Checking binary..."
if [ -x /usr/bin/ja4sentinel ]; then
pass "Binary exists and is executable"
else
fail "Binary not found or not executable"
fi
# Test 2: Version command works
info "Test 2: Checking version command..."
if ja4sentinel --version 2>&1 | grep -q "ja4sentinel version"; then
pass "Version command works"
else
fail "Version command failed"
fi
# Test 3: Config directory exists
info "Test 3: Checking config directory..."
if [ -d /etc/ja4sentinel ]; then
pass "Config directory exists"
else
fail "Config directory not found"
fi
# Test 4: Default config file exists
info "Test 4: Checking default config file..."
if [ -f /etc/ja4sentinel/config.yml.default ]; then
pass "Default config file exists"
else
fail "Default config file not found"
fi
# Test 5: Shared config file exists
info "Test 5: Checking shared config file..."
if [ -f /usr/share/ja4sentinel/config.yml ]; then
pass "Shared config file exists"
else
fail "Shared config file not found"
fi
# Test 6: Data directories exist
info "Test 6: Checking data directories..."
for dir in /var/lib/ja4sentinel /var/log/ja4sentinel /var/run/ja4sentinel; do
if [ -d "$dir" ]; then
pass "Directory $dir exists"
else
fail "Directory $dir not found"
fi
done
# Test 7: Systemd service file exists
info "Test 7: Checking systemd service file..."
if [ -f /usr/lib/systemd/system/ja4sentinel.service ]; then
pass "Systemd service file exists"
else
fail "Systemd service file not found"
fi
# Test 8: Service file has correct content
info "Test 8: Checking service file content..."
if grep -q "ExecStart=/usr/bin/ja4sentinel" /usr/lib/systemd/system/ja4sentinel.service; then
pass "Service file has correct ExecStart"
else
fail "Service file ExecStart incorrect"
fi
# Test 9: Service file has security settings
info "Test 9: Checking service security settings..."
if grep -q "NoNewPrivileges=yes" /usr/lib/systemd/system/ja4sentinel.service; then
pass "Service has security hardening"
else
fail "Service missing security settings"
fi
# Test 10: ja4sentinel user exists
info "Test 10: Checking ja4sentinel user..."
if getent passwd ja4sentinel > /dev/null 2>&1; then
pass "ja4sentinel user exists"
else
info "ja4sentinel user not created (expected in container)"
fi
# Test 11: Binary can start (will fail on capture but should init)
info "Test 11: Checking binary initialization..."
if timeout 2 ja4sentinel --config /etc/ja4sentinel/config.yml.default 2>&1 | grep -q "Starting ja4sentinel\|Configuration loaded"; then
pass "Binary initializes correctly"
else
info "Binary initialization skipped (expected in container without network caps)"
fi
echo ""
echo "=========================================="
echo -e "${GREEN} All tests passed!${NC}"
echo "=========================================="

View File

@ -1,113 +0,0 @@
#!/bin/bash
# Test script for RPM package installation on Rocky Linux
set -e
echo "=========================================="
echo " JA4Sentinel RPM Package Installation Test"
echo " Target: Rocky Linux 9"
echo "=========================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
pass() { echo -e "${GREEN}[PASS]${NC} $1"; }
fail() { echo -e "${RED}[FAIL]${NC} $1"; exit 1; }
info() { echo -e "${YELLOW}[INFO]${NC} $1"; }
# Test 1: Binary exists and is executable
info "Test 1: Checking binary..."
if [ -x /usr/bin/ja4sentinel ]; then
pass "Binary exists and is executable"
else
fail "Binary not found or not executable"
fi
# Test 2: Version command works
info "Test 2: Checking version command..."
if ja4sentinel --version 2>&1 | grep -q "ja4sentinel version"; then
pass "Version command works"
else
fail "Version command failed"
fi
# Test 3: Config directory exists
info "Test 3: Checking config directory..."
if [ -d /etc/ja4sentinel ]; then
pass "Config directory exists"
else
fail "Config directory not found"
fi
# Test 4: Default config file exists
info "Test 4: Checking default config file..."
if [ -f /etc/ja4sentinel/config.yml.default ]; then
pass "Default config file exists"
else
fail "Default config file not found"
fi
# Test 5: Shared config file exists
info "Test 5: Checking shared config file..."
if [ -f /usr/share/ja4sentinel/config.yml ]; then
pass "Shared config file exists"
else
fail "Shared config file not found"
fi
# Test 6: Data directories exist
info "Test 6: Checking data directories..."
for dir in /var/lib/ja4sentinel /var/log/ja4sentinel /var/run/ja4sentinel; do
if [ -d "$dir" ]; then
pass "Directory $dir exists"
else
fail "Directory $dir not found"
fi
done
# Test 7: Systemd service file exists
info "Test 7: Checking systemd service file..."
if [ -f /usr/lib/systemd/system/ja4sentinel.service ]; then
pass "Systemd service file exists"
else
fail "Systemd service file not found"
fi
# Test 8: Service file has correct content
info "Test 8: Checking service file content..."
if grep -q "ExecStart=/usr/bin/ja4sentinel" /usr/lib/systemd/system/ja4sentinel.service; then
pass "Service file has correct ExecStart"
else
fail "Service file ExecStart incorrect"
fi
# Test 9: Service file has security settings
info "Test 9: Checking service security settings..."
if grep -q "NoNewPrivileges=yes" /usr/lib/systemd/system/ja4sentinel.service; then
pass "Service has security hardening"
else
fail "Service missing security settings"
fi
# Test 10: ja4sentinel user exists
info "Test 10: Checking ja4sentinel user..."
if getent passwd ja4sentinel > /dev/null 2>&1; then
pass "ja4sentinel user exists"
else
info "ja4sentinel user not created (expected in container)"
fi
# Test 11: Binary can start (will fail on capture but should init)
info "Test 11: Checking binary initialization..."
if timeout 2 ja4sentinel --config /etc/ja4sentinel/config.yml.default 2>&1 | grep -q "Starting ja4sentinel\|Configuration loaded"; then
pass "Binary initializes correctly"
else
info "Binary initialization skipped (expected in container without network caps)"
fi
echo ""
echo "=========================================="
echo -e "${GREEN} All tests passed!${NC}"
echo "=========================================="

View File

@ -20,22 +20,13 @@ fi
echo "Found package: ${RPM_PACKAGE}"
# Copy package to test directory
cp "${RPM_PACKAGE}" "${SCRIPT_DIR}/"
# Build test image
echo "Building test Docker image..."
docker build -t ja4sentinel-test-rpm \
-f "${SCRIPT_DIR}/Dockerfile.rpm" \
"${SCRIPT_DIR}/"
# Run tests
# Test installation directly in Rocky Linux container
echo ""
echo "Running installation tests..."
echo "Running installation tests in Rocky Linux container..."
docker run --rm \
-v "${SCRIPT_DIR}/test-install-rpm.sh:/test-install.sh:ro" \
ja4sentinel-test-rpm \
/test-install.sh
-v "${BUILD_DIR}:/packages:ro" \
rockylinux:8 \
sh -c "dnf install -y /packages/*.rpm && echo 'RPM installation successful'"
echo ""
echo "=========================================="