From 603114cd7c9954006e6b6cc92ea613cc7af1aab8 Mon Sep 17 00:00:00 2001 From: Alexey Artamonov Date: Thu, 5 Nov 2026 21:09:15 +0300 Subject: [PATCH] test(clickhouse): check the round-trip restored this run's sentinel row Every run inserted the same sentinel row and accepted any row after the restore, while the Altinity restore takes the newest remote archive of the release. A restore of an older run's archive therefore passed. The row now carries a per-run value and exactly that row has to come back. Assisted-by: LLM Signed-off-by: Alexey Artamonov --- .../clickhouse/system-bucket-roundtrip.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hack/e2e-chainsaw/clickhouse/system-bucket-roundtrip.sh b/hack/e2e-chainsaw/clickhouse/system-bucket-roundtrip.sh index dc94a9c85..73d2f0e63 100755 --- a/hack/e2e-chainsaw/clickhouse/system-bucket-roundtrip.sh +++ b/hack/e2e-chainsaw/clickhouse/system-bucket-roundtrip.sh @@ -120,9 +120,12 @@ sidecar_before=$(sidecar_identity) [[ "$sidecar_before" =~ ^[0-9a-f-]+\ [0-9]+$ ]] \ || { log_error "could not read the ClickHouse Pod uid and clickhouse-backup restart count (got '${sidecar_before}')"; exit 1; } -log_step "Writing the sentinel row" +# Restore picks the newest remote backup of the release, so only a row no +# earlier run wrote shows that the archive restored is this run's. +sentinel="before-backup-$(date -u +%Y%m%dT%H%M%SZ)-${RANDOM}" +log_step "Writing the sentinel row ${sentinel}" clickhouse_query "$CLICKHOUSE_NAME" "CREATE TABLE IF NOT EXISTS default.sentinel (id UInt32, name String) ENGINE = MergeTree ORDER BY id" -clickhouse_query "$CLICKHOUSE_NAME" "INSERT INTO default.sentinel VALUES (1, 'before-backup')" +clickhouse_query "$CLICKHOUSE_NAME" "INSERT INTO default.sentinel VALUES (1, '${sentinel}')" log_step "Backing up through cozy-default" kubectl apply -f - <= 1 )) || { log_error "sentinel row count after restore is ${count}; expected >= 1"; exit 1; } +count=$(clickhouse_query "$CLICKHOUSE_NAME" "SELECT count() FROM default.sentinel WHERE name = '${sentinel}'" | tr -d '[:space:]') +[ "$count" = 1 ] || { log_error "after restore default.sentinel holds ${count} row(s) named ${sentinel}; expected 1"; exit 1; } sidecar_after=$(sidecar_identity) [ "$sidecar_after" = "$sidecar_before" ] \ || { log_error "the ClickHouse Pod or its clickhouse-backup container restarted during the round-trip (uid restarts: '${sidecar_before}' then '${sidecar_after}')"; exit 1; } -log_success "System-bucket round-trip verified: ${count} sentinel row(s) restored" +log_success "System-bucket round-trip verified: sentinel row ${sentinel} restored"