test(clickhouse): describe the round-trip's guards by the archive-recording restore

Restores now take the archive the Backup recorded rather than the
newest one, and a leftover Backup of the BackupJob's name that records
another archive fails the new BackupJob instead of being adopted. The
comments justifying the sentinel row and the Backup cleanup, in the
round-trip and in its unit test, still gave the earlier reasons, which
would send the next reader after behaviour the driver no longer has.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
This commit is contained in:
Alexey Artamonov committed 2026-11-06 17:56:59 +03:00
1 parent c76080cc07
commit 6280d06d01
3 files changed
+7 -6

No files matched your search

@@ -92,9 +92,9 @@ restore() {
jq -e '.data.Corefile == ".:53 {\n errors\n}\n"' "$STUB/replaced.json" >/dev/null
}
# The Altinity driver names the Backup after the BackupJob and adopts one that
# already exists under that name, so a Backup left behind would stand in for
# the next run's backup. It is reclaimed by name, whether or not the BackupJob
# The Altinity driver names the Backup after the BackupJob, and a Backup left
# behind under that name records an earlier run's archive, which fails the next
# run's BackupJob. It is reclaimed by name, whether or not the BackupJob
# recorded it in status.backupRef.
@test "the round-trip reclaims its Backup by name before and after the run" {
suite=hack/e2e-chainsaw/clickhouse/chainsaw-test.yaml
@@ -452,7 +452,8 @@ spec:
fi
# Fixed names in a persistent namespace: a leftover Succeeded job
# would satisfy the waits in the run step without a new attempt, and
# the driver adopts a leftover Backup of the BackupJob's name.
# a leftover Backup of the BackupJob's name, recording an earlier
# run's archive, fails the new BackupJob.
kubectl -n "$NAMESPACE" delete restorejob sysbucket-restore --ignore-not-found --wait=true --timeout=30s
kubectl -n "$NAMESPACE" delete backupjob sysbucket-backup --ignore-not-found --wait=true --timeout=30s
kubectl -n "$NAMESPACE" delete backup sysbucket-backup --ignore-not-found --wait=true --timeout=60s
@@ -120,8 +120,8 @@ 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; }
# 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.
# Restore takes the archive this run's Backup recorded; a row no earlier run
# wrote is what shows the data restored is that archive'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"