mirror of
https://github.com/Cacti/cacti.git
synced 2026-11-03 10:37:46 +09:00
* fix(docker): restrict the dev stack to localhost and make the poller run The web port bound to every interface, named volumes hid the shipped .htaccess denies, and the cron job could neither find php nor write to PID 1's output, so the poller never ran. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test(docker): keep harnesses polling and restore the developer's config.php check_docker.sh deleted an existing include/config.php on exit, health polling aborted under pipefail before the container reported, the MariaDB wait had no bound, and the BSD mktemp template left its Xs literal. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * docs(changelog): add fragment for #8453 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test(e2e): move the pointer off the Deepness multiselect button Deepness sets a zero body margin, so the unhovered #ms-button sits at the viewport origin and headless Chromium on Linux intermittently applies :hover to it. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * ci: pull pinned integration database from authenticated mirror Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
104 lines
3.9 KiB
Bash
Executable File
104 lines
3.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# +-------------------------------------------------------------------------+
|
|
# | Copyright (C) 2004-2026 The Cacti Group |
|
|
# | |
|
|
# | This program is free software; you can redistribute it and/or |
|
|
# | modify it under the terms of the GNU General Public License |
|
|
# | as published by the Free Software Foundation; either version 2 |
|
|
# | of the License, or (at your option) any later version. |
|
|
# +-------------------------------------------------------------------------+
|
|
# | Cacti: The Complete RRDtool-based Graphing Solution |
|
|
# +-------------------------------------------------------------------------+
|
|
#
|
|
# End-to-end check for the support_process_tables() plugin hook (#7353). Boots the
|
|
# Cacti Docker stack, then runs support_process_tables_probe.php inside the web
|
|
# container to confirm the hook returns well-formed process-table definitions
|
|
# against the real database.
|
|
#
|
|
# Requires Docker. Run from a checkout: tests/e2e/support_process_tables_docker.sh
|
|
set -euo pipefail
|
|
|
|
COMPOSE_PROJECT="cacti_support_proctab_e2e_$$"
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
REPO_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
ENV_FILE="$REPO_DIR/.env.support-proctab-e2e"
|
|
WEB_PORT=18084
|
|
DB_PORT=13310
|
|
CONFIG_EXISTED=0
|
|
CONFIG_BACKUP=""
|
|
|
|
cleanup() {
|
|
cd "$REPO_DIR"
|
|
docker compose -p "$COMPOSE_PROJECT" --env-file "$ENV_FILE" down -v --remove-orphans 2>/dev/null || true
|
|
rm -f "$ENV_FILE"
|
|
|
|
if [ "$CONFIG_EXISTED" -eq 1 ] && [ -n "$CONFIG_BACKUP" ] && [ -f "$CONFIG_BACKUP" ]; then
|
|
# The entrypoint may have created a container-owned config.php that cp
|
|
# cannot open for writing; the host user can still unlink it.
|
|
rm -f "$REPO_DIR/include/config.php"
|
|
cp "$CONFIG_BACKUP" "$REPO_DIR/include/config.php"
|
|
rm -f "$CONFIG_BACKUP"
|
|
elif [ "$CONFIG_EXISTED" -eq 0 ]; then
|
|
rm -f "$REPO_DIR/include/config.php"
|
|
fi
|
|
}
|
|
|
|
# install the trap before touching config.php so a failure during backup still
|
|
# restores the developer's real config on exit
|
|
trap cleanup EXIT
|
|
|
|
if [ -f "$REPO_DIR/include/config.php" ]; then
|
|
CONFIG_EXISTED=1
|
|
CONFIG_BACKUP="$(mktemp "${TMPDIR:-/tmp}/cacti-config.XXXXXX")"
|
|
cp "$REPO_DIR/include/config.php" "$CONFIG_BACKUP"
|
|
rm -f "$REPO_DIR/include/config.php"
|
|
fi
|
|
|
|
cd "$REPO_DIR"
|
|
|
|
cat > "$ENV_FILE" <<EOF
|
|
WEB_PORT=$WEB_PORT
|
|
DB_ROOT_PASSWORD=testroot
|
|
DB_NAME=cacti
|
|
DB_USER=cacti
|
|
DB_PASSWORD=testpass
|
|
DB_PORT=$DB_PORT
|
|
TIMEZONE=UTC
|
|
PHP_MEMORY_LIMIT=256M
|
|
DB_MAX_CONNECTIONS=50
|
|
DB_BUFFER_POOL_SIZE=256M
|
|
EOF
|
|
|
|
echo "Building support process tables Docker test image..."
|
|
docker compose -p "$COMPOSE_PROJECT" --env-file "$ENV_FILE" build --quiet
|
|
|
|
echo "Starting support process tables Docker test stack..."
|
|
docker compose -p "$COMPOSE_PROJECT" --env-file "$ENV_FILE" up -d
|
|
|
|
echo "Waiting for Docker test stack..."
|
|
TRIES=0
|
|
while [ "$TRIES" -lt 36 ]; do
|
|
DB_HEALTH=$(docker compose -p "$COMPOSE_PROJECT" --env-file "$ENV_FILE" ps --format json 2>/dev/null | grep -o '"Health":"[^"]*"' | head -1 | cut -d'"' -f4 || true)
|
|
WEB_HEALTH=$(docker compose -p "$COMPOSE_PROJECT" --env-file "$ENV_FILE" ps --format json 2>/dev/null | grep -o '"Health":"[^"]*"' | tail -1 | cut -d'"' -f4 || true)
|
|
|
|
if [ "$DB_HEALTH" = "healthy" ] && [ "$WEB_HEALTH" = "healthy" ]; then
|
|
break
|
|
fi
|
|
|
|
sleep 5
|
|
TRIES=$((TRIES + 1))
|
|
done
|
|
|
|
if [ "${DB_HEALTH:-}" != "healthy" ] || [ "${WEB_HEALTH:-}" != "healthy" ]; then
|
|
docker compose -p "$COMPOSE_PROJECT" --env-file "$ENV_FILE" ps
|
|
exit 1
|
|
fi
|
|
|
|
WEB_CONTAINER=$(docker compose -p "$COMPOSE_PROJECT" --env-file "$ENV_FILE" ps -q web)
|
|
|
|
docker exec "$WEB_CONTAINER" php -l /var/www/html/cacti/support.php
|
|
docker exec "$WEB_CONTAINER" php -l /var/www/html/cacti/tests/e2e/support_process_tables_probe.php
|
|
PROBE_OUTPUT=$(docker exec "$WEB_CONTAINER" php /var/www/html/cacti/tests/e2e/support_process_tables_probe.php)
|
|
echo "$PROBE_OUTPUT"
|
|
grep -q 'PASS support process tables docker probe' <<<"$PROBE_OUTPUT"
|