mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 19:34:31 +00:00
Itemized changes:
1. knoe-auth: New cluster-internal KDC and SSO gateway service
- Created etc/init_knoe_auth.sh based on init_kdc.sh with knoe-auth naming
- Namespace defaults to SERVICE_NAMESPACE (knoe-system)
- ConfigMap: knoe-auth-kdc-config, Secret: knoe-auth-secrets
- Legacy cleanup removes old auth/dog/authority deployments
2. Orchestration: knoe-auth initializes before CloudNativePG
- Updated prole.sh to insert init_knoe_auth.sh as step 2 (before CNPG)
- Renumbered all subsequent initialization steps
3. Kong routing: Updated init_kong.sh to route to knoe-auth in SERVICE_NAMESPACE
4. Comment/reference updates for knoe-auth
- Updated init_common_services.sh, init_service_layer.sh, init_kerberos.sh
5. prole-db renamed to knoe-db across the entire codebase
- Renamed prole-db/ directory to knoe-db/
- Renamed all prole-db Kubernetes manifests (deploy/opentofu, k8s/)
- Renamed scripts: docker-root-knoe-db.sh, docker-run-knoe-db.sh, test-cnpg-knoe-db.sh
- Renamed etc/init_prole-db-reset.sh to etc/init_knoe-db-reset.sh
- Renamed etc/prole-db-passwwd.sh to etc/knoe-db-passwwd.sh
- Renamed mock_val counterparts accordingly
- Renamed tests/etc/test_init_prole-db-reset.sh to test_init_knoe-db-reset.sh
- Renamed docs/prole-db-documentation-mcp-architecture.md to knoe-db variant
- Renamed modes/k3d/prole-db/ to modes/k3d/knoe-db/
- Renamed prole-db.iml to knoe-db.iml
6. Configuration updates
- Updated conf/dev, conf/prod, conf/test, conf/service prole.cfg files
- Updated conf/port-mapping.cfg
- Updated etc/prole_cfg.sh and mock_val/prole_cfg.sh
- Updated service/prole.cfg
7. Kubernetes manifests and deploy configuration
- Updated deploy/opentofu/k3s ArgoCD application YAMLs
- Updated kong-configmap.yaml and kustomization.yaml
- Updated k3s/kong-config.yml and prole-resources.yaml
- Updated prole-mssql-db deployment YAMLs
- Updated supabase helm render and deploy scripts
8. Infrastructure and GCP Terraform
- Updated deploy/gcp/terraform: folders, groups, IAM, service-projects
9. Python/installer code updates
- Updated knoe/core: actions, build_context, controller, env, milestones
- Updated knoe/milestone.py
- Updated knoe/ui/screens: cfg, database, database_options, deploy, docker,
navigation, security, services, validate
- Updated knoe.spec, status.py
10. Shell script updates
- Updated etc/: build_db, init_cloudnative_pg, init_cnpg_backup,
init_db_manager, init_forgejo, init_gitlab, init_monitoring, init_openbao,
init_port_forwards, init_postgrest, init_supabase_ports, status
- Updated mock_val/ counterparts for all above scripts
- Updated prole-net/init-prole-dns.sh
- Updated bin/prole-kpf.sh, gitea/deploy.sh, supabase/deploy.sh
11. Test updates
- Updated tests/etc/: test_init_cloudnative_pg*, test_init_cnpg_backup*,
test_init_kdc*, test_init_kerberos*, test_init_kong*, test_prole_cfg*
- Updated tests/installer/: test_actions_helpers, test_cfg_save_kubecontext,
test_controller, test_core_classes, test_milestones, test_milestones_extended,
test_namespace_propagation
- Updated tests/: test_database_options, test_navigation,
test_render_supabase_hostname, test_docker_build_fix,
test_all_prole_home_fixes, silent_install_test, final_test
12. Documentation updates
- Updated docs/: DOCKER-BUILD-FIX, PROLE-CFG-SECRETS, PROLE-HOME-DIRECTORY,
build-system, patent
- Updated scan/network_description.txt
- Updated pom.xml
13. Miscellaneous script updates
- Updated root-level: _adopt_replica_pvcs, _fix_replica_merlin, _import_pi,
_patch_cluster, _prebind_pvcs, _rebind_d002, _rebind_d002b, test_resolve
- Updated scripts/generate_spec.py
Co-authored-by: Junie <junie@jetbrains.com>
207 lines
6.1 KiB
Bash
207 lines
6.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Unit test for etc/init_cnpg_backup.sh
|
|
# Verifies we wait for CNPG webhook endpoints before applying a Backup.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
PROLE_HOME_REPO=$(cd "$SCRIPT_DIR/../.." && pwd)
|
|
ETC_DIR="$PROLE_HOME_REPO/etc"
|
|
SCRIPT_UNDER_TEST="$ETC_DIR/init_cnpg_backup.sh"
|
|
|
|
TMP_DIR=$(mktemp -d)
|
|
trap 'rm -rf "$TMP_DIR"' EXIT
|
|
|
|
BIN_DIR="$TMP_DIR/bin"
|
|
mkdir -p "$BIN_DIR"
|
|
|
|
cat <<'K_EOF' > "$BIN_DIR/kubectl"
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
_log_file="${TMP_DIR}/mock_calls.log"
|
|
echo "Mocked kubectl called with $*" >> "${_log_file}"
|
|
|
|
args="$*"
|
|
|
|
# API server readiness probes
|
|
if [[ "${args}" == *"get --raw=/readyz"* || "${args}" == *"get --raw='/readyz'"* || "${args}" == *"get --raw=\"/readyz\""* ]]; then
|
|
echo "ok"
|
|
exit 0
|
|
fi
|
|
if [[ "${args}" == *"version --short"* ]]; then
|
|
echo "Client Version: v0.0.0"
|
|
echo "Server Version: v0.0.0"
|
|
exit 0
|
|
fi
|
|
|
|
# Namespace existence/creation
|
|
if [[ "${args}" == "get namespace test-ns" ]]; then
|
|
exit 0
|
|
fi
|
|
if [[ "${args}" == "create namespace test-ns" ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
# Cluster existence
|
|
if [[ "${args}" == "get cluster knoe-db -n test-ns" || "${args}" == "get cluster knoe-db -n test-ns"* ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
# Plugin config present (so the script doesn't try to patch the cluster in this unit test)
|
|
if [[ "${args}" == *"-n test-ns"*"get cluster knoe-db"*"-o jsonpath="*".spec.plugins[*].name"* ]]; then
|
|
echo "barman-cloud.cloudnative-pg.io"
|
|
exit 0
|
|
fi
|
|
if [[ "${args}" == *"-n test-ns"*"get cluster knoe-db"*"-o jsonpath="*".spec.plugins"* ]]; then
|
|
echo '[{"enabled":true,"isWALArchiver":true,"name":"barman-cloud.cloudnative-pg.io","parameters":{"barmanObjectName":"knoe-db-barman-objectstore"}}]'
|
|
exit 0
|
|
fi
|
|
|
|
# Barman-cloud deployment ready (required by wait_for_plugin_ready)
|
|
if [[ "${args}" == "get deployment -A -l app.kubernetes.io/name=barman-cloud -o jsonpath="* ]]; then
|
|
printf 'cnpg-system\t1\t1\n'
|
|
exit 0
|
|
fi
|
|
|
|
# Barman plugin service registration (used by wait_for_barman_plugin_infra_ready)
|
|
if [[ "${args}" == *"-n cnpg-system"*"get svc"*"-l cnpg.io/pluginName=barman-cloud.cloudnative-pg.io"*"-o jsonpath="*"metadata.name"* ]]; then
|
|
echo "barman-cloud"
|
|
exit 0
|
|
fi
|
|
if [[ "${args}" == *"-n cnpg-system"*"get svc barman-cloud"*"-o jsonpath="*"metadata.name"* ]]; then
|
|
echo "barman-cloud"
|
|
exit 0
|
|
fi
|
|
if [[ "${args}" == *"-n cnpg-system"*"get svc barman-cloud"*"pluginClientSecret"* ]]; then
|
|
echo "barman-cloud-client-tls"
|
|
exit 0
|
|
fi
|
|
if [[ "${args}" == *"-n cnpg-system"*"get svc barman-cloud"*"pluginServerSecret"* ]]; then
|
|
echo "barman-cloud-server-tls"
|
|
exit 0
|
|
fi
|
|
if [[ "${args}" == *"-n cnpg-system"*"get svc barman-cloud"*"pluginPort"* ]]; then
|
|
echo "9090"
|
|
exit 0
|
|
fi
|
|
if [[ "${args}" == *"-n cnpg-system"*"get endpoints barman-cloud"* ]]; then
|
|
echo "10.42.0.11"
|
|
exit 0
|
|
fi
|
|
|
|
# CNPG cluster pod selection for socket check
|
|
if [[ "${args}" == *"-n test-ns"*"get pods"*"-l cnpg.io/cluster=knoe-db,cnpg.io/instanceRole=primary"*"-o jsonpath={.items[0].metadata.name"* ]]; then
|
|
echo "knoe-db-1"
|
|
exit 0
|
|
fi
|
|
if [[ "${args}" == *"-n test-ns"*"get pods"*"-l cnpg.io/cluster=knoe-db"*"-o jsonpath={.items[0].metadata.name"* ]]; then
|
|
echo "knoe-db-1"
|
|
exit 0
|
|
fi
|
|
|
|
# Plugin socket check succeeds immediately
|
|
if [[ "${args}" == *"-n test-ns"*"exec knoe-db-1 -c postgres -- test -S /plugins/barman-cloud.cloudnative-pg.io"* ]]; then
|
|
exit 0
|
|
fi
|
|
if [[ "${args}" == *"-n test-ns"*"exec knoe-db-1 -c manager -- test -S /plugins/barman-cloud.cloudnative-pg.io"* ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
# CNPG webhook endpoints: return empty twice, then return an IP.
|
|
if [[ "${args}" == *"-n cnpg-system"*"get endpoints"*"cnpg-webhook-service"* ]]; then
|
|
cfile="${TMP_DIR}/endpoints_calls"
|
|
c=0
|
|
[[ -f "$cfile" ]] && c=$(cat "$cfile")
|
|
c=$((c + 1))
|
|
echo "$c" > "$cfile"
|
|
if (( c >= 3 )); then
|
|
echo "10.42.0.10"
|
|
fi
|
|
exit 0
|
|
fi
|
|
|
|
# Capture applied Backup manifest
|
|
if [[ "${args}" == apply*"-n"*"test-ns"*"-f"*"-"* ]]; then
|
|
cat > "${TMP_DIR}/applied.yaml"
|
|
echo "applied"
|
|
exit 0
|
|
fi
|
|
|
|
# ObjectStore readiness checks
|
|
if [[ "${args}" == *"-n test-ns"*"get objectstore"*"knoe-db-barman-objectstore"*"-o jsonpath="*"conditions"*"Ready"* ]]; then
|
|
echo "True"
|
|
exit 0
|
|
fi
|
|
if [[ "${args}" == *"-n test-ns"*"get objectstore"*"knoe-db-barman-objectstore"*"-o jsonpath={.status.phase"* ]]; then
|
|
echo "Ready"
|
|
exit 0
|
|
fi
|
|
|
|
exit 0
|
|
K_EOF
|
|
chmod +x "$BIN_DIR/kubectl"
|
|
|
|
export PATH="$BIN_DIR:$PATH"
|
|
export TMP_DIR
|
|
|
|
# prole_cfg.sh sources $PROLE_HOME/env.sh if present; provide a minimal env.sh that points to our temp config.
|
|
CONF_DIR="$TMP_DIR/conf"
|
|
ENV_HOME="$TMP_DIR/env-home"
|
|
mkdir -p "$CONF_DIR" "$ENV_HOME"
|
|
|
|
cat <<C_EOF > "$CONF_DIR/prole.cfg"
|
|
[User]
|
|
NAMESPACE = test-ns
|
|
SERVICE_NAMESPACE = test-system
|
|
PROLE_HOME = $PROLE_HOME_REPO
|
|
PROLE_SERVICE = $TMP_DIR/service
|
|
|
|
[Global]
|
|
DEPLOYMENT_MODE = k3s
|
|
C_EOF
|
|
|
|
cat <<E_EOF > "$ENV_HOME/env.sh"
|
|
#!/usr/bin/env bash
|
|
export PROLE_HOME="$PROLE_HOME_REPO"
|
|
export PROLE_CONF="$CONF_DIR"
|
|
E_EOF
|
|
chmod +x "$ENV_HOME/env.sh"
|
|
|
|
set +e
|
|
PROLE_HOME="$ENV_HOME" bash "$SCRIPT_UNDER_TEST" backup full >"$TMP_DIR/stdout" 2>"$TMP_DIR/stderr"
|
|
RC=$?
|
|
set -e
|
|
|
|
if [[ $RC -ne 0 ]]; then
|
|
echo "FAILURE: init_cnpg_backup.sh returned rc=$RC"
|
|
sed -n '1,200p' "$TMP_DIR/mock_calls.log" || true
|
|
sed -n '1,200p' "$TMP_DIR/stderr" || true
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -f "$TMP_DIR/applied.yaml" ]]; then
|
|
echo "FAILURE: expected Backup manifest to be applied"
|
|
sed -n '1,200p' "$TMP_DIR/mock_calls.log" || true
|
|
sed -n '1,200p' "$TMP_DIR/stderr" || true
|
|
exit 1
|
|
fi
|
|
|
|
# Verify webhook endpoints were checked before apply.
|
|
endpoint_line=$(grep -n "get endpoints cnpg-webhook-service" "$TMP_DIR/mock_calls.log" | head -n1 | cut -d: -f1 || true)
|
|
apply_line=$(grep -n "apply -n test-ns -f -" "$TMP_DIR/mock_calls.log" | tail -n1 | cut -d: -f1 || true)
|
|
if [[ -z "$endpoint_line" || -z "$apply_line" || "$endpoint_line" -ge "$apply_line" ]]; then
|
|
echo "FAILURE: expected webhook endpoints check before applying Backup"
|
|
echo "endpoint_line=$endpoint_line apply_line=$apply_line"
|
|
sed -n '1,200p' "$TMP_DIR/mock_calls.log" || true
|
|
exit 1
|
|
fi
|
|
|
|
if ! grep -qE '^kind:\s*Backup\s*$' "$TMP_DIR/applied.yaml"; then
|
|
echo "FAILURE: expected applied manifest to be a Backup"
|
|
sed -n '1,120p' "$TMP_DIR/applied.yaml" || true
|
|
exit 1
|
|
fi
|
|
|
|
echo "SUCCESS"
|