mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
test(backups): cover a ClickHouse restore against an unreachable sidecar
The restore path resolves its archive from list/remote before the start gate runs, so it carries its own wait for a sidecar that is not up, and only the backup path had a test for a sidecar that never answers. The retry comment also miscounted: the limit is attempts, not retries. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
This commit is contained in:
1 parent
993b79bb37
commit
ae1e1830ce
2 files changed
+17
-6
No files matched your search
@@ -205,6 +205,17 @@ run_script() {
|
||||
if grep -q '^POST ' "$tmp/state/requests"; then echo "FAIL: no operation may start on an unreachable sidecar"; false; fi
|
||||
}
|
||||
|
||||
@test "restore fails without starting restore_remote when the sidecar never answers" {
|
||||
tmp=$(mktemp -d)
|
||||
make_stubs "$tmp/bin" "$tmp/state"
|
||||
touch "$tmp/state/unreachable"
|
||||
render_script "$tmp/s.sh" restore myapp
|
||||
if run_script "$tmp" 2> "$tmp/err"; then echo "FAIL: an unreachable sidecar must fail the Pod"; false; fi
|
||||
if grep -q '^POST ' "$tmp/state/requests"; then echo "FAIL: no restore may start on an unreachable sidecar"; false; fi
|
||||
grep -q 'list/remote failed 60 times in a row' "$tmp/err"
|
||||
[ "$(grep -c '^GET .*/backup/list/remote$' "$tmp/state/requests")" = 60 ]
|
||||
}
|
||||
|
||||
@test "restore fails without starting restore_remote when the sidecar stays busy" {
|
||||
tmp=$(mktemp -d)
|
||||
make_stubs "$tmp/bin" "$tmp/state"
|
||||
|
||||
@@ -52,9 +52,9 @@ spec:
|
||||
api="http://${host}:7171"
|
||||
auth="-u ${API_USERNAME}:${API_PASSWORD}"
|
||||
# Every request but the POST is retried on failure, every 5s,
|
||||
# up to $2 times: once the operation is accepted, a dropped poll
|
||||
# must not fail the attempt, since the Job retry it causes cannot
|
||||
# tell a lost poll from a lost operation.
|
||||
# for $2 attempts in all: once the operation is accepted, a
|
||||
# dropped poll must not fail the attempt, since the Job retry it
|
||||
# causes cannot tell a lost poll from a lost operation.
|
||||
api_get() {
|
||||
n=0
|
||||
while true; do
|
||||
@@ -72,9 +72,9 @@ spec:
|
||||
}
|
||||
# The sidecar answers 423 to a new operation while any other is
|
||||
# in progress, so starting before it is idle burns the attempt.
|
||||
# The exception is the operation $1 itself already running: an
|
||||
# earlier attempt of this Job started it and died, and the retry
|
||||
# takes it over rather than starting it twice.
|
||||
# The exception is the operation $1 itself already running, as
|
||||
# left by an earlier attempt of this Job that died: it is taken
|
||||
# over rather than started twice.
|
||||
wait_turn() {
|
||||
for _ in $(seq 1 60); do
|
||||
if actions=$(curl -fsS ${auth} --max-time 10 "${api}/backup/actions"); then
|
||||
|
||||
Reference in new issue
Block a user