mirror of
https://github.com/dredx/prole.git
synced 2026-09-27 07:14:29 +00:00
- Add centralized config resolver/activator with per-environment layering and stable symlink entrypoint\n- Bootstrap missing env dirs and preserve non-symlink legacy prole.cfg by seeding into inferred env\n- Wire installer UI/backend + shell helpers to shared resolution path for explicit, safe env switching\n- Harden k3d: registry network/DNS wiring and ArgoCD repo-server hostPath permission init\n- Add docs + regression tests for env switching, namespace stability, k3d registry, and ArgoCD rollout Co-authored-by: Junie <junie@jetbrains.com>
79 lines
2.3 KiB
Bash
79 lines
2.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Regression test: sourcing etc/prole_cfg.sh should bootstrap env-dir layout
|
|
# and migrate a legacy regular-file prole.cfg entrypoint into the right env.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
PROLE_REPO_ROOT=$(cd "$SCRIPT_DIR/../.." && pwd)
|
|
|
|
TMP_DIR=$(mktemp -d)
|
|
trap 'rm -rf "$TMP_DIR"' EXIT
|
|
|
|
TEST_HOME="$TMP_DIR/prole-home"
|
|
mkdir -p "$TEST_HOME/conf"
|
|
|
|
cat >"$TEST_HOME/env.sh" <<EOF
|
|
export PROLE_HOME="$TEST_HOME"
|
|
export PROLE_CONF="$TEST_HOME/conf"
|
|
export PROLE_SERVICE="$TEST_HOME/etc"
|
|
export PROLE_DATA="$TEST_HOME/data"
|
|
export PROLE_LOGS="$TEST_HOME/logs"
|
|
EOF
|
|
|
|
# Legacy single-file entrypoint config
|
|
cat >"$TEST_HOME/conf/prole.cfg" <<'EOF'
|
|
[Global]
|
|
DEPLOYMENT_MODE = k3d
|
|
CLUSTER_ENV = k3d-knoe-dev-cluster
|
|
NAMESPACE = prole-db-legacy
|
|
SERVICE_NAMESPACE = default
|
|
EOF
|
|
|
|
export PROLE_HOME="$TEST_HOME"
|
|
export PROLE_CONF="$TEST_HOME/conf"
|
|
|
|
# Source the shared loader (this should bootstrap the env-dir layout)
|
|
# shellcheck disable=SC1090
|
|
source "$PROLE_REPO_ROOT/etc/prole_cfg.sh"
|
|
|
|
if [[ ! -L "$PROLE_CONF/prole.cfg" ]]; then
|
|
echo "FAILURE: expected $PROLE_CONF/prole.cfg to be a symlink after bootstrap" >&2
|
|
ls -la "$PROLE_CONF" >&2 || true
|
|
exit 1
|
|
fi
|
|
|
|
resolved=$(python3 -c 'import os,sys; print(os.path.realpath(sys.argv[1]))' "$PROLE_CONF/prole.cfg")
|
|
expected=$(python3 -c 'import os,sys; print(os.path.realpath(sys.argv[1]))' "$PROLE_CONF/dev/prole.cfg")
|
|
if [[ "$resolved" != "$expected" ]]; then
|
|
echo "FAILURE: expected entrypoint to resolve to $expected, got $resolved" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -f "$PROLE_CONF/dev/prole.cfg" ]]; then
|
|
echo "FAILURE: expected $PROLE_CONF/dev/prole.cfg to exist" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! grep -q "NAMESPACE = prole-db-legacy" "$PROLE_CONF/dev/prole.cfg"; then
|
|
echo "FAILURE: expected migrated dev base to contain legacy content" >&2
|
|
echo "--- dev/prole.cfg ---" >&2
|
|
cat "$PROLE_CONF/dev/prole.cfg" >&2 || true
|
|
exit 1
|
|
fi
|
|
|
|
if ! ls "$PROLE_CONF"/prole.cfg.legacy.* >/dev/null 2>&1; then
|
|
echo "FAILURE: expected legacy backup prole.cfg.legacy.* to be created" >&2
|
|
ls -la "$PROLE_CONF" >&2 || true
|
|
exit 1
|
|
fi
|
|
|
|
for env in dev service prod test; do
|
|
if [[ ! -d "$PROLE_CONF/$env" ]]; then
|
|
echo "FAILURE: expected env dir to exist: $PROLE_CONF/$env" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
echo "SUCCESS"
|