fix: align account test trace and checks

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
zyycn
2026-06-27 14:32:02 +08:00
co-authored by Codex
parent 2a8b26c819
commit c3c3f0d3cb
5 changed files with 21 additions and 21 deletions
+1 -1
View File
@@ -536,7 +536,7 @@ impl AccountPool {
.filter(|(account_id, _)| {
self.accounts
.get(*account_id)
.is_some_and(|account| is_capacity_account(account))
.is_some_and(&is_capacity_account)
})
.map(|(_, slots)| slots.len().min(self.options.max_concurrent_per_account))
.sum();
+1 -3
View File
@@ -92,9 +92,7 @@ fn quota_snapshot_from_rate_limit(
metered_feature: Option<&str>,
rate_limit: Option<&Value>,
) -> Option<Value> {
let Some(rate_limit) = rate_limit.filter(|value| !value.is_null()) else {
return None;
};
let rate_limit = rate_limit.filter(|value| !value.is_null())?;
let primary = window_from_rate_limit(rate_limit.get("primary_window"));
let secondary = window_from_rate_limit(rate_limit.get("secondary_window"));
if primary.is_null() && secondary.is_null() {
+4 -13
View File
@@ -284,21 +284,12 @@ async fn admin_account_quota_should_send_usage_cookie() {
}
#[tokio::test]
async fn admin_account_health_check_should_send_usage_cookie() {
async fn admin_account_health_check_should_send_probe_cookie() {
let server = MockServer::start().await;
Mock::given(method("GET"))
.and(path("/backend-api/wham/usage"))
.and(path("/backend-api/codex/models"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"plan_type": "plus",
"rate_limit": {
"allowed": true,
"limit_reached": false,
"primary_window": {
"used_percent": 15,
"reset_at": 1_800_000_000,
"limit_window_seconds": 18_000
}
}
"models": []
})))
.mount(&server)
.await;
@@ -349,7 +340,7 @@ async fn admin_account_health_check_should_send_usage_cookie() {
let requests = server.received_requests().await.unwrap();
let cookie_header = requests
.iter()
.find(|request| request.url.path() == "/backend-api/wham/usage")
.find(|request| request.url.path() == "/backend-api/codex/models")
.and_then(|request| request.headers.get("cookie"))
.and_then(|value| value.to_str().ok());
+6 -3
View File
@@ -129,7 +129,8 @@ async fn admin_settings_update_should_persist_retained_fields_to_config_yaml() {
.body(Body::from(
json!({
"defaultModel": "gpt-6", "rotationStrategy": "round_robin",
"refreshEnabled": false
"maxConcurrentPerAccount": 7,
"requestIntervalMs": 80
})
.to_string(),
))
@@ -160,7 +161,9 @@ async fn admin_settings_update_should_persist_retained_fields_to_config_yaml() {
let persisted = AppConfig::load_from_dir(dir.path()).unwrap();
assert_eq!(persisted.model.default_model, "gpt-6");
assert_eq!(persisted.auth.rotation_strategy, "round_robin");
assert!(!persisted.auth.refresh_enabled);
assert_eq!(persisted.auth.max_concurrent_per_account, 7);
assert_eq!(persisted.auth.request_interval_ms, 80);
assert!(persisted.auth.refresh_enabled);
assert_eq!(persisted.database.url, config.database.url);
assert_eq!(
persisted.security.master_key_file,
@@ -206,7 +209,7 @@ async fn admin_settings_update_should_reject_unsupported_or_invalid_fields() {
.header("cookie", "cpr_admin_session=session_1")
.header("x-request-id", "req_settings_update_invalid")
.body(Body::from(
json!({"unknownSetting": true, "rotationStrategy": "random"}).to_string(),
json!({"refreshEnabled": false, "rotationStrategy": "random"}).to_string(),
))
.unwrap(),
)
+9 -1
View File
@@ -449,6 +449,14 @@ function formatConnectionTestDetail(value: any) {
return JSON.stringify(value, null, 2)
}
function connectionTestRequestText(payload: any) {
const texts = (payload?.input || [])
.flatMap((item: any) => item?.content || [])
.filter((item: any) => item?.type === 'input_text' && item?.text)
.map((item: any) => item.text)
return texts.join('\n')
}
function connectionTestLogItem(key: string, text: string, tone = 'normal', detail?: any) {
return {
key,
@@ -491,7 +499,7 @@ function handleConnectionTestEvent(event: any) {
return
}
if (event.type === 'request') {
setConnectionTestLog('request', '发起请求', 'info', event.payload)
setConnectionTestLog('request', '发起请求', 'info', connectionTestRequestText(event.payload))
return
}
if (event.type === 'status' && event.text) {