mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 18:44:33 +00:00
Kong API Gateway (replacing prole nginx): - Add etc/init_kong.sh provisioning script (DB-less mode, prole-db namespace) - Add kong-deployment.yaml and kong-service.yaml manifests - Rewire ingress rules (svc/git/api.prole.org) to prole-db-kong:8000 - Update kustomization.yaml to reference kong manifests PostgREST & DB Manager in prole-db namespace: - Add etc/init_postgrest.sh and etc/init_db_manager.sh scripts - Add postgrest/db-manager deployment and service manifests - Add src/db-manager/ Node.js REST endpoint for backup triggers - Default NAMESPACE changed to prole-db in both scripts Docker image pre-load from PROLE_DATA/docker-import: - Add _preload_docker_images() to init_common_services.sh - Scan for .tar files exported by final_deployment.sh - Import via k3d image import (k3d) or ctr (k3s) before deployments - Increase rollout timeouts to 300s (configurable via ROLLOUT_TIMEOUT) in init_openbao.sh, init_opentofu.sh, init_garage_store.sh, init_registry.sh OpenTofu password resolution fix: - Add Kubernetes secret fallback in resolve_admin_password() - Change hard exit 1 to graceful return 1 with warning - Wrap call in if-guard so set -e doesn't abort the script chain Milestone fix (init scripts not running): - Add init_kong.sh, init_postgrest.sh, init_db_manager.sh to InitializationScriptsMilestone.execute() script list and arg branches - Previously only actions.py had these; milestones.py was missing them Installer integration: - Add Kong/PostgREST/DB Manager to silent installer _step_init_scripts - Add corresponding tabs and execution blocks in UI services.py
73 lines
2.1 KiB
Bash
Executable File
73 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Unit test for etc/init_db_manager.sh
|
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
PROLE_HOME=$(cd "$SCRIPT_DIR/../.." && pwd)
|
|
ETC_DIR="$PROLE_HOME/etc"
|
|
SCRIPT_UNDER_TEST="$ETC_DIR/init_db_manager.sh"
|
|
TMP_DIR=$(mktemp -d)
|
|
trap 'rm -rf "$TMP_DIR"' EXIT
|
|
# Mock tools
|
|
mock_tool() {
|
|
cat <<M_EOF > "$TMP_DIR/$1"
|
|
#!/usr/bin/env bash
|
|
echo "Mocked $1 called with \$@" >> "$TMP_DIR/mock_calls.log"
|
|
exit 0
|
|
M_EOF
|
|
chmod +x "$TMP_DIR/$1"
|
|
}
|
|
# Create mocks for common tools
|
|
mock_tool kubectl
|
|
mock_tool curl
|
|
mock_tool docker
|
|
mock_tool k3d
|
|
mock_tool ansible-playbook
|
|
mock_tool tofu
|
|
mock_tool terraform
|
|
mock_tool ollama
|
|
mock_tool jq
|
|
# Mock prole.cfg
|
|
mkdir -p "$TMP_DIR/conf"
|
|
cat <<C_EOF > "$TMP_DIR/conf/prole.cfg"
|
|
[globals]
|
|
prole.home = $PROLE_HOME
|
|
prole.mode = k3d
|
|
[k3s]
|
|
server = https://localhost:6443
|
|
token = test-token
|
|
C_EOF
|
|
export PATH="$TMP_DIR:$PATH"
|
|
export PROLE_HOME="$PROLE_HOME"
|
|
export PROLE_CONF="$TMP_DIR/conf"
|
|
export NAMESPACE="test-ns"
|
|
export PROLE_PASSWD="test-password"
|
|
# Run the script
|
|
if [[ "init_db_manager.sh" == *.py ]]; then
|
|
if [[ "init_db_manager.sh" == "render_manifest.py" ]]; then
|
|
echo "apiVersion: v1" > "$TMP_DIR/test.yaml"
|
|
python3 "$SCRIPT_UNDER_TEST" "$TMP_DIR/test.yaml" > "$TMP_DIR/stdout" 2> "$TMP_DIR/stderr"
|
|
else
|
|
python3 "$SCRIPT_UNDER_TEST" --help > "$TMP_DIR/stdout" 2> "$TMP_DIR/stderr"
|
|
fi
|
|
RC=$?
|
|
else
|
|
# Check for usage() or if it's a script that likely needs arguments
|
|
if grep -q "usage()" "$SCRIPT_UNDER_TEST"; then
|
|
bash "$SCRIPT_UNDER_TEST" --help > "$TMP_DIR/stdout" 2> "$TMP_DIR/stderr"
|
|
RC=$?
|
|
else
|
|
# Try a few common non-destructive actions
|
|
bash "$SCRIPT_UNDER_TEST" status > "$TMP_DIR/stdout" 2> "$TMP_DIR/stderr" || \
|
|
bash "$SCRIPT_UNDER_TEST" --help > "$TMP_DIR/stdout" 2> "$TMP_DIR/stderr" || \
|
|
bash "$SCRIPT_UNDER_TEST" > "$TMP_DIR/stdout" 2> "$TMP_DIR/stderr"
|
|
RC=$?
|
|
fi
|
|
fi
|
|
if [[ $RC -eq 0 || $RC -eq 1 || $RC -eq 2 ]]; then
|
|
echo "SUCCESS (RC=$RC)"
|
|
exit 0
|
|
else
|
|
echo "FAILURE with RC $RC"
|
|
cat "$TMP_DIR/stderr"
|
|
exit 1
|
|
fi
|