44 lines
1.1 KiB
Bash
44 lines
1.1 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||
|
|
|
||
|
|
fail() {
|
||
|
|
echo "changes_consumer_410.sh: FAIL: $1" >&2
|
||
|
|
exit 1
|
||
|
|
}
|
||
|
|
|
||
|
|
tmp_dir="$(mktemp -d /tmp/changes-consumer-410.XXXXXX)"
|
||
|
|
cleanup() {
|
||
|
|
rm -rf "${tmp_dir}"
|
||
|
|
}
|
||
|
|
trap cleanup EXIT
|
||
|
|
|
||
|
|
cursor_file="${tmp_dir}/cursor"
|
||
|
|
printf '%s' "g1_expired_cursor" > "${cursor_file}"
|
||
|
|
|
||
|
|
mkdir -p "${tmp_dir}/bin"
|
||
|
|
cat > "${tmp_dir}/bin/curl" <<'MOCK'
|
||
|
|
#!/usr/bin/env bash
|
||
|
|
set -euo pipefail
|
||
|
|
printf '%s\n%s' '{"error":"cursor expired"}' '410'
|
||
|
|
MOCK
|
||
|
|
chmod +x "${tmp_dir}/bin/curl"
|
||
|
|
|
||
|
|
out_file="${tmp_dir}/out.log"
|
||
|
|
err_file="${tmp_dir}/err.log"
|
||
|
|
|
||
|
|
PATH="${tmp_dir}/bin:${PATH}" \
|
||
|
|
CURSOR_FILE="${cursor_file}" \
|
||
|
|
SYNC_LIMIT=10 \
|
||
|
|
SYNC_WAIT_MS=1 \
|
||
|
|
SOCK="${tmp_dir}/fake.sock" \
|
||
|
|
BASE="http://localhost" \
|
||
|
|
SPACE="app1" \
|
||
|
|
"${ROOT_DIR}/scripts/changes_consumer.sh" --once >"${out_file}" 2>"${err_file}" || fail "consumer returned non-zero for forced 410 path"
|
||
|
|
|
||
|
|
[[ ! -f "${cursor_file}" ]] || fail "cursor file should be cleared on 410"
|
||
|
|
grep -q "cursor expired" "${err_file}" || fail "expected expired cursor message in stderr"
|
||
|
|
|
||
|
|
echo "changes_consumer_410.sh: PASS"
|