fix: migrate PaperMC to v3 API, fix NeoForge beta fallback, add test suite
- Migrate Paper loader from sunset v2 API to v3 (fill.papermc.io) - Fix NeoForge: fall back to beta versions when no stable exists (set -e + grep) - Fix setEula/setperms ordering (was writing eula.txt before /data was writable) - Fix setEula/serverInfoWrite to use absolute paths (/data/server/) - Add VOLUME directive removal (was shadowing bind mounts) - Add comprehensive API test suite (110 tests across 6 suites) - Move test.sh to tests/integration.sh, switch to named volumes - Add Docker build cache to CI workflows - Add .editorconfig, expand .gitignore, improve README docs
This commit is contained in:
Executable
+174
@@ -0,0 +1,174 @@
|
||||
#!/usr/bin/env bash
|
||||
# Main test runner for Dockercraft API tests
|
||||
# Runs all test suites against the external APIs to verify they're healthy
|
||||
# and returning expected data.
|
||||
#
|
||||
# Usage:
|
||||
# ./tests/run_tests.sh # Run all tests
|
||||
# ./tests/run_tests.sh -m 1.21.1 # Test with specific MC version
|
||||
# ./tests/run_tests.sh -s mojang # Run only Mojang tests
|
||||
# ./tests/run_tests.sh -s paper,fabric # Run Paper and Fabric tests
|
||||
# ./tests/run_tests.sh --list # List available test suites
|
||||
#
|
||||
# Exit codes:
|
||||
# 0 = all tests passed
|
||||
# 1 = one or more tests failed
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# ---------- configuration --------------------------------------------------
|
||||
|
||||
MC_VERSION=""
|
||||
SUITE=""
|
||||
LIST_ONLY=false
|
||||
|
||||
# Available test suites
|
||||
declare -A SUITES=(
|
||||
["mojang"]="test_mojang.sh"
|
||||
["paper"]="test_paper.sh"
|
||||
["fabric"]="test_fabric.sh"
|
||||
["forge"]="test_forge.sh"
|
||||
["neoforge"]="test_neoforge.sh"
|
||||
["bedrock"]="test_bedrock.sh"
|
||||
)
|
||||
|
||||
SUITE_ORDER=("mojang" "paper" "fabric" "forge" "neoforge" "bedrock")
|
||||
|
||||
# ---------- argument parsing -----------------------------------------------
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") [options]
|
||||
|
||||
Run API health and correctness tests for Dockercraft.
|
||||
|
||||
Options:
|
||||
-m, --mc-version <ver> Minecraft version (default: auto-detect latest)
|
||||
-s, --suite <name> Run specific suite(s), comma-separated
|
||||
Valid: mojang, paper, fabric, forge, neoforge, bedrock
|
||||
-l, --list List available test suites and exit
|
||||
-h, --help Show this help
|
||||
|
||||
Examples:
|
||||
$(basename "$0") # All suites, latest MC
|
||||
$(basename "$0") -m 1.21.1 # All suites, MC 1.21.1
|
||||
$(basename "$0") -s mojang # Just Mojang API tests
|
||||
$(basename "$0") -s paper,fabric,neoforge # Specific suites
|
||||
$(basename "$0") -l # List suites
|
||||
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
list_suites() {
|
||||
echo "Available test suites:"
|
||||
echo ""
|
||||
for s in "${SUITE_ORDER[@]}"; do
|
||||
echo " ${s} - ${SUITES[$s]}"
|
||||
done
|
||||
echo ""
|
||||
echo "Usage: $(basename "$0") -s mojang,paper"
|
||||
exit 0
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-h|--help) usage ;;
|
||||
-m|--mc-version) MC_VERSION="$2"; shift 2 ;;
|
||||
-s|--suite) SUITE="$2"; shift 2 ;;
|
||||
-l|--list) LIST_ONLY=true; shift ;;
|
||||
*) echo "Unknown option: $1"; usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if $LIST_ONLY; then
|
||||
list_suites
|
||||
fi
|
||||
|
||||
# ---------- detect MC version if needed ------------------------------------
|
||||
|
||||
if [[ -z "$MC_VERSION" ]]; then
|
||||
echo "Detecting latest Minecraft version..."
|
||||
MC_VERSION=$(curl -sf --connect-timeout 10 --max-time 30 \
|
||||
"https://launchermeta.mojang.com/mc/game/version_manifest.json" |
|
||||
jq -r '.latest.release')
|
||||
echo " -> ${MC_VERSION}"
|
||||
fi
|
||||
|
||||
# ---------- determine which suites to run ----------------------------------
|
||||
|
||||
if [[ -n "$SUITE" ]]; then
|
||||
IFS=',' read -ra RUN_SUITES <<< "$SUITE"
|
||||
else
|
||||
RUN_SUITES=("${SUITE_ORDER[@]}")
|
||||
fi
|
||||
|
||||
# ---------- validate suite names -------------------------------------------
|
||||
|
||||
for s in "${RUN_SUITES[@]}"; do
|
||||
if [[ -z "${SUITES[$s]+x}" ]]; then
|
||||
echo "Unknown suite: ${s}"
|
||||
echo "Valid suites: ${!SUITES[*]}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# ---------- run suites -----------------------------------------------------
|
||||
|
||||
OVERALL_PASS=0
|
||||
OVERALL_FAIL=0
|
||||
OVERALL_SUITES=0
|
||||
FAILED_SUITES=()
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo " Dockercraft API Test Runner"
|
||||
echo " MC Version: ${MC_VERSION}"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
for s in "${RUN_SUITES[@]}"; do
|
||||
test_file="${SCRIPT_DIR}/${SUITES[$s]}"
|
||||
|
||||
if [[ ! -f "$test_file" ]]; then
|
||||
echo "Test file not found: ${test_file}"
|
||||
OVERALL_FAIL=$((OVERALL_FAIL + 1))
|
||||
FAILED_SUITES+=("$s")
|
||||
continue
|
||||
fi
|
||||
|
||||
OVERALL_SUITES=$((OVERALL_SUITES + 1))
|
||||
|
||||
# Run the suite and capture exit code
|
||||
if bash "$test_file" "$MC_VERSION"; then
|
||||
OVERALL_PASS=$((OVERALL_PASS + 1))
|
||||
else
|
||||
OVERALL_FAIL=$((OVERALL_FAIL + 1))
|
||||
FAILED_SUITES+=("$s")
|
||||
fi
|
||||
done
|
||||
|
||||
# ---------- final summary --------------------------------------------------
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo " Overall Results"
|
||||
echo "========================================"
|
||||
echo " Suites run: ${OVERALL_SUITES}"
|
||||
echo " Suites passed: ${OVERALL_PASS}"
|
||||
echo " Suites failed: ${OVERALL_FAIL}"
|
||||
echo ""
|
||||
|
||||
if [[ $OVERALL_FAIL -gt 0 ]]; then
|
||||
echo "Failed suites:"
|
||||
for s in "${FAILED_SUITES[@]}"; do
|
||||
echo " - ${s}"
|
||||
done
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "All suites passed!"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user