# Description of Changes

<!--
Please provide a summary of the changes, including:

- What was changed
- Why the change was made
- Any challenges encountered

Closes #(issue_number)
-->

---

## Checklist

### General

- [ ] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [ ] I have performed a self-review of my own code
- [ ] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing)
for more details.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
Signed-off-by: stirlingbot[bot] <stirlingbot[bot]@users.noreply.github.com>
Co-authored-by: ConnorYoh <40631091+ConnorYoh@users.noreply.github.com>
Co-authored-by: Connor Yoh <connor@stirlingpdf.com>
Co-authored-by: OUNZAR Aymane <aymane.ounzar@imt-atlantique.net>
Co-authored-by: YAOU Reda <yaoureda24@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com>
Co-authored-by: Balázs Szücs <127139797+balazs-szucs@users.noreply.github.com>
Co-authored-by: Ludy <Ludy87@users.noreply.github.com>
Co-authored-by: tkymmm <136296842+tkymmm@users.noreply.github.com>
Co-authored-by: Peter Dave Hello <hsu@peterdavehello.org>
Co-authored-by: albanobattistella <34811668+albanobattistella@users.noreply.github.com>
Co-authored-by: PingLin8888 <88387490+PingLin8888@users.noreply.github.com>
Co-authored-by: FdaSilvaYY <FdaSilvaYY@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: OteJlo <106060728+OteJlo@users.noreply.github.com>
Co-authored-by: Angel <41905618+TheShadowAngel@users.noreply.github.com>
Co-authored-by: Ricardo Catarino <ricardomicc@gmail.com>
Co-authored-by: Luis Antonio Argüelles González <luis.arguelles@encora.com>
Co-authored-by: Dawid Urbański <31166488+urbaned121@users.noreply.github.com>
Co-authored-by: Stephan Paternotte <Stephan-P@users.noreply.github.com>
Co-authored-by: Leonardo Santos Paulucio <leonardo.paulucio@hotmail.com>
Co-authored-by: hamza khalem <72972114+hamzakhalem@users.noreply.github.com>
Co-authored-by: IT Creativity + Art Team <admin@it-playground.net>
Co-authored-by: Reece Browne <74901996+reecebrowne@users.noreply.github.com>
Co-authored-by: James Brunton <jbrunton96@gmail.com>
Co-authored-by: Victor Villarreal <133383186+vvillarreal-cfee@users.noreply.github.com>
This commit is contained in:
Anthony Stirling
2025-12-21 10:40:32 +00:00
committed by GitHub
parent a5dcdd5bd9
commit 68ed54e398
343 changed files with 25212 additions and 6592 deletions

View File

@@ -1,5 +1,20 @@
#!/bin/bash
# Usage function
usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " --rerun-failed Rerun only the tests that failed in the last run"
echo " --rerun \"test1,test2,...\" Rerun specific tests (comma-separated)"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 # Run all tests"
echo " $0 --rerun-failed # Rerun tests that failed previously"
echo " $0 --rerun \"Stirling-PDF-Regression Stirling-PDF-Security-Fat-with-login,Webpage-Accessibility-full\""
exit 0
}
# Find project root by locating build.gradle
find_root() {
local dir="$PWD"
@@ -16,27 +31,57 @@ find_root() {
PROJECT_ROOT=$(find_root)
# Function to check the health of the service with a timeout of 80 seconds
# Function to check application readiness via HTTP instead of Docker's health status
check_health() {
local service_name=$1
local container_name=$1 # real container name
local compose_file=$2
local end=$((SECONDS+60))
local timeout=80 # total timeout in seconds
local interval=3 # poll interval in seconds
local end=$((SECONDS + timeout))
local last_code="000"
echo -n "Waiting for $service_name to become healthy..."
until [ "$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}healthy{{end}}' "$service_name")" == "healthy" ] || [ $SECONDS -ge $end ]; do
sleep 3
echo -n "."
if [ $SECONDS -ge $end ]; then
echo -e "\n$service_name health check timed out after 80 seconds."
echo "Printing logs for $service_name:"
docker logs "$service_name"
return 1
# Check if container has API key configured
local api_key=$(docker inspect "$container_name" --format '{{range .Config.Env}}{{println .}}{{end}}' 2>/dev/null | grep "SECURITY_CUSTOMGLOBALAPIKEY=" | cut -d'=' -f2)
if [ -n "$api_key" ]; then
echo "Using API key for health check: ${api_key:0:3}***"
fi
echo "Waiting for $container_name to become reachable on http://localhost:8080/api/v1/info/status (timeout ${timeout}s)..."
while [ $SECONDS -lt $end ]; do
# Optional: check if container is running at all (nice for debugging)
if ! docker ps --format '{{.Names}}' | grep -Fxq "$container_name"; then
echo " Container $container_name not running yet (still waiting)..."
fi
# Try API status endpoint with optional API key
if [ -n "$api_key" ]; then
last_code=$(curl -s -o /dev/null -w '%{http_code}' -H "X-API-KEY: $api_key" "http://localhost:8080/api/v1/info/status") || last_code="000"
else
last_code=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:8080/api/v1/info/status") || last_code="000"
fi
# Treat any 2xx as "ready"
if [ "$last_code" -ge 200 ] && [ "$last_code" -lt 300 ]; then
echo "$container_name is reachable over HTTP (status $last_code)."
echo "Printing logs for $container_name:"
docker logs "$container_name" || true
return 0
fi
echo " Still waiting for HTTP readiness, current status: $last_code"
sleep "$interval"
done
echo -e "\n$service_name is healthy!"
echo "Printing logs for $service_name:"
docker logs "$service_name"
return 0
echo "$container_name did not become HTTP-ready within ${timeout}s (last HTTP status: $last_code)."
# For extra debugging: show Docker health status, but DO NOT depend on it
local docker_health
docker_health=$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}(no healthcheck){{end}}' "$container_name" 2>/dev/null || echo "inspect failed")
echo "Docker-reported health status for $container_name: $docker_health"
echo "Printing logs for $container_name:"
docker logs "$container_name" || true
return 1
}
# Function to capture file list from a Docker container
@@ -47,21 +92,20 @@ capture_file_list() {
echo "Capturing file list from $container_name..."
# Get all files in one command, output directly from Docker to avoid path issues
# Skip proc, sys, dev, and the specified LibreOffice config directory
# Also skip PDFBox and LibreOffice temporary files
docker exec $container_name sh -c "find / -type f \
# Also skip PDFBox, LibreOffice, and Jetty temporary files
docker exec "$container_name" sh -c "find / -type f \
-not -path '*/proc/*' \
-not -path '*/sys/*' \
-not -path '*/dev/*' \
-not -path '/config/*' \
-not -path '/configs/scripts/python/*' \
-not -path '/configs/*' \
-not -path '/logs/*' \
-not -path '*/home/stirlingpdfuser/.config/libreoffice/*' \
-not -path '*/home/stirlingpdfuser/.pdfbox.cache' \
-not -path '*/tmp/stirling-pdf/PDFBox*' \
-not -path '*/tmp/stirling-pdf/hsperfdata_stirlingpdfuser/*' \
-not -path '*/tmp/hsperfdata_stirlingpdfuser/*' \
-not -path '/tmp/stirling-pdf/jetty-*' \
-not -path '/tmp/stirling-pdf/jetty-*/*' \
-not -path '*/tmp/stirling-pdf/jetty-*/*' \
-not -path '*/tmp/stirling-pdf/lu*' \
-not -path '*/tmp/stirling-pdf/tmp*' \
2>/dev/null | xargs -I{} sh -c 'stat -c \"%n %s %Y\" \"{}\" 2>/dev/null || true' | sort" > "$output_file"
@@ -72,20 +116,19 @@ capture_file_list() {
echo "Trying alternative approach..."
# Alternative simpler approach - just get paths as a fallback
docker exec $container_name sh -c "find / -type f \
docker exec "$container_name" sh -c "find / -type f \
-not -path '*/proc/*' \
-not -path '*/sys/*' \
-not -path '*/dev/*' \
-not -path '/config/*' \
-not -path '/configs/scripts/python/*' \
-not -path '/configs/*' \
-not -path '/logs/*' \
-not -path '*/home/stirlingpdfuser/.config/libreoffice/*' \
-not -path '*/home/stirlingpdfuser/.pdfbox.cache' \
-not -path '*/tmp/PDFBox*' \
-not -path '*/tmp/hsperfdata_stirlingpdfuser/*' \
-not -path '*/tmp/stirling-pdf/hsperfdata_stirlingpdfuser/*' \
-not -path '/tmp/stirling-pdf/jetty-*' \
-not -path '/tmp/stirling-pdf/jetty-*/*' \
-not -path '*/tmp/stirling-pdf/jetty-*/*' \
-not -path '*/tmp/lu*' \
-not -path '*/tmp/tmp*' \
2>/dev/null | sort" > "$output_file"
@@ -112,14 +155,8 @@ compare_file_lists() {
# Check if files exist and have content
if [ ! -s "$before_file" ] || [ ! -s "$after_file" ]; then
echo "WARNING: One or both file lists are empty."
if [ ! -s "$before_file" ]; then
echo "Before file is empty: $before_file"
fi
if [ ! -s "$after_file" ]; then
echo "After file is empty: $after_file"
fi
if [ ! -s "$before_file" ]; then echo "Before file is empty: $before_file"; fi
if [ ! -s "$after_file" ]; then echo "After file is empty: $after_file"; fi
# Create empty diff file
> "$diff_file"
@@ -138,7 +175,6 @@ compare_file_lists() {
echo "No temporary files found in the after snapshot."
fi
fi
return 0
fi
@@ -175,7 +211,6 @@ compare_file_lists() {
else
echo "No file changes detected during test."
fi
return 0
}
@@ -191,17 +226,18 @@ verify_app_version() {
echo "Checking version for $service_name (expecting $EXPECTED_VERSION)..."
# Try to access the status endpoint and extract the version
# Use the API endpoint to get version information
local response
response=$(curl -s "$base_url/api/v1/info/status")
response=$(curl -s "${base_url}/api/v1/info/status")
# Extract version from JSON response using grep and sed
local actual_version
actual_version=$(echo "$response" | grep -o '"version":"[^"]*"' | head -1 | sed 's/"version":"//' | sed 's/"//')
actual_version=$(echo "$response" | grep -o '"version":"[^"]*"' | head -1 | sed 's/"version":"\(.*\)"/\1/')
# Check if we got a valid response
# Check if we got a version
if [ -z "$actual_version" ]; then
echo "❌ Version verification failed: Could not find version information in status endpoint"
echo "❌ Version verification failed: Could not find version in API response"
echo "API response: $response"
return 1
fi
@@ -221,19 +257,33 @@ verify_app_version() {
# Function to test a Docker Compose configuration
test_compose() {
local compose_file=$1
local service_name=$2
local test_name=$2
local status=0
echo "Testing $compose_file configuration..."
echo "Testing ${compose_file} configuration..."
# Start up the Docker Compose service with forced rebuild
docker-compose -f "$compose_file" up -d --build
# Start up the Docker Compose service
docker-compose -f "$compose_file" up -d
# Wait for the service to become healthy
if check_health "$service_name" "$compose_file"; then
echo "$service_name test passed."
# Wait a moment for containers to appear
sleep 3
local container_name
container_name=$(docker-compose -f "$compose_file" ps --format '{{.Names}}' --filter "status=running" | head -n1)
if [[ -z "$container_name" ]]; then
echo "ERROR: No running container found for ${compose_file}"
docker-compose -f "$compose_file" ps
return 1
fi
echo "Started container: $container_name"
# Wait for the service to become healthy (HTTP-based)
if check_health "$container_name" "$compose_file"; then
echo "${test_name} test passed."
else
echo "$service_name test failed."
echo "${test_name} test failed."
status=1
fi
@@ -244,10 +294,66 @@ test_compose() {
declare -a passed_tests
declare -a failed_tests
# File to store failed tests
FAILED_TESTS_FILE="$PROJECT_ROOT/testing/.failed_tests"
# Function to save failed tests to file
# Note: This OVERWRITES (not appends) the file each run, so the list resets every time
save_failed_tests() {
if [ ${#failed_tests[@]} -ne 0 ]; then
echo "Saving failed tests to $FAILED_TESTS_FILE"
printf "%s\n" "${failed_tests[@]}" > "$FAILED_TESTS_FILE"
echo "Failed tests saved. To rerun them: $0 --rerun-failed"
else
# Remove the file if all tests passed
rm -f "$FAILED_TESTS_FILE"
echo "All tests passed - cleared failed tests file"
fi
}
# Function to load failed tests from file
load_failed_tests() {
if [ -f "$FAILED_TESTS_FILE" ]; then
echo "Loading failed tests from previous run..."
mapfile -t RERUN_TESTS < "$FAILED_TESTS_FILE"
echo "Found ${#RERUN_TESTS[@]} failed test(s) to rerun:"
for test in "${RERUN_TESTS[@]}"; do
echo " - $test"
done
return 0
else
echo "No failed tests file found at $FAILED_TESTS_FILE"
echo "Run tests normally first, then use --rerun-failed"
exit 1
fi
}
# Function to check if a test should be run
should_run_test() {
local test_name=$1
if [ ${#RERUN_TESTS[@]} -eq 0 ]; then
# No filter - run all tests
return 0
fi
# Check if this test is in the rerun list
for rerun_test in "${RERUN_TESTS[@]}"; do
if [[ "$test_name" == "$rerun_test" ]]; then
return 0
fi
done
return 1
}
run_tests() {
local test_name=$1
local compose_file=$2
if ! should_run_test "$test_name"; then
echo "Skipping $test_name (not in rerun list)"
return 0
fi
if test_compose "$compose_file" "$test_name"; then
passed_tests+=("$test_name")
else
@@ -255,142 +361,207 @@ run_tests() {
fi
}
# Main testing routine
main() {
SECONDS=0
cd "$PROJECT_ROOT"
# Parse command line arguments
RERUN_MODE=false
declare -a RERUN_TESTS
while [[ $# -gt 0 ]]; do
case $1 in
--rerun-failed)
RERUN_MODE=true
load_failed_tests
shift
;;
--rerun)
RERUN_MODE=true
if [[ -z "$2" ]]; then
echo "Error: --rerun requires a comma-separated list of test names"
usage
fi
# Split comma-separated list into array
IFS=',' read -ra RERUN_TESTS <<< "$2"
echo "Rerunning ${#RERUN_TESTS[@]} specified test(s):"
for test in "${RERUN_TESTS[@]}"; do
echo " - $test"
done
shift 2
;;
-h|--help)
usage
;;
*)
echo "Unknown option: $1"
usage
;;
esac
done
export DOCKER_CLI_EXPERIMENTAL=enabled
export COMPOSE_DOCKER_CLI_BUILD=0
export DISABLE_ADDITIONAL_FEATURES=true
# Run the gradlew build command and check if it fails
if ! ./gradlew clean build; then
echo "Gradle build failed with security disabled, exiting script."
exit 1
fi
# ==================================================================
# 1. Ultra-Lite (no additional features)
# ==================================================================
# Check if any ultra-lite tests need to run before building
if should_run_test "Stirling-PDF-Ultra-Lite" || \
should_run_test "Webpage-Accessibility-lite" || \
should_run_test "Stirling-PDF-Ultra-Lite-Version-Check"; then
# Get expected version after the build to ensure version.properties is created
echo "Getting expected version from Gradle..."
EXPECTED_VERSION=$(get_expected_version)
echo "Expected version: $EXPECTED_VERSION"
export DISABLE_ADDITIONAL_FEATURES=true
if ! ./gradlew clean build; then
echo "Gradle build failed with security disabled, exiting script."
exit 1
fi
# Test each configuration
run_tests "Stirling-PDF-Ultra-Lite" "./testing/compose/docker-compose-ultra-lite.yml"
# echo "Testing webpage accessibility..."
# cd "testing"
# if ./test_webpages.sh -f webpage_urls.txt -b http://localhost:8080; then
# passed_tests+=("Webpage-Accessibility-lite")
# else
# failed_tests+=("Webpage-Accessibility-lite")
# echo "Webpage accessibility lite tests failed"
# fi
# cd "$PROJECT_ROOT"
# Get expected version after the build to ensure version.properties is created
echo "Getting expected version from Gradle..."
EXPECTED_VERSION=$(get_expected_version)
echo "Expected version: $EXPECTED_VERSION"
echo "Testing version verification..."
if verify_app_version "Stirling-PDF-Ultra-Lite" "http://localhost:8080"; then
passed_tests+=("Stirling-PDF-Ultra-Lite-Version-Check")
echo "Version verification passed for Stirling-PDF-Ultra-Lite"
# Build Ultra-Lite image with embedded frontend (GHCR tag, matching docker-compose-latest-ultra-lite.yml)
echo "Building ultra-lite image for tests that require it..."
docker build --build-arg VERSION_TAG=alpha \
-t docker.stirlingpdf.com/stirlingtools/stirling-pdf:ultra-lite \
-f ./docker/embedded/Dockerfile.ultra-lite .
else
failed_tests+=("Stirling-PDF-Ultra-Lite-Version-Check")
echo "Version verification failed for Stirling-PDF-Ultra-Lite"
echo "Skipping ultra-lite image build - no ultra-lite tests in rerun list"
fi
docker-compose -f "./testing/compose/docker-compose-ultra-lite.yml" down
# Clean up any generated config files
echo "Cleaning up generated config files..."
rm -rf "$PROJECT_ROOT/stirling/" 2>/dev/null || true
# Test Ultra-Lite configuration
run_tests "Stirling-PDF-Ultra-Lite" "./docker/embedded/compose/docker-compose-latest-ultra-lite.yml"
export DISABLE_ADDITIONAL_FEATURES=false
# Run the gradlew build command and check if it fails
if ! ./gradlew clean build; then
echo "Gradle build failed with security enabled, exiting script."
exit 1
if should_run_test "Webpage-Accessibility-lite"; then
echo "Testing webpage accessibility..."
cd "testing"
if ./test_webpages.sh -f webpage_urls.txt -b http://localhost:8080; then
passed_tests+=("Webpage-Accessibility-lite")
else
failed_tests+=("Webpage-Accessibility-lite")
echo "Webpage accessibility lite tests failed"
fi
cd "$PROJECT_ROOT"
fi
# Get expected version after the security-enabled build
echo "Getting expected version from Gradle (security enabled)..."
EXPECTED_VERSION=$(get_expected_version)
echo "Expected version with security enabled: $EXPECTED_VERSION"
if should_run_test "Stirling-PDF-Ultra-Lite-Version-Check"; then
echo "Testing version verification..."
if verify_app_version "Stirling-PDF-Ultra-Lite" "http://localhost:8080"; then
passed_tests+=("Stirling-PDF-Ultra-Lite-Version-Check")
echo "Version verification passed for Stirling-PDF-Ultra-Lite"
else
failed_tests+=("Stirling-PDF-Ultra-Lite-Version-Check")
echo "Version verification failed for Stirling-PDF-Ultra-Lite"
fi
fi
# Test each configuration with security
run_tests "Stirling-PDF-Security" "./testing/compose/docker-compose-security.yml"
# echo "Testing webpage accessibility..."
# cd "testing"
# if ./test_webpages.sh -f webpage_urls_full.txt -b http://localhost:8080; then
# passed_tests+=("Webpage-Accessibility-full")
# else
# failed_tests+=("Webpage-Accessibility-full")
# echo "Webpage accessibility full tests failed"
# fi
# cd "$PROJECT_ROOT"
docker-compose -f "./docker/embedded/compose/docker-compose-latest-ultra-lite.yml" down -v
echo "Testing version verification..."
if verify_app_version "Stirling-PDF-Security" "http://localhost:8080"; then
passed_tests+=("Stirling-PDF-Security-Version-Check")
echo "Version verification passed for Stirling-PDF-Security"
# ==================================================================
# 2. Full Fat + Security
# ==================================================================
# Check if any fat image tests need to run before building
if should_run_test "Stirling-PDF-Security-Fat" || \
should_run_test "Webpage-Accessibility-full" || \
should_run_test "Stirling-PDF-Security-Fat-Version-Check" || \
should_run_test "Stirling-PDF-Security-Fat-with-login" || \
should_run_test "Stirling-PDF-Regression Stirling-PDF-Security-Fat-with-login" || \
should_run_test "Stirling-PDF-Fat-Disable-Endpoints" || \
should_run_test "Disabled-Endpoints" || \
should_run_test "Stirling-PDF-Fat-Disable-Endpoints-Version-Check"; then
export DISABLE_ADDITIONAL_FEATURES=false
if ! ./gradlew clean build; then
echo "Gradle build failed with security enabled, exiting script."
exit 1
fi
echo "Getting expected version from Gradle (security enabled)..."
EXPECTED_VERSION=$(get_expected_version)
echo "Expected version with security enabled: $EXPECTED_VERSION"
# Build Fat (Security) image with embedded frontend for GHCR tag used in all 'fat' compose files
echo "Building fat image for tests that require it..."
docker build --no-cache --pull --build-arg VERSION_TAG=alpha \
-t docker.stirlingpdf.com/stirlingtools/stirling-pdf:fat \
-f ./docker/embedded/Dockerfile.fat .
else
failed_tests+=("Stirling-PDF-Security-Version-Check")
echo "Version verification failed for Stirling-PDF-Security"
echo "Skipping fat image build - no fat tests in rerun list"
fi
docker-compose -f "./testing/compose/docker-compose-security.yml" down
# Clean up any generated config files
echo "Cleaning up generated config files..."
rm -rf "$PROJECT_ROOT/stirling/" 2>/dev/null || true
# Test fat + security compose
run_tests "Stirling-PDF-Security-Fat" "./docker/embedded/compose/docker-compose-latest-fat-security.yml"
run_tests "Stirling-PDF-Security-with-login" "./testing/compose/docker-compose-security-with-login.yml"
if should_run_test "Webpage-Accessibility-full"; then
echo "Testing webpage accessibility..."
cd "testing"
if ./test_webpages.sh -f webpage_urls_full.txt -b http://localhost:8080; then
passed_tests+=("Webpage-Accessibility-full")
else
failed_tests+=("Webpage-Accessibility-full")
echo "Webpage accessibility full tests failed"
fi
cd "$PROJECT_ROOT"
fi
if should_run_test "Stirling-PDF-Security-Fat-Version-Check"; then
echo "Testing version verification..."
if verify_app_version "Stirling-PDF-Security-Fat" "http://localhost:8080"; then
passed_tests+=("Stirling-PDF-Security-Fat-Version-Check")
echo "Version verification passed for Stirling-PDF-Security-Fat"
else
failed_tests+=("Stirling-PDF-Security-Fat-Version-Check")
echo "Version verification failed for Stirling-PDF-Security-Fat"
fi
fi
docker-compose -f "./docker/embedded/compose/docker-compose-latest-fat-security.yml" down -v
# ==================================================================
# 3. Regression test with login (test_cicd.yml)
# ==================================================================
run_tests "Stirling-PDF-Security-Fat-with-login" "./docker/embedded/compose/test_cicd.yml"
# Only run behave tests if the container started successfully
if [[ " ${passed_tests[*]} " =~ "Stirling-PDF-Security-Fat-with-login" ]]; then
CONTAINER_NAME=$(docker-compose -f "./docker/embedded/compose/test_cicd.yml" ps --format '{{.Names}}' --filter "status=running" | head -n1)
if [ $? -eq 0 ]; then
# Create directory for file snapshots if it doesn't exist
SNAPSHOT_DIR="$PROJECT_ROOT/testing/file_snapshots"
mkdir -p "$SNAPSHOT_DIR"
# Capture file list before running behave tests
BEFORE_FILE="$SNAPSHOT_DIR/files_before_behave.txt"
AFTER_FILE="$SNAPSHOT_DIR/files_after_behave.txt"
DIFF_FILE="$SNAPSHOT_DIR/files_diff.txt"
# Define container name variable for consistency
CONTAINER_NAME="Stirling-PDF-Security-with-login"
capture_file_list "$CONTAINER_NAME" "$BEFORE_FILE"
cd "testing/cucumber"
if python -m behave; then
# Wait 10 seconds before capturing the file list after tests
echo "Waiting 5 seconds for any file operations to complete..."
sleep 5
# Capture file list after running behave tests
cd "$PROJECT_ROOT"
capture_file_list "$CONTAINER_NAME" "$AFTER_FILE"
# Compare file lists
if compare_file_lists "$BEFORE_FILE" "$AFTER_FILE" "$DIFF_FILE" "$CONTAINER_NAME"; then
echo "No unexpected temporary files found."
passed_tests+=("Stirling-PDF-Regression")
passed_tests+=("Stirling-PDF-Regression $CONTAINER_NAME")
else
echo "WARNING: Unexpected temporary files detected after behave tests!"
failed_tests+=("Stirling-PDF-Regression-Temp-Files")
fi
passed_tests+=("Stirling-PDF-Regression")
passed_tests+=("Stirling-PDF-Regression $CONTAINER_NAME")
else
failed_tests+=("Stirling-PDF-Regression")
failed_tests+=("Stirling-PDF-Regression $CONTAINER_NAME")
echo "Printing docker logs of failed regression"
docker logs "$CONTAINER_NAME"
echo "Printed docker logs of failed regression"
# Still capture file list after failure for analysis
# Wait 10 seconds before capturing the file list
echo "Waiting 5 seconds before capturing file list..."
echo "Waiting 10 seconds before capturing file list..."
sleep 10
cd "$PROJECT_ROOT"
@@ -398,35 +569,61 @@ main() {
compare_file_lists "$BEFORE_FILE" "$AFTER_FILE" "$DIFF_FILE" "$CONTAINER_NAME"
fi
fi
docker-compose -f "./docker/embedded/compose/test_cicd.yml" down -v
docker-compose -f "./testing/compose/docker-compose-security-with-login.yml" down
# Clean up any generated config files
echo "Cleaning up generated config files..."
rm -rf "$PROJECT_ROOT/stirling/" 2>/dev/null || true
# ==================================================================
# 4. Disabled Endpoints Test
# ==================================================================
run_tests "Stirling-PDF-Fat-Disable-Endpoints" "./docker/embedded/compose/docker-compose-latest-fat-endpoints-disabled.yml"
if should_run_test "Disabled-Endpoints"; then
echo "Testing disabled endpoints..."
if ./testing/test_disabledEndpoints.sh -f ./testing/endpoints.txt -b http://localhost:8080; then
passed_tests+=("Disabled-Endpoints")
else
failed_tests+=("Disabled-Endpoints")
echo "Disabled Endpoints tests failed"
fi
fi
# Report results
if should_run_test "Stirling-PDF-Fat-Disable-Endpoints-Version-Check"; then
echo "Testing version verification..."
if verify_app_version "Stirling-PDF-Fat-Disable-Endpoints" "http://localhost:8080"; then
passed_tests+=("Stirling-PDF-Fat-Disable-Endpoints-Version-Check")
echo "Version verification passed for Stirling-PDF-Fat-Disable-Endpoints"
else
failed_tests+=("Stirling-PDF-Fat-Disable-Endpoints-Version-Check")
echo "Version verification failed for Stirling-PDF-Fat-Disable-Endpoints"
fi
fi
docker-compose -f "./docker/embedded/compose/docker-compose-latest-fat-endpoints-disabled.yml" down -v
# ==================================================================
# Final Report
# ==================================================================
echo "All tests completed in $SECONDS seconds."
if [ ${#passed_tests[@]} -ne 0 ]; then
echo "Passed tests:"
for test in "${passed_tests[@]}"; do
echo -e "\e[32m$test\e[0m"
done
fi
for test in "${passed_tests[@]}"; do
echo -e "\e[32m$test\e[0m" # Green color for passed tests
done
if [ ${#failed_tests[@]} -ne 0 ]; then
echo "Failed tests:"
for test in "${failed_tests[@]}"; do
echo -e "\e[31m$test\e[0m"
done
fi
for test in "${failed_tests[@]}"; do
echo -e "\e[31m$test\e[0m" # Red color for failed tests
done
# Check if there are any failed tests and exit with an error code if so
# Save failed tests for potential rerun
save_failed_tests
if [ ${#failed_tests[@]} -ne 0 ]; then
echo "Some tests failed."
echo "To rerun only failed tests, use: $0 --rerun-failed"
exit 1
else
echo "All tests passed successfully."
@@ -434,4 +631,4 @@ main() {
fi
}
main
main "$@"