From 5d6b36d1903069be15441d54055c730df4cf3d0a Mon Sep 17 00:00:00 2001 From: Lemon-miaow Date: Sat, 26 Sep 2026 13:25:22 +0800 Subject: [PATCH] =?UTF-8?q?test(e2e):=20=E6=A3=80=E6=9F=A5=20k3s=20?= =?UTF-8?q?=E5=86=85=E7=9A=84=20felis-postgres=20=E5=B9=B6=E7=BB=8F=20kube?= =?UTF-8?q?ctl=20exec=20=E5=81=9A=E4=B8=80=E6=AC=A1=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/e2e.yml | 5 ++++- deploy/e2e_check.sh | 27 +++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 596afc0..1abc6c2 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -81,7 +81,8 @@ jobs: k -n "${p%%/*}" describe pod "${p#*/}" | tail -n 40 || true k -n "${p%%/*}" logs "${p#*/}" --all-containers --tail=60 || true done - sudo journalctl -u k3s -u felis-velocity -u postgresql --no-pager -n 120 || true + k -n felis logs deploy/felis-postgres --tail=60 || true + sudo journalctl -u k3s -u felis-velocity --no-pager -n 120 || true - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 if: always() @@ -144,6 +145,8 @@ jobs: run: | export KUBECONFIG=/etc/rancher/k3s/k3s.yaml sudo -E /usr/local/bin/k3s kubectl get pods -A -o wide || true + sudo -E /usr/local/bin/k3s kubectl -n felis logs deploy/felis-postgres --tail=60 || true + # The release ran the database on the host; the upgrade moves it into k3s. sudo journalctl -u k3s -u felis-velocity -u postgresql --no-pager -n 120 || true - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 diff --git a/deploy/e2e_check.sh b/deploy/e2e_check.sh index 16594e9..1235571 100644 --- a/deploy/e2e_check.sh +++ b/deploy/e2e_check.sh @@ -7,10 +7,11 @@ # sudo bash deploy/e2e_check.sh release # after the newest release installed # sudo bash deploy/e2e_check.sh upgrade # after this commit ran over a release # -# It asks what an operator's first minutes ask: the binary runs, the control plane is -# rolled out and ready, the panel answers on its NodePort, the proxy answers a Minecraft -# status ping, and the host timers are there. A rerun must also leave the proxy running -# (it restarts only when what it runs changed) and keep every earlier answer. +# It asks what an operator's first minutes ask: the binary runs, the control plane and its +# database are rolled out and ready, a database backup can be taken, the panel answers on +# its NodePort, the proxy answers a Minecraft status ping, and the host timers are there. +# A rerun must also leave the proxy running (it restarts only when what it runs changed) +# and keep every earlier answer. set -euo pipefail phase="${1:?usage: e2e_check.sh install|rerun|release|upgrade}" @@ -29,7 +30,7 @@ check() { # label command... check "felis version runs" sh -c '/usr/local/bin/felis version | grep -q "^felis "' -for d in felis-api felis-operator registry; do +for d in felis-postgres felis-api felis-operator registry; do check "deployment ${d} is rolled out" "${KUBECTL[@]}" -n felis rollout status "deploy/${d}" --timeout=180s done @@ -41,9 +42,23 @@ internal="$("${KUBECTL[@]}" -n felis get svc felis-api-internal -o jsonpath='{.s check "felis-api is ready (database and cluster reachable)" \ curl -sf --retry 10 --retry-delay 3 --retry-all-errors -o /dev/null "http://${internal}/readyz" -for unit in k3s postgresql felis-velocity; do +for unit in k3s felis-velocity; do check "${unit} is active" systemctl is-active --quiet "$unit" done +# The database runs in k3s; a release may still run it on the host, and the upgrade moved +# it. The host has no PostgreSQL client: a bundle that verifies proves felis reaches the +# database's pod through kubectl exec, and that pg_dump there reads every table. +if [ "$phase" != release ]; then + check "the host's own postgresql is stopped" sh -c '! systemctl is-active --quiet postgresql' + bundle_dir="$(mktemp -d)" + if out="$(/usr/local/bin/felis db backup -dir "$bundle_dir" -state-dir "" -no-servers 2>&1)"; then + bundle="$(printf '%s\n' "$out" | sed -n 's/^felis db backup: wrote //p' | tail -n 1)" + check "felis db backup writes a bundle that verifies" /usr/local/bin/felis db verify "$bundle" + else + fail "felis db backup writes a bundle: ${out}" + fi + rm -rf "$bundle_dir" +fi # A release may predate a timer; what this commit installs has them all. if [ "$phase" != release ]; then for timer in felis-db-backup.timer felis-watchdog.timer felis-update-check.timer; do