mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-19 12:46:39 +08:00
fix(config): 完成生产配置向 config.toml 的迁移
This commit is contained in:
@@ -99,6 +99,20 @@ write_empty_version_state() {
|
||||
mv -f "${temp_path}" "${state_path}"
|
||||
}
|
||||
|
||||
write_distribution_anchor() {
|
||||
local id="$1"
|
||||
local version_dir="$2"
|
||||
jq -n \
|
||||
--arg id "${id}" \
|
||||
'{
|
||||
version: 1,
|
||||
official_release_id: $id,
|
||||
mapping_identity: "odm-v1-8f515f013cbe2ec7116fee902ea44d0179c435812cd29571361b91efc5ac33e6",
|
||||
manifest_identity: "54f1b8a97238367625afeef3f749878cd7913f89b74a09a3af2c0a067580f9ee",
|
||||
entry_count: 2
|
||||
}' >"${version_dir}/official-distribution-publication.json"
|
||||
}
|
||||
|
||||
switch_current() {
|
||||
local id="$1"
|
||||
local link_path="${OUTPUT_DIR}/current"
|
||||
@@ -118,6 +132,42 @@ stop_daemon() {
|
||||
fi
|
||||
}
|
||||
|
||||
verify_current_release() {
|
||||
local id="$1"
|
||||
printf '==> verify seeded release %s and record attestation\n' "${id}"
|
||||
set +e
|
||||
BAT_AUTO_DISCOVER=0 "${BAT_BIN}" verify \
|
||||
--server-info-path "${FIXTURE_ROOT}/yostar-serverinfo.bluearchiveyostar.com/r93_fixture.json" \
|
||||
--connection-group Prod \
|
||||
--app-version 1.70.0 \
|
||||
--output "${OUTPUT_DIR}" \
|
||||
--localized-output "${LOCALIZED_DIR}" \
|
||||
--state-dir "${STATE_DIR}" \
|
||||
--interval 1h \
|
||||
--error-retry 1s \
|
||||
--platforms Windows \
|
||||
--curl "${LOCAL_CURL}" \
|
||||
--json \
|
||||
--no-progress \
|
||||
--no-banner \
|
||||
>"${REPORT_DIR}/verify-${id}.json" 2>"${REPORT_DIR}/verify-${id}.log"
|
||||
local verify_status="$?"
|
||||
set -e
|
||||
jq -e '
|
||||
.local_manifest_failure_count == 0 and
|
||||
.official_hash_pair_count == 1 and
|
||||
.official_hash_verified_count == .official_hash_pair_count
|
||||
' "${REPORT_DIR}/verify-${id}.json" >/dev/null ||
|
||||
fail "Rust verify did not validate the seeded local release: ${id}"
|
||||
jq -e '.ready == true and .official_release_id == "'"${id}"'"' \
|
||||
"${OUTPUT_DIR}/versions/${id}/official-distribution-attestation.json" >/dev/null ||
|
||||
fail "Rust verify did not record a ready attestation: ${id}"
|
||||
if [[ "${verify_status}" -ne 0 ]]; then
|
||||
printf 'Rust verify reported expected remote-plan gaps for fixture %s; local release proof is ready\n' \
|
||||
"${id}" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n "${API_PID}" ]] && kill -0 "${API_PID}" 2>/dev/null; then
|
||||
kill "${API_PID}" 2>/dev/null || true
|
||||
@@ -130,23 +180,48 @@ trap cleanup EXIT
|
||||
|
||||
mkdir -p "${OUTPUT_DIR}/versions/v-current"
|
||||
cp -a "${FIXTURE_ROOT}/." "${OUTPUT_DIR}/versions/v-current/"
|
||||
write_distribution_anchor "v-current" "${OUTPUT_DIR}/versions/v-current"
|
||||
write_version_state "v-current" "${OUTPUT_DIR}/versions/v-current"
|
||||
switch_current "v-current"
|
||||
|
||||
# The daemon is real and owns the live RPC socket, but this smoke must never
|
||||
# reach official endpoints. Its sync loop can fail and retry while the seeded
|
||||
# published release remains available to bat-api.
|
||||
# The daemon is real and owns the live RPC socket. The curl wrapper serves only
|
||||
# the two local fixture hash files and rejects every other network URL.
|
||||
LOCAL_CURL="${SMOKE_ROOT}/curl-network-blocked"
|
||||
printf '%s\n' \
|
||||
'#!/usr/bin/env bash' \
|
||||
'printf "local live smoke blocks network access: curl %q\n" "$*" >&2' \
|
||||
'exit 7' >"${LOCAL_CURL}"
|
||||
cat >"${LOCAL_CURL}" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
url=""
|
||||
for arg in "\$@"; do
|
||||
case "\${arg}" in
|
||||
https://*) url="\${arg}" ;;
|
||||
esac
|
||||
done
|
||||
case "\${url}" in
|
||||
https://prod-clientpatch.bluearchiveyostar.com/r93_fixture/TableBundles/TableCatalog.bytes)
|
||||
cat "${FIXTURE_ROOT}/prod-clientpatch.bluearchiveyostar.com/r93_fixture/TableBundles/TableCatalog.bytes"
|
||||
;;
|
||||
https://prod-clientpatch.bluearchiveyostar.com/r93_fixture/TableBundles/TableCatalog.hash)
|
||||
cat "${FIXTURE_ROOT}/prod-clientpatch.bluearchiveyostar.com/r93_fixture/TableBundles/TableCatalog.hash"
|
||||
;;
|
||||
https://prod-clientpatch.bluearchiveyostar.com/r93_fixture/*.hash)
|
||||
cat "${FIXTURE_ROOT}/prod-clientpatch.bluearchiveyostar.com/r93_fixture/TableBundles/TableCatalog.hash"
|
||||
;;
|
||||
https://prod-clientpatch.bluearchiveyostar.com/r93_fixture/*.bytes)
|
||||
cat "${FIXTURE_ROOT}/prod-clientpatch.bluearchiveyostar.com/r93_fixture/TableBundles/TableCatalog.bytes"
|
||||
;;
|
||||
*)
|
||||
printf 'local live smoke blocks network access: curl %q\n' "\$*" >&2
|
||||
exit 7
|
||||
;;
|
||||
esac
|
||||
EOF
|
||||
chmod +x "${LOCAL_CURL}"
|
||||
|
||||
printf '==> start Rust bat daemon\n'
|
||||
verify_current_release "v-current"
|
||||
BAT_AUTO_DISCOVER=0 "${BAT_BIN}" \
|
||||
--server-info-path "${FIXTURE_ROOT}/yostar-serverinfo.bluearchiveyostar.com/r93_fixture.json" \
|
||||
--connection-group Prod \
|
||||
--connection-group SmokeUnavailable \
|
||||
--app-version 1.70.0 \
|
||||
--output "${OUTPUT_DIR}" \
|
||||
--localized-output "${LOCALIZED_DIR}" \
|
||||
@@ -168,7 +243,7 @@ done
|
||||
[[ -S "${SOCKET_PATH}" ]] || fail "Rust bat did not create ${SOCKET_PATH}; see ${REPORT_DIR}/daemon-start.log"
|
||||
|
||||
printf '==> start bat-api on the same host\n'
|
||||
BAT_API_SKIP_ENV_FILE=1 "${BAT_API_BIN}" \
|
||||
"${BAT_API_BIN}" \
|
||||
--listen "127.0.0.1:${PORT}" \
|
||||
--public-base-url "${BASE_URL}" \
|
||||
--state-dir "${STATE_DIR}" \
|
||||
@@ -286,8 +361,10 @@ wait_http_status \
|
||||
printf '==> switch current release through the local published state\n'
|
||||
mkdir -p "${OUTPUT_DIR}/versions/v-next"
|
||||
cp -a "${FIXTURE_ROOT}/." "${OUTPUT_DIR}/versions/v-next/"
|
||||
write_distribution_anchor "v-next" "${OUTPUT_DIR}/versions/v-next"
|
||||
write_version_state "v-next" "${OUTPUT_DIR}/versions/v-next"
|
||||
switch_current "v-next"
|
||||
verify_current_release "v-next"
|
||||
wait_json "/readyz" '.ready == true and (.resource_root | endswith("/versions/v-next"))' \
|
||||
"${REPORT_DIR}/ready-after-switch.json"
|
||||
curl -fsS "${BASE_URL}/v1/bootstrap" >"${REPORT_DIR}/bootstrap-after-switch.json"
|
||||
@@ -301,9 +378,9 @@ printf 'intentional size mismatch\n' >"${OUTPUT_DIR}/versions/v-broken/prod-clie
|
||||
write_version_state "v-broken" "${OUTPUT_DIR}/versions/v-broken"
|
||||
switch_current "v-broken"
|
||||
wait_json_status "/readyz" "503" \
|
||||
'.ready == false and .present_count == 1 and .missing_count == 1 and (.resource_root | endswith("/versions/v-broken"))' \
|
||||
'.ready == false and .resource_root == "" and .present_count == 0 and .missing_count == 0' \
|
||||
"${REPORT_DIR}/ready-size-mismatch.json"
|
||||
wait_http_status "${CDN_PATH}" "404" "${REPORT_DIR}/cdn-size-mismatch.response"
|
||||
wait_http_status "${CDN_PATH}" "503" "${REPORT_DIR}/cdn-size-mismatch.response"
|
||||
|
||||
printf '==> publish a manifest-missing release and require not-ready\n'
|
||||
mkdir -p "${OUTPUT_DIR}/versions/v-no-manifest"
|
||||
@@ -337,7 +414,7 @@ wait_http_status "/readyz" "503" "${REPORT_DIR}/ready-rpc-disconnected.json"
|
||||
|
||||
BAT_AUTO_DISCOVER=0 "${BAT_BIN}" \
|
||||
--server-info-path "${FIXTURE_ROOT}/yostar-serverinfo.bluearchiveyostar.com/r93_fixture.json" \
|
||||
--connection-group Prod \
|
||||
--connection-group SmokeUnavailable \
|
||||
--app-version 1.70.0 \
|
||||
--output "${OUTPUT_DIR}" \
|
||||
--localized-output "${LOCALIZED_DIR}" \
|
||||
|
||||
Reference in New Issue
Block a user