fix fresh-host acceptance and document real-host debugging learnings
This commit is contained in:
@@ -243,14 +243,17 @@ EOF
|
||||
}
|
||||
|
||||
run_test_import_remote43_provider_subscription_prep() {
|
||||
local tmpdir fakebin artifact_dir ssh_log psql_sql
|
||||
local tmpdir fakebin artifact_dir ssh_log psql_sql pack_dir
|
||||
tmpdir="$(mktemp -d)"
|
||||
trap 'rm -rf "$tmpdir"' RETURN
|
||||
fakebin="$tmpdir/bin"
|
||||
artifact_dir="$tmpdir/artifacts"
|
||||
ssh_log="$artifact_dir/ssh-log.txt"
|
||||
psql_sql="$artifact_dir/prep.sql"
|
||||
pack_dir="$tmpdir/pack"
|
||||
mkdir -p "$fakebin"
|
||||
mkdir -p "$pack_dir/providers"
|
||||
printf '%s\n' '{"provider_id":"deepseek","base_url":"https://upstream.example.com/v1"}' > "$pack_dir/providers/deepseek.json"
|
||||
|
||||
cat > "$fakebin/curl" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
@@ -338,7 +341,7 @@ if [[ "$cmd" == *'***'* ]]; then
|
||||
echo "unexpected redacted auth placeholder in ssh command: $cmd" >&2
|
||||
exit 1
|
||||
fi
|
||||
case "$cmd" in
|
||||
case "$cmd" in
|
||||
*"/api/v1/auth/login"*)
|
||||
printf '%s\n' 'host-bearer-token'
|
||||
;;
|
||||
@@ -390,6 +393,26 @@ case "$cmd" in
|
||||
"cat /tmp/chat_body.json")
|
||||
cat /tmp/chat_body.json
|
||||
;;
|
||||
*"curl -sS -D /tmp/upstream_models_headers.txt"*)
|
||||
printf '%s\n' 'HTTP/1.1 200 OK' > /tmp/upstream_models_headers.txt
|
||||
printf '%s\n' '{"data":[{"id":"openai/gpt-4"},{"id":"openai/gpt-4.1"}]}' > /tmp/upstream_models_body.json
|
||||
;;
|
||||
"cat /tmp/upstream_models_headers.txt")
|
||||
cat /tmp/upstream_models_headers.txt
|
||||
;;
|
||||
"cat /tmp/upstream_models_body.json")
|
||||
cat /tmp/upstream_models_body.json
|
||||
;;
|
||||
*"curl -sS -D /tmp/upstream_chat_headers.txt"*)
|
||||
printf '%s\n' 'HTTP/1.1 200 OK' > /tmp/upstream_chat_headers.txt
|
||||
printf '%s\n' '{"choices":[{"message":{"content":"upstream-pong"}}]}' > /tmp/upstream_chat_body.txt
|
||||
;;
|
||||
"cat /tmp/upstream_chat_headers.txt")
|
||||
cat /tmp/upstream_chat_headers.txt
|
||||
;;
|
||||
"cat /tmp/upstream_chat_body.txt")
|
||||
cat /tmp/upstream_chat_body.txt
|
||||
;;
|
||||
*"/api/providers/deepseek/status"*)
|
||||
printf '%s\n' '{"status":"ready"}'
|
||||
;;
|
||||
@@ -451,7 +474,7 @@ EOF
|
||||
CRM_HOST_BASE="http://127.0.0.1:18093" \
|
||||
ROOT="$artifact_dir/root" \
|
||||
ART="$artifact_dir/run" \
|
||||
PACK_PATH="/tmp/openai-pack" \
|
||||
PACK_PATH="$pack_dir" \
|
||||
REMOTE_PG_CONTAINER="fresh-pg" \
|
||||
REMOTE_REDIS_CONTAINER="fresh-redis" \
|
||||
UPSTREAM_KEY="upstream-test-key" \
|
||||
@@ -474,14 +497,21 @@ EOF
|
||||
assert_contains "$invalidation_log" "auth_cache_key=apikey:auth:"
|
||||
assert_contains "$invalidation_log" "balance_cache_key=billing:balance:84"
|
||||
assert_contains "$invalidation_log" "subscription_cache_key=billing:sub:84:7"
|
||||
local subscription_state models_body chat_body
|
||||
local subscription_state models_body chat_body upstream_models upstream_chat summary_json
|
||||
subscription_state="$(cat "$artifact_dir/run/08-subscription-group-state.json")"
|
||||
assert_contains "$subscription_state" '"group_id":7'
|
||||
assert_contains "$subscription_state" '"status":"active"'
|
||||
models_body="$(cat "$artifact_dir/run/10-models.body.json")"
|
||||
chat_body="$(cat "$artifact_dir/run/12-chat.body.json")"
|
||||
upstream_models="$(cat "$artifact_dir/run/18-upstream-models.body.json")"
|
||||
upstream_chat="$(cat "$artifact_dir/run/20-upstream-chat.body.txt")"
|
||||
summary_json="$(cat "$artifact_dir/run/21-summary.json" 2>/dev/null || true)"
|
||||
assert_contains "$models_body" '"id":"gpt-4"'
|
||||
assert_contains "$chat_body" '"content":"pong"'
|
||||
assert_contains "$upstream_models" '"id":"openai/gpt-4"'
|
||||
assert_contains "$upstream_chat" '"content":"upstream-pong"'
|
||||
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"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user