fix: resolve concurrency hardening lint failures

Use typed connection admission errors, group HTTP limits, and make test lock lifetimes explicit. Handle fixture reads and remove unnecessary cloning and manual divisibility checks.
This commit is contained in:
elky
2026-09-10 08:31:47 +08:00
parent 3a8dadcd6b
commit 6aeadcd1d7
8 changed files with 82 additions and 67 deletions
+7 -6
View File
@@ -8681,12 +8681,13 @@ mod tests {
);
}
assert_eq!(store.enrichment_calls.load(Ordering::Acquire), 2);
let records = store.records.lock().expect("records lock");
assert_eq!(records.len(), 1);
assert_eq!(records[0].total_cost_usd, Some(0.456));
assert_eq!(records[0].actual_total_cost_usd, Some(0.123));
assert_eq!(records[0].total_tokens, Some(12));
drop(records);
{
let records = store.records.lock().expect("records lock");
assert_eq!(records.len(), 1);
assert_eq!(records[0].total_cost_usd, Some(0.456));
assert_eq!(records[0].actual_total_cost_usd, Some(0.123));
assert_eq!(records[0].total_tokens, Some(12));
}
{
let coalescer = &runtime.lifecycle_coalescer;
let entries = coalescer.shards[coalescer.shard_index(request_id)]
+22 -19
View File
@@ -1670,20 +1670,22 @@ mod tests {
.await
.expect("pending entry should become reclaimable");
let records = store.records.lock().expect("records lock");
assert_eq!(records.len(), 1);
assert_eq!(records[0].total_cost_usd, Some(0.456));
assert_eq!(records[0].actual_total_cost_usd, Some(0.123));
assert_eq!(records[0].total_tokens, Some(10));
drop(records);
let reconciliations = store.reconciliations.lock().expect("reconciliations lock");
assert_eq!(reconciliations.len(), 1);
assert_eq!(reconciliations[0].actual_cost_units, 12_300_000);
assert_eq!(
reconciliations[0].reservation_token,
"pricing-retry-reservation"
);
drop(reconciliations);
{
let records = store.records.lock().expect("records lock");
assert_eq!(records.len(), 1);
assert_eq!(records[0].total_cost_usd, Some(0.456));
assert_eq!(records[0].actual_total_cost_usd, Some(0.123));
assert_eq!(records[0].total_tokens, Some(10));
}
{
let reconciliations = store.reconciliations.lock().expect("reconciliations lock");
assert_eq!(reconciliations.len(), 1);
assert_eq!(reconciliations[0].actual_cost_units, 12_300_000);
assert_eq!(
reconciliations[0].reservation_token,
"pricing-retry-reservation"
);
}
assert_eq!(store.settlements.lock().expect("settlements lock").len(), 1);
assert_eq!(
store.enrich_calls.lock().expect("enrich calls lock").len(),
@@ -2400,11 +2402,12 @@ mod tests {
.await
.expect("worker should stop")
.expect("worker task");
let records = store.records.lock().expect("records lock");
assert_eq!(records.len(), 1);
assert_eq!(records[0].response_body, event.data.response_body);
assert_eq!(records[0].total_tokens, Some(10));
drop(records);
{
let records = store.records.lock().expect("records lock");
assert_eq!(records.len(), 1);
assert_eq!(records[0].response_body, event.data.response_body);
assert_eq!(records[0].total_tokens, Some(10));
}
let snapshot = budget.snapshot();
assert_eq!(snapshot.reserved_bytes, 0);
assert_eq!(snapshot.oversized_entries_total, 1);