Harden remote43 acceptance script
This commit is contained in:
@@ -16,6 +16,14 @@ assert_contains() {
|
||||
fi
|
||||
}
|
||||
|
||||
assert_not_contains() {
|
||||
local haystack="$1"
|
||||
local needle="$2"
|
||||
if [[ "$haystack" == *"$needle"* ]]; then
|
||||
fail "expected to avoid [$needle] in [$haystack]"
|
||||
fi
|
||||
}
|
||||
|
||||
run_test_build_subscription_access_prep_sql() {
|
||||
# shellcheck disable=SC1091
|
||||
source "$ROOT_DIR/scripts/host_access_prep_lib.sh"
|
||||
@@ -314,13 +322,13 @@ case "$url" in
|
||||
*/api/import-batches/123)
|
||||
write_body '{"managed_resources":[{"ResourceType":"group","HostResourceID":"7","ResourceName":"DeepSeek 默认分组"}]}'
|
||||
;;
|
||||
*/api/providers/deepseek/status)
|
||||
*/api/providers/deepseek/status*)
|
||||
write_body '{"status":"ready"}'
|
||||
;;
|
||||
*/api/providers/deepseek/access/status)
|
||||
*/api/providers/deepseek/access/status*)
|
||||
write_body '{"latest_access_status":"subscription_ready"}'
|
||||
;;
|
||||
*/api/providers/deepseek/access/preview)
|
||||
*/api/providers/deepseek/access/preview*)
|
||||
write_body '{"available":true}'
|
||||
;;
|
||||
*)
|
||||
@@ -342,6 +350,9 @@ if [[ "$cmd" == *'***'* ]]; then
|
||||
exit 1
|
||||
fi
|
||||
case "$cmd" in
|
||||
"sudo -n docker ps --format '{{.Names}}\t{{.Ports}}'"*)
|
||||
printf '%s\n' 'sub2api-fresh-deepseek-20260519_115244-app-1 127.0.0.1:18093->8080/tcp'
|
||||
;;
|
||||
*"/api/v1/auth/login"*)
|
||||
printf '%s\n' 'host-bearer-token'
|
||||
;;
|
||||
@@ -425,10 +436,10 @@ fi
|
||||
*"/api/providers/deepseek/reconcile"*)
|
||||
printf '%s\n' '{"status":"in_sync"}'
|
||||
;;
|
||||
*"sudo -n docker exec -i fresh-pg psql -U sub2api -d sub2api -At -F ''"*)
|
||||
*"sudo -n docker exec -i sub2api-fresh-deepseek-20260519_115244-postgres-1 psql -U sub2api -d sub2api -At -F ''"*)
|
||||
printf '%s\n' '{"group_id":7,"subscription":{"status":"active"},"key":{"group_id":7}}'
|
||||
;;
|
||||
*"sudo -n docker exec -i fresh-pg psql -U sub2api -d sub2api"*)
|
||||
*"sudo -n docker exec -i sub2api-fresh-deepseek-20260519_115244-postgres-1 psql -U sub2api -d sub2api"*)
|
||||
CMD="$cmd" LOG_DIR="$log_dir" python3 - <<'PY'
|
||||
import base64, os, re, pathlib, sys
|
||||
cmd = os.environ['CMD']
|
||||
@@ -454,7 +465,7 @@ else:
|
||||
print('')
|
||||
PY
|
||||
;;
|
||||
*"sudo -n docker exec fresh-redis redis-cli DEL apikey:auth:"*" billing:balance:"*" billing:sub:"*":7"*)
|
||||
*"sudo -n docker exec sub2api-fresh-deepseek-20260519_115244-redis-1 redis-cli DEL apikey:auth:"*" billing:balance:"*" billing:sub:"*":7"*)
|
||||
printf '%s\n' '3'
|
||||
;;
|
||||
*)
|
||||
@@ -472,11 +483,10 @@ EOF
|
||||
CRM_BASE="http://127.0.0.1:18088" \
|
||||
HOST_BASE="http://127.0.0.1:18087" \
|
||||
CRM_HOST_BASE="http://127.0.0.1:18093" \
|
||||
REMOTE_HOST_BASE="http://127.0.0.1:18093" \
|
||||
ROOT="$artifact_dir/root" \
|
||||
ART="$artifact_dir/run" \
|
||||
PACK_PATH="$pack_dir" \
|
||||
REMOTE_PG_CONTAINER="fresh-pg" \
|
||||
REMOTE_REDIS_CONTAINER="fresh-redis" \
|
||||
UPSTREAM_KEY="upstream-test-key" \
|
||||
SUBSCRIPTION_DAYS=30 \
|
||||
MIN_BALANCE=10 \
|
||||
@@ -493,6 +503,7 @@ EOF
|
||||
local runtime_context invalidation_log
|
||||
runtime_context="$(cat "$artifact_dir/run/01-runtime-context.json")"
|
||||
assert_contains "$runtime_context" '"crm_host_base": "http://127.0.0.1:18093"'
|
||||
assert_contains "$runtime_context" '"remote_host_base": "http://127.0.0.1:18093"'
|
||||
invalidation_log="$(cat "$artifact_dir/run/07-redis-targeted-invalidation.txt")"
|
||||
assert_contains "$invalidation_log" "auth_cache_key=apikey:auth:"
|
||||
assert_contains "$invalidation_log" "balance_cache_key=billing:balance:84"
|
||||
@@ -513,6 +524,13 @@ EOF
|
||||
assert_contains "$summary_json" '"upstream_models_has_expected_model": true'
|
||||
assert_contains "$summary_json" '"completion_classification": "unknown"'
|
||||
[[ -s "$ssh_log" ]] || fail "ssh log was empty"
|
||||
local ssh_contents
|
||||
ssh_contents="$(cat "$ssh_log")"
|
||||
assert_contains "$ssh_contents" "sudo -n docker ps --format"
|
||||
assert_contains "$ssh_contents" "http://127.0.0.1:18093/v1/models"
|
||||
assert_contains "$ssh_contents" "http://127.0.0.1:18093/v1/chat/completions"
|
||||
assert_not_contains "$ssh_contents" "http://127.0.0.1:18087/v1/models"
|
||||
assert_not_contains "$ssh_contents" "http://127.0.0.1:18087/v1/chat/completions"
|
||||
}
|
||||
|
||||
run_test_build_subscription_access_prep_sql
|
||||
|
||||
Reference in New Issue
Block a user