mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-07 18:07:47 +08:00
Improve gateway transport and usage runtime
This commit is contained in:
@@ -1468,8 +1468,15 @@ async fn gateway_executes_openai_chat_cross_format_tool_use_upstream_stream_via_
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_skips_openai_chat_antigravity_cross_format_sync_candidate_as_transport_unsupported(
|
||||
#[test]
|
||||
fn gateway_skips_openai_chat_antigravity_cross_format_sync_candidate_as_transport_unsupported() {
|
||||
run_openai_chat_finalize_test(
|
||||
"gateway_skips_openai_chat_antigravity_cross_format_sync_candidate_as_transport_unsupported",
|
||||
gateway_skips_openai_chat_antigravity_cross_format_sync_candidate_as_transport_unsupported_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_skips_openai_chat_antigravity_cross_format_sync_candidate_as_transport_unsupported_impl(
|
||||
) {
|
||||
fn hash_api_key(value: &str) -> String {
|
||||
let mut hasher = Sha256::new();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use super::{
|
||||
any, build_router_with_execution_runtime_override, build_router_with_state,
|
||||
build_state_with_execution_runtime_override, json, start_server, to_bytes, Arc, Body, Bytes,
|
||||
HeaderName, HeaderValue, Json, Mutex, Request, Response, Router, StatusCode,
|
||||
CONTROL_EXECUTED_HEADER, EXECUTION_PATH_EXECUTION_RUNTIME_SYNC, EXECUTION_PATH_HEADER,
|
||||
TRACE_ID_HEADER,
|
||||
build_state_with_execution_runtime_override, json, run_finalize_local_cli_test, start_server,
|
||||
to_bytes, Arc, Body, Bytes, HeaderName, HeaderValue, Json, Mutex, Request, Response, Router,
|
||||
StatusCode, CONTROL_EXECUTED_HEADER, EXECUTION_PATH_EXECUTION_RUNTIME_SYNC,
|
||||
EXECUTION_PATH_HEADER, TRACE_ID_HEADER,
|
||||
};
|
||||
use crate::data::GatewayDataState;
|
||||
use aether_crypto::{encrypt_python_fernet_plaintext, DEVELOPMENT_ENCRYPTION_KEY};
|
||||
@@ -25,8 +25,16 @@ use aether_data_contracts::repository::provider_catalog::{
|
||||
};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_openai_responses_compact_openai_family_upstream_stream_via_local_finalize_response(
|
||||
#[test]
|
||||
fn gateway_executes_openai_responses_compact_openai_family_upstream_stream_via_local_finalize_response(
|
||||
) {
|
||||
run_finalize_local_cli_test(
|
||||
"gateway_executes_openai_responses_compact_openai_family_upstream_stream_via_local_finalize_response",
|
||||
gateway_executes_openai_responses_compact_openai_family_upstream_stream_via_local_finalize_response_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_openai_responses_compact_openai_family_upstream_stream_via_local_finalize_response_impl(
|
||||
) {
|
||||
use base64::Engine as _;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use super::{
|
||||
any, build_router_with_execution_runtime_override, build_router_with_state,
|
||||
build_state_with_execution_runtime_override, json, start_server, to_bytes, Arc, Body, Bytes,
|
||||
HeaderName, HeaderValue, Json, Mutex, Request, Response, Router, StatusCode,
|
||||
CONTROL_EXECUTED_HEADER, EXECUTION_PATH_EXECUTION_RUNTIME_SYNC, EXECUTION_PATH_HEADER,
|
||||
TRACE_ID_HEADER,
|
||||
build_state_with_execution_runtime_override, json, run_finalize_local_cli_test, start_server,
|
||||
to_bytes, Arc, Body, Bytes, HeaderName, HeaderValue, Json, Mutex, Request, Response, Router,
|
||||
StatusCode, CONTROL_EXECUTED_HEADER, EXECUTION_PATH_EXECUTION_RUNTIME_SYNC,
|
||||
EXECUTION_PATH_HEADER, TRACE_ID_HEADER,
|
||||
};
|
||||
use crate::data::GatewayDataState;
|
||||
use aether_crypto::{encrypt_python_fernet_plaintext, DEVELOPMENT_ENCRYPTION_KEY};
|
||||
@@ -25,8 +25,15 @@ use aether_data_contracts::repository::provider_catalog::{
|
||||
};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_openai_responses_cross_format_upstream_stream_via_local_finalize_response(
|
||||
#[test]
|
||||
fn gateway_executes_openai_responses_cross_format_upstream_stream_via_local_finalize_response() {
|
||||
run_finalize_local_cli_test(
|
||||
"gateway_executes_openai_responses_cross_format_upstream_stream_via_local_finalize_response",
|
||||
gateway_executes_openai_responses_cross_format_upstream_stream_via_local_finalize_response_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_openai_responses_cross_format_upstream_stream_via_local_finalize_response_impl(
|
||||
) {
|
||||
use base64::Engine as _;
|
||||
|
||||
@@ -490,8 +497,16 @@ async fn gateway_executes_openai_responses_cross_format_upstream_stream_via_loca
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_openai_responses_cross_format_function_call_upstream_stream_via_local_finalize_response(
|
||||
#[test]
|
||||
fn gateway_executes_openai_responses_cross_format_function_call_upstream_stream_via_local_finalize_response(
|
||||
) {
|
||||
run_finalize_local_cli_test(
|
||||
"gateway_executes_openai_responses_cross_format_function_call_upstream_stream_via_local_finalize_response",
|
||||
gateway_executes_openai_responses_cross_format_function_call_upstream_stream_via_local_finalize_response_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_openai_responses_cross_format_function_call_upstream_stream_via_local_finalize_response_impl(
|
||||
) {
|
||||
use base64::Engine as _;
|
||||
|
||||
@@ -953,8 +968,16 @@ async fn gateway_executes_openai_responses_cross_format_function_call_upstream_s
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_openai_responses_antigravity_cross_format_upstream_stream_via_local_finalize_response(
|
||||
#[test]
|
||||
fn gateway_executes_openai_responses_antigravity_cross_format_upstream_stream_via_local_finalize_response(
|
||||
) {
|
||||
run_finalize_local_cli_test(
|
||||
"gateway_executes_openai_responses_antigravity_cross_format_upstream_stream_via_local_finalize_response",
|
||||
gateway_executes_openai_responses_antigravity_cross_format_upstream_stream_via_local_finalize_response_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_openai_responses_antigravity_cross_format_upstream_stream_via_local_finalize_response_impl(
|
||||
) {
|
||||
use base64::Engine as _;
|
||||
|
||||
|
||||
@@ -49,8 +49,15 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_openai_responses_sync_upstream_stream_via_local_finalize_response() {
|
||||
#[test]
|
||||
fn gateway_executes_openai_responses_sync_upstream_stream_via_local_finalize_response() {
|
||||
run_kiro_claude_cli_finalize_test(
|
||||
"gateway_executes_openai_responses_sync_upstream_stream_via_local_finalize_response",
|
||||
gateway_executes_openai_responses_sync_upstream_stream_via_local_finalize_response_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_openai_responses_sync_upstream_stream_via_local_finalize_response_impl() {
|
||||
use base64::Engine as _;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -23,6 +23,30 @@ use super::{
|
||||
UsageRuntimeConfig, VideoTaskTruthSourceMode,
|
||||
};
|
||||
|
||||
const FINALIZE_LOCAL_CLI_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_finalize_local_cli_test<F, Fut>(test_name: &'static str, make_future: F)
|
||||
where
|
||||
F: FnOnce() -> Fut + Send + 'static,
|
||||
Fut: std::future::Future<Output = ()> + 'static,
|
||||
{
|
||||
let handle = std::thread::Builder::new()
|
||||
.name(test_name.to_string())
|
||||
.stack_size(FINALIZE_LOCAL_CLI_TEST_STACK_BYTES)
|
||||
.spawn(move || {
|
||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("test runtime should build");
|
||||
runtime.block_on(make_future());
|
||||
})
|
||||
.expect("finalize local cli test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
mod compact;
|
||||
mod cross_format;
|
||||
mod direct;
|
||||
|
||||
@@ -22,6 +22,30 @@ use sha2::{Digest, Sha256};
|
||||
use crate::data::GatewayDataState;
|
||||
use crate::tests::next_non_keepalive_chunk;
|
||||
|
||||
const LIFECYCLE_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_lifecycle_test<F, Fut>(test_name: &'static str, make_future: F)
|
||||
where
|
||||
F: FnOnce() -> Fut + Send + 'static,
|
||||
Fut: std::future::Future<Output = ()> + 'static,
|
||||
{
|
||||
let handle = std::thread::Builder::new()
|
||||
.name(test_name.to_string())
|
||||
.stack_size(LIFECYCLE_TEST_STACK_BYTES)
|
||||
.spawn(move || {
|
||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("test runtime should build");
|
||||
runtime.block_on(make_future());
|
||||
})
|
||||
.expect("lifecycle test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
fn hash_api_key(value: &str) -> String {
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(value.as_bytes());
|
||||
@@ -163,8 +187,15 @@ fn sample_local_openai_key() -> StoredProviderCatalogKey {
|
||||
.expect("key transport should build")
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn gateway_completes_sync_response_on_local_execution_runtime_path() {
|
||||
#[test]
|
||||
fn gateway_completes_sync_response_on_local_execution_runtime_path() {
|
||||
run_lifecycle_test(
|
||||
"gateway_completes_sync_response_on_local_execution_runtime_path",
|
||||
gateway_completes_sync_response_on_local_execution_runtime_path_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_completes_sync_response_on_local_execution_runtime_path_impl() {
|
||||
let public_hits = Arc::new(Mutex::new(0usize));
|
||||
let public_hits_clone = Arc::clone(&public_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -261,8 +292,15 @@ async fn gateway_completes_sync_response_on_local_execution_runtime_path() {
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn gateway_stops_execution_runtime_stream_when_client_disconnects() {
|
||||
#[test]
|
||||
fn gateway_stops_execution_runtime_stream_when_client_disconnects() {
|
||||
run_lifecycle_test(
|
||||
"gateway_stops_execution_runtime_stream_when_client_disconnects",
|
||||
gateway_stops_execution_runtime_stream_when_client_disconnects_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_stops_execution_runtime_stream_when_client_disconnects_impl() {
|
||||
let seen_report = Arc::new(Mutex::new(0usize));
|
||||
let seen_report_clone = Arc::clone(&seen_report);
|
||||
let public_hits = Arc::new(Mutex::new(0usize));
|
||||
@@ -388,8 +426,15 @@ async fn gateway_stops_execution_runtime_stream_when_client_disconnects() {
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn gateway_returns_error_body_when_prefetch_detects_embedded_stream_error() {
|
||||
#[test]
|
||||
fn gateway_returns_error_body_when_prefetch_detects_embedded_stream_error() {
|
||||
run_lifecycle_test(
|
||||
"gateway_returns_error_body_when_prefetch_detects_embedded_stream_error",
|
||||
gateway_returns_error_body_when_prefetch_detects_embedded_stream_error_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_returns_error_body_when_prefetch_detects_embedded_stream_error_impl() {
|
||||
let public_hits = Arc::new(Mutex::new(0usize));
|
||||
let public_hits_clone = Arc::clone(&public_hits);
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::{
|
||||
any, build_router_with_state, build_state_with_execution_runtime_override, json, start_server,
|
||||
strip_sse_keepalive_comments, to_bytes, AppState, Arc, Body, Bytes, HeaderName, HeaderValue,
|
||||
Json, Mutex, Request, Response, Router, StatusCode, EXECUTION_PATH_EXECUTION_RUNTIME_STREAM,
|
||||
EXECUTION_PATH_HEADER, TRACE_ID_HEADER,
|
||||
strip_sse_keepalive_comments, to_bytes, wait_until, AppState, Arc, Body, Bytes, HeaderName,
|
||||
HeaderValue, Json, Mutex, Request, Response, Router, StatusCode,
|
||||
EXECUTION_PATH_EXECUTION_RUNTIME_STREAM, EXECUTION_PATH_HEADER, TRACE_ID_HEADER,
|
||||
};
|
||||
use aether_crypto::{encrypt_python_fernet_plaintext, DEVELOPMENT_ENCRYPTION_KEY};
|
||||
use aether_data::repository::auth::{
|
||||
@@ -22,8 +22,40 @@ use aether_data_contracts::repository::provider_catalog::{
|
||||
};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_openai_chat_stream_via_local_decision_gate_without_execution_runtime_override(
|
||||
const STREAM_DECISION_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_stream_decision_test<F, Fut>(test_name: &'static str, make_future: F)
|
||||
where
|
||||
F: FnOnce() -> Fut + Send + 'static,
|
||||
Fut: std::future::Future<Output = ()> + 'static,
|
||||
{
|
||||
let handle = std::thread::Builder::new()
|
||||
.name(test_name.to_string())
|
||||
.stack_size(STREAM_DECISION_TEST_STACK_BYTES)
|
||||
.spawn(move || {
|
||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("test runtime should build");
|
||||
runtime.block_on(make_future());
|
||||
})
|
||||
.expect("stream decision test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gateway_executes_openai_chat_stream_via_local_decision_gate_without_execution_runtime_override()
|
||||
{
|
||||
run_stream_decision_test(
|
||||
"gateway_executes_openai_chat_stream_via_local_decision_gate_without_execution_runtime_override",
|
||||
gateway_executes_openai_chat_stream_via_local_decision_gate_without_execution_runtime_override_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_openai_chat_stream_via_local_decision_gate_without_execution_runtime_override_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenUpstreamStreamRequest {
|
||||
@@ -310,50 +342,19 @@ async fn gateway_executes_openai_chat_stream_via_local_decision_gate_without_exe
|
||||
"user-openai-local-stream-1",
|
||||
),
|
||||
)]));
|
||||
let mut backup_candidate_row = sample_candidate_row();
|
||||
backup_candidate_row.provider_id = "provider-openai-local-stream-2".to_string();
|
||||
backup_candidate_row.endpoint_id = "endpoint-openai-local-stream-2".to_string();
|
||||
backup_candidate_row.key_id = "key-openai-local-stream-2".to_string();
|
||||
backup_candidate_row.key_name = "backup".to_string();
|
||||
backup_candidate_row.key_internal_priority = 6;
|
||||
backup_candidate_row.model_id = "model-openai-local-stream-2".to_string();
|
||||
backup_candidate_row.global_model_id = "global-model-openai-local-stream-2".to_string();
|
||||
backup_candidate_row.model_provider_model_name = "gpt-5-upstream-backup".to_string();
|
||||
backup_candidate_row.model_provider_model_mappings = Some(vec![StoredProviderModelMapping {
|
||||
name: "gpt-5-upstream-backup".to_string(),
|
||||
priority: 1,
|
||||
api_formats: Some(vec!["openai:chat".to_string()]),
|
||||
endpoint_ids: None,
|
||||
}]);
|
||||
let candidate_selection_repository =
|
||||
Arc::new(InMemoryMinimalCandidateSelectionReadRepository::seed(vec![
|
||||
sample_candidate_row(),
|
||||
backup_candidate_row,
|
||||
]));
|
||||
let request_candidate_repository = Arc::new(InMemoryRequestCandidateRepository::default());
|
||||
let mut backup_provider = sample_provider_catalog_provider();
|
||||
backup_provider.id = "provider-openai-local-stream-2".to_string();
|
||||
let mut backup_endpoint = sample_provider_catalog_endpoint();
|
||||
backup_endpoint.id = "endpoint-openai-local-stream-2".to_string();
|
||||
backup_endpoint.provider_id = "provider-openai-local-stream-2".to_string();
|
||||
backup_endpoint.base_url = "https://api.openai.backup.example".to_string();
|
||||
let mut backup_key = sample_provider_catalog_key();
|
||||
backup_key.id = "key-openai-local-stream-2".to_string();
|
||||
backup_key.provider_id = "provider-openai-local-stream-2".to_string();
|
||||
backup_key.name = "backup".to_string();
|
||||
backup_key.encrypted_api_key = Some(
|
||||
encrypt_python_fernet_plaintext(DEVELOPMENT_ENCRYPTION_KEY, "sk-upstream-openai-backup")
|
||||
.expect("api key should encrypt"),
|
||||
);
|
||||
let (upstream_url, upstream_handle) = start_server(upstream).await;
|
||||
let (provider_url, provider_handle) = start_server(provider).await;
|
||||
let mut primary_endpoint = sample_provider_catalog_endpoint();
|
||||
primary_endpoint.base_url = format!("{provider_url}/v1");
|
||||
backup_endpoint.base_url = "http://127.0.0.1:9".to_string();
|
||||
let provider_catalog_repository = Arc::new(InMemoryProviderCatalogReadRepository::seed(
|
||||
vec![sample_provider_catalog_provider(), backup_provider],
|
||||
vec![primary_endpoint, backup_endpoint],
|
||||
vec![sample_provider_catalog_key(), backup_key],
|
||||
vec![sample_provider_catalog_provider()],
|
||||
vec![primary_endpoint],
|
||||
vec![sample_provider_catalog_key()],
|
||||
));
|
||||
let gateway_state = AppState::new()
|
||||
.expect("gateway state should build")
|
||||
@@ -443,8 +444,16 @@ async fn gateway_executes_openai_chat_stream_via_local_decision_gate_without_exe
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_openai_chat_stream_via_local_openai_responses_cross_format_candidate() {
|
||||
#[test]
|
||||
fn gateway_executes_openai_chat_stream_via_local_openai_responses_cross_format_candidate() {
|
||||
run_stream_decision_test(
|
||||
"gateway_executes_openai_chat_stream_via_local_openai_responses_cross_format_candidate",
|
||||
gateway_executes_openai_chat_stream_via_local_openai_responses_cross_format_candidate_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_openai_chat_stream_via_local_openai_responses_cross_format_candidate_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
trace_id: String,
|
||||
@@ -821,10 +830,10 @@ async fn gateway_executes_openai_chat_stream_via_local_openai_responses_cross_fo
|
||||
Arc::clone(&request_candidate_repository),
|
||||
DEVELOPMENT_ENCRYPTION_KEY,
|
||||
)
|
||||
.with_system_config_values_for_tests(vec![(
|
||||
"provider_priority_mode".to_string(),
|
||||
json!("global_key"),
|
||||
)]),
|
||||
.with_system_config_values_for_tests(vec![
|
||||
("scheduling_mode".to_string(), json!("fixed_order")),
|
||||
("provider_priority_mode".to_string(), json!("global_key")),
|
||||
]),
|
||||
);
|
||||
let gateway = build_router_with_state(gateway_state);
|
||||
let (gateway_url, gateway_handle) = start_server(gateway).await;
|
||||
@@ -928,8 +937,16 @@ async fn gateway_executes_openai_chat_stream_via_local_openai_responses_cross_fo
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_openai_chat_stream_via_local_cross_format_gemini_candidate_with_stream_path_rewrite(
|
||||
#[test]
|
||||
fn gateway_executes_openai_chat_stream_via_local_cross_format_gemini_candidate_with_stream_path_rewrite(
|
||||
) {
|
||||
run_stream_decision_test(
|
||||
"gateway_executes_openai_chat_stream_via_local_cross_format_gemini_candidate_with_stream_path_rewrite",
|
||||
gateway_executes_openai_chat_stream_via_local_cross_format_gemini_candidate_with_stream_path_rewrite_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_openai_chat_stream_via_local_cross_format_gemini_candidate_with_stream_path_rewrite_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
@@ -1350,8 +1367,16 @@ async fn gateway_executes_openai_chat_stream_via_local_cross_format_gemini_candi
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_openai_chat_stream_with_custom_path_via_local_decision_gate_with_local_stream_decision(
|
||||
#[test]
|
||||
fn gateway_executes_openai_chat_stream_with_custom_path_via_local_decision_gate_with_local_stream_decision(
|
||||
) {
|
||||
run_stream_decision_test(
|
||||
"gateway_executes_openai_chat_stream_with_custom_path_via_local_decision_gate_with_local_stream_decision",
|
||||
gateway_executes_openai_chat_stream_with_custom_path_via_local_decision_gate_with_local_stream_decision_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_openai_chat_stream_with_custom_path_via_local_decision_gate_with_local_stream_decision_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
@@ -1844,8 +1869,16 @@ async fn gateway_executes_openai_chat_stream_with_custom_path_via_local_decision
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable_429_execution_runtime_status(
|
||||
#[test]
|
||||
fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable_429_execution_runtime_status(
|
||||
) {
|
||||
run_stream_decision_test(
|
||||
"gateway_retries_next_local_openai_chat_stream_candidate_after_retryable_429_execution_runtime_status",
|
||||
gateway_retries_next_local_openai_chat_stream_candidate_after_retryable_429_execution_runtime_status_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable_429_execution_runtime_status_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
@@ -2024,7 +2057,7 @@ async fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable
|
||||
let seen_execution_runtime_clone = Arc::clone(&seen_execution_runtime);
|
||||
let seen_report = Arc::new(Mutex::new(false));
|
||||
let seen_report_clone = Arc::clone(&seen_report);
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits = Arc::new(std::sync::atomic::AtomicUsize::new(0));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let decision_hits = Arc::new(Mutex::new(0usize));
|
||||
let decision_hits_clone = Arc::clone(&decision_hits);
|
||||
@@ -2106,24 +2139,26 @@ async fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable
|
||||
let raw_body = to_bytes(body, usize::MAX).await.expect("body should read");
|
||||
let payload: serde_json::Value =
|
||||
serde_json::from_slice(&raw_body).expect("execution runtime payload should parse");
|
||||
let mut hits = execution_runtime_hits_inner.lock().expect("mutex should lock");
|
||||
*hits += 1;
|
||||
let attempt = *hits;
|
||||
drop(hits);
|
||||
let request_url = payload
|
||||
.get("url")
|
||||
.and_then(|value| value.as_str())
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
let attempt = execution_runtime_hits_inner
|
||||
.fetch_add(1, std::sync::atomic::Ordering::SeqCst)
|
||||
+ 1;
|
||||
|
||||
seen_execution_runtime_inner.lock().expect("mutex should lock").push(
|
||||
SeenExecutionRuntimeStreamRequest {
|
||||
seen_execution_runtime_inner
|
||||
.lock()
|
||||
.expect("mutex should lock")
|
||||
.push(SeenExecutionRuntimeStreamRequest {
|
||||
trace_id: parts
|
||||
.headers
|
||||
.get(TRACE_ID_HEADER)
|
||||
.and_then(|value| value.to_str().ok())
|
||||
.unwrap_or_default()
|
||||
.to_string(),
|
||||
url: payload
|
||||
.get("url")
|
||||
.and_then(|value| value.as_str())
|
||||
.unwrap_or_default()
|
||||
.to_string(),
|
||||
url: request_url.clone(),
|
||||
model: payload
|
||||
.get("body")
|
||||
.and_then(|value| value.get("json_body"))
|
||||
@@ -2149,8 +2184,7 @@ async fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable
|
||||
.and_then(|value| value.as_str())
|
||||
.unwrap_or_default()
|
||||
.to_string(),
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
let frames = if attempt == 1 {
|
||||
concat!(
|
||||
@@ -2289,38 +2323,47 @@ async fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable
|
||||
"data: {\"id\":\"chatcmpl-local-stream-failover-123\"}\n\ndata: [DONE]\n\n"
|
||||
);
|
||||
|
||||
wait_until(5_000, || {
|
||||
seen_execution_runtime
|
||||
.lock()
|
||||
.expect("mutex should lock")
|
||||
.len()
|
||||
>= 2
|
||||
})
|
||||
.await;
|
||||
let seen_execution_runtime_requests = seen_execution_runtime
|
||||
.lock()
|
||||
.expect("mutex should lock")
|
||||
.clone();
|
||||
assert_eq!(seen_execution_runtime_requests.len(), 2);
|
||||
let primary_request = seen_execution_runtime_requests
|
||||
.iter()
|
||||
.find(|request| request.url == "https://api.openai.primary.example/chat/completions")
|
||||
.expect("primary execution runtime request should be captured");
|
||||
let backup_request = seen_execution_runtime_requests
|
||||
.iter()
|
||||
.find(|request| request.url == "https://api.openai.backup.example/chat/completions")
|
||||
.expect("backup execution runtime request should be captured");
|
||||
assert_eq!(
|
||||
seen_execution_runtime_requests[0].trace_id,
|
||||
primary_request.trace_id,
|
||||
"trace-openai-chat-local-stream-failover-123"
|
||||
);
|
||||
assert_eq!(primary_request.model, "gpt-5-upstream-primary");
|
||||
assert!(primary_request.stream);
|
||||
assert_eq!(primary_request.accept, "text/event-stream");
|
||||
assert_eq!(
|
||||
seen_execution_runtime_requests[0].url,
|
||||
"https://api.openai.primary.example/chat/completions"
|
||||
);
|
||||
assert_eq!(
|
||||
seen_execution_runtime_requests[0].authorization,
|
||||
primary_request.authorization,
|
||||
"Bearer sk-upstream-openai-primary"
|
||||
);
|
||||
assert_eq!(
|
||||
seen_execution_runtime_requests[1].url,
|
||||
"https://api.openai.backup.example/chat/completions"
|
||||
backup_request.trace_id,
|
||||
"trace-openai-chat-local-stream-failover-123"
|
||||
);
|
||||
assert_eq!(backup_request.model, "gpt-5-upstream-backup");
|
||||
assert!(backup_request.stream);
|
||||
assert_eq!(backup_request.accept, "text/event-stream");
|
||||
assert_eq!(
|
||||
seen_execution_runtime_requests[1].model,
|
||||
"gpt-5-upstream-backup"
|
||||
);
|
||||
assert!(seen_execution_runtime_requests[1].stream);
|
||||
assert_eq!(
|
||||
seen_execution_runtime_requests[1].accept,
|
||||
"text/event-stream"
|
||||
);
|
||||
assert_eq!(
|
||||
seen_execution_runtime_requests[1].authorization,
|
||||
backup_request.authorization,
|
||||
"Bearer sk-upstream-openai-backup"
|
||||
);
|
||||
let stored_candidates = request_candidate_repository
|
||||
@@ -2328,18 +2371,25 @@ async fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable
|
||||
.await
|
||||
.expect("request candidate trace should read");
|
||||
assert_eq!(stored_candidates.len(), 2);
|
||||
assert_eq!(stored_candidates[0].candidate_index, 0);
|
||||
assert_eq!(stored_candidates[0].status, RequestCandidateStatus::Failed);
|
||||
assert_eq!(stored_candidates[0].status_code, Some(429));
|
||||
let failed_candidate = stored_candidates
|
||||
.iter()
|
||||
.find(|candidate| candidate.candidate_index == 0)
|
||||
.expect("primary failed candidate should be stored");
|
||||
let success_candidate = stored_candidates
|
||||
.iter()
|
||||
.find(|candidate| candidate.candidate_index == 1)
|
||||
.expect("backup success candidate should be stored");
|
||||
assert_eq!(failed_candidate.status, RequestCandidateStatus::Failed);
|
||||
assert_eq!(failed_candidate.status_code, Some(429));
|
||||
assert_eq!(
|
||||
stored_candidates[0].error_type.as_deref(),
|
||||
failed_candidate.error_type.as_deref(),
|
||||
Some("retryable_upstream_status")
|
||||
);
|
||||
assert_eq!(
|
||||
stored_candidates[0].error_message.as_deref(),
|
||||
failed_candidate.error_message.as_deref(),
|
||||
Some("execution runtime stream returned retryable status 429")
|
||||
);
|
||||
let failed_upstream_response = stored_candidates[0]
|
||||
let failed_upstream_response = failed_candidate
|
||||
.extra_data
|
||||
.as_ref()
|
||||
.and_then(|value| value.get("upstream_response"))
|
||||
@@ -2353,11 +2403,10 @@ async fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable
|
||||
failed_upstream_response["body"]["error"]["type"],
|
||||
json!("rate_limit_error")
|
||||
);
|
||||
assert_eq!(stored_candidates[1].candidate_index, 1);
|
||||
assert_eq!(stored_candidates[1].status, RequestCandidateStatus::Success);
|
||||
assert_eq!(stored_candidates[1].status_code, Some(200));
|
||||
assert!(stored_candidates[1].started_at_unix_ms.is_some());
|
||||
assert!(stored_candidates[1].finished_at_unix_ms.is_some());
|
||||
assert_eq!(success_candidate.status, RequestCandidateStatus::Success);
|
||||
assert_eq!(success_candidate.status_code, Some(200));
|
||||
assert!(success_candidate.started_at_unix_ms.is_some());
|
||||
assert!(success_candidate.finished_at_unix_ms.is_some());
|
||||
|
||||
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
|
||||
assert!(
|
||||
@@ -2366,7 +2415,7 @@ async fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
*execution_runtime_hits.lock().expect("mutex should lock"),
|
||||
execution_runtime_hits.load(std::sync::atomic::Ordering::SeqCst),
|
||||
2
|
||||
);
|
||||
assert_eq!(*decision_hits.lock().expect("mutex should lock"), 0);
|
||||
|
||||
@@ -18,8 +18,39 @@ use aether_data_contracts::repository::provider_catalog::{
|
||||
};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_codex_image_stream_via_local_decision_gate_after_oauth_refresh() {
|
||||
const STREAM_IMAGE_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_stream_image_test<F, Fut>(test_name: &'static str, make_future: F)
|
||||
where
|
||||
F: FnOnce() -> Fut + Send + 'static,
|
||||
Fut: std::future::Future<Output = ()> + 'static,
|
||||
{
|
||||
let handle = std::thread::Builder::new()
|
||||
.name(test_name.to_string())
|
||||
.stack_size(STREAM_IMAGE_TEST_STACK_BYTES)
|
||||
.spawn(move || {
|
||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("test runtime should build");
|
||||
runtime.block_on(make_future());
|
||||
})
|
||||
.expect("stream image test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gateway_executes_codex_image_stream_via_local_decision_gate_after_oauth_refresh() {
|
||||
run_stream_image_test(
|
||||
"gateway_executes_codex_image_stream_via_local_decision_gate_after_oauth_refresh",
|
||||
gateway_executes_codex_image_stream_via_local_decision_gate_after_oauth_refresh_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_codex_image_stream_via_local_decision_gate_after_oauth_refresh_impl() {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
trace_id: String,
|
||||
@@ -438,8 +469,15 @@ async fn gateway_executes_codex_image_stream_via_local_decision_gate_after_oauth
|
||||
refresh_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_bridges_codex_image_sync_json_to_streaming_image_sse() {
|
||||
#[test]
|
||||
fn gateway_bridges_codex_image_sync_json_to_streaming_image_sse() {
|
||||
run_stream_image_test(
|
||||
"gateway_bridges_codex_image_sync_json_to_streaming_image_sse",
|
||||
gateway_bridges_codex_image_sync_json_to_streaming_image_sse_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_bridges_codex_image_sync_json_to_streaming_image_sse_impl() {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
trace_id: String,
|
||||
@@ -1057,8 +1095,16 @@ fn image_bridge_execution_runtime(
|
||||
)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_routes_openai_responses_stream_image_intent_to_openai_image_plan_without_streaming_support(
|
||||
#[test]
|
||||
fn gateway_routes_openai_responses_stream_image_intent_to_openai_image_plan_without_streaming_support(
|
||||
) {
|
||||
run_stream_image_test(
|
||||
"gateway_routes_openai_responses_stream_image_intent_to_openai_image_plan_without_streaming_support",
|
||||
gateway_routes_openai_responses_stream_image_intent_to_openai_image_plan_without_streaming_support_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_routes_openai_responses_stream_image_intent_to_openai_image_plan_without_streaming_support_impl(
|
||||
) {
|
||||
let seen_execution_plan = Arc::new(Mutex::new(None::<SeenImageBridgeExecutionPlan>));
|
||||
let execution_runtime = image_bridge_execution_runtime(Arc::clone(&seen_execution_plan));
|
||||
|
||||
@@ -228,8 +228,39 @@ fn collect_email_sentinel(text: &str) -> String {
|
||||
text[start..end].to_string()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn ai_execute_stream_pii_redaction_round_trip() {
|
||||
const STREAM_PII_REDACTION_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_stream_pii_redaction_test<F, Fut>(test_name: &'static str, make_future: F)
|
||||
where
|
||||
F: FnOnce() -> Fut + Send + 'static,
|
||||
Fut: std::future::Future<Output = ()> + 'static,
|
||||
{
|
||||
let handle = std::thread::Builder::new()
|
||||
.name(test_name.to_string())
|
||||
.stack_size(STREAM_PII_REDACTION_TEST_STACK_BYTES)
|
||||
.spawn(move || {
|
||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("test runtime should build");
|
||||
runtime.block_on(make_future());
|
||||
})
|
||||
.expect("stream pii redaction test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_execute_stream_pii_redaction_round_trip() {
|
||||
run_stream_pii_redaction_test(
|
||||
"ai_execute_stream_pii_redaction_round_trip",
|
||||
ai_execute_stream_pii_redaction_round_trip_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn ai_execute_stream_pii_redaction_round_trip_impl() {
|
||||
let seen_provider_request = Arc::new(Mutex::new(None::<SeenProviderStreamRequest>));
|
||||
let seen_provider_request_clone = Arc::clone(&seen_provider_request);
|
||||
let provider_app = Router::new().route(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::{
|
||||
any, build_router_with_state, build_state_with_execution_runtime_override, json, start_server,
|
||||
to_bytes, Arc, Body, Bytes, HeaderName, HeaderValue, Infallible, Json, Mutex, Request,
|
||||
Response, Router, StatusCode, EXECUTION_PATH_EXECUTION_RUNTIME_STREAM, EXECUTION_PATH_HEADER,
|
||||
TRACE_ID_HEADER,
|
||||
any, build_router_with_state, build_state_with_execution_runtime_override, json,
|
||||
run_stream_cli_test, start_server, to_bytes, Arc, Body, Bytes, HeaderName, HeaderValue,
|
||||
Infallible, Json, Mutex, Request, Response, Router, StatusCode,
|
||||
EXECUTION_PATH_EXECUTION_RUNTIME_STREAM, EXECUTION_PATH_HEADER, TRACE_ID_HEADER,
|
||||
};
|
||||
use aether_crypto::{encrypt_python_fernet_plaintext, DEVELOPMENT_ENCRYPTION_KEY};
|
||||
use aether_data::repository::auth::{
|
||||
@@ -22,8 +22,16 @@ use aether_data_contracts::repository::provider_catalog::{
|
||||
};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_openai_responses_compact_stream_via_local_decision_gate_with_local_stream_decision(
|
||||
#[test]
|
||||
fn gateway_executes_openai_responses_compact_stream_via_local_decision_gate_with_local_stream_decision(
|
||||
) {
|
||||
run_stream_cli_test(
|
||||
"gateway_executes_openai_responses_compact_stream_via_local_decision_gate_with_local_stream_decision",
|
||||
gateway_executes_openai_responses_compact_stream_via_local_decision_gate_with_local_stream_decision_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_openai_responses_compact_stream_via_local_decision_gate_with_local_stream_decision_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use super::{
|
||||
any, build_router_with_state, build_state_with_execution_runtime_override, json, start_server,
|
||||
strip_sse_keepalive_comments, to_bytes, Arc, Body, Bytes, HeaderName, HeaderValue, Infallible,
|
||||
Json, Mutex, Request, Response, Router, StatusCode, UsageRuntimeConfig, TRACE_ID_HEADER,
|
||||
any, build_router_with_state, build_state_with_execution_runtime_override, json,
|
||||
run_stream_cli_test, start_server, strip_sse_keepalive_comments, to_bytes, Arc, Body, Bytes,
|
||||
HeaderName, HeaderValue, Infallible, Json, Mutex, Request, Response, Router, StatusCode,
|
||||
UsageRuntimeConfig, TRACE_ID_HEADER,
|
||||
};
|
||||
use aether_crypto::{encrypt_python_fernet_plaintext, DEVELOPMENT_ENCRYPTION_KEY};
|
||||
use aether_data::repository::auth::{
|
||||
@@ -23,8 +24,15 @@ use aether_data_contracts::repository::provider_catalog::{
|
||||
use aether_data_contracts::repository::usage::UsageReadRepository;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_codex_cli_stream_via_local_decision_gate_after_oauth_refresh() {
|
||||
#[test]
|
||||
fn gateway_executes_codex_cli_stream_via_local_decision_gate_after_oauth_refresh() {
|
||||
run_stream_cli_test(
|
||||
"gateway_executes_codex_cli_stream_via_local_decision_gate_after_oauth_refresh",
|
||||
gateway_executes_codex_cli_stream_via_local_decision_gate_after_oauth_refresh_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_codex_cli_stream_via_local_decision_gate_after_oauth_refresh_impl() {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
trace_id: String,
|
||||
|
||||
@@ -23,5 +23,29 @@ use super::{
|
||||
GatewayFallbackReason, UsageRuntimeConfig, VideoTaskTruthSourceMode,
|
||||
};
|
||||
|
||||
const STREAM_CLI_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_stream_cli_test<F, Fut>(test_name: &'static str, make_future: F)
|
||||
where
|
||||
F: FnOnce() -> Fut + Send + 'static,
|
||||
Fut: std::future::Future<Output = ()> + 'static,
|
||||
{
|
||||
let handle = std::thread::Builder::new()
|
||||
.name(test_name.to_string())
|
||||
.stack_size(STREAM_CLI_TEST_STACK_BYTES)
|
||||
.spawn(move || {
|
||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("test runtime should build");
|
||||
runtime.block_on(make_future());
|
||||
})
|
||||
.expect("stream cli test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
mod compact;
|
||||
mod direct;
|
||||
|
||||
@@ -22,8 +22,39 @@ use aether_data_contracts::repository::provider_catalog::{
|
||||
};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_kiro_claude_cli_stream_via_local_provider_catalog_candidate() {
|
||||
const STREAM_PROVIDER_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_stream_provider_test<F, Fut>(test_name: &'static str, make_future: F)
|
||||
where
|
||||
F: FnOnce() -> Fut + Send + 'static,
|
||||
Fut: std::future::Future<Output = ()> + 'static,
|
||||
{
|
||||
let handle = std::thread::Builder::new()
|
||||
.name(test_name.to_string())
|
||||
.stack_size(STREAM_PROVIDER_TEST_STACK_BYTES)
|
||||
.spawn(move || {
|
||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("test runtime should build");
|
||||
runtime.block_on(make_future());
|
||||
})
|
||||
.expect("stream provider test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gateway_executes_kiro_claude_cli_stream_via_local_provider_catalog_candidate() {
|
||||
run_stream_provider_test(
|
||||
"gateway_executes_kiro_claude_cli_stream_via_local_provider_catalog_candidate",
|
||||
gateway_executes_kiro_claude_cli_stream_via_local_provider_catalog_candidate_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_kiro_claude_cli_stream_via_local_provider_catalog_candidate_impl() {
|
||||
use base64::Engine as _;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -578,8 +609,16 @@ async fn gateway_executes_kiro_claude_cli_stream_via_local_provider_catalog_cand
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_claude_cli_stream_via_local_decision_gate_without_waiting_for_same_format_prefetch(
|
||||
#[test]
|
||||
fn gateway_executes_claude_cli_stream_via_local_decision_gate_without_waiting_for_same_format_prefetch(
|
||||
) {
|
||||
run_stream_provider_test(
|
||||
"gateway_executes_claude_cli_stream_via_local_decision_gate_without_waiting_for_same_format_prefetch",
|
||||
gateway_executes_claude_cli_stream_via_local_decision_gate_without_waiting_for_same_format_prefetch_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_claude_cli_stream_via_local_decision_gate_without_waiting_for_same_format_prefetch_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
@@ -1026,8 +1065,15 @@ async fn gateway_executes_claude_cli_stream_via_local_decision_gate_without_wait
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_claude_code_cli_stream_via_local_decision_gate_with_local_stream_decision(
|
||||
#[test]
|
||||
fn gateway_executes_claude_code_cli_stream_via_local_decision_gate_with_local_stream_decision() {
|
||||
run_stream_provider_test(
|
||||
"gateway_executes_claude_code_cli_stream_via_local_decision_gate_with_local_stream_decision",
|
||||
gateway_executes_claude_code_cli_stream_via_local_decision_gate_with_local_stream_decision_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_claude_code_cli_stream_via_local_decision_gate_with_local_stream_decision_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
@@ -1558,8 +1604,16 @@ async fn gateway_executes_claude_code_cli_stream_via_local_decision_gate_with_lo
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_claude_chat_stream_via_local_decision_gate_with_local_stream_decision() {
|
||||
#[test]
|
||||
fn gateway_executes_claude_chat_stream_via_local_decision_gate_with_local_stream_decision() {
|
||||
run_stream_provider_test(
|
||||
"gateway_executes_claude_chat_stream_via_local_decision_gate_with_local_stream_decision",
|
||||
gateway_executes_claude_chat_stream_via_local_decision_gate_with_local_stream_decision_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_claude_chat_stream_via_local_decision_gate_with_local_stream_decision_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
trace_id: String,
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
use super::{
|
||||
any, build_router_with_state, build_state_with_execution_runtime_override,
|
||||
encrypt_python_fernet_plaintext, json, start_server, strip_sse_keepalive_comments, to_bytes,
|
||||
Arc, Body, Bytes, Digest, HeaderName, HeaderValue, InMemoryAuthApiKeySnapshotRepository,
|
||||
InMemoryMinimalCandidateSelectionReadRepository, InMemoryProviderCatalogReadRepository,
|
||||
InMemoryRequestCandidateRepository, Json, Mutex, Request, RequestCandidateReadRepository,
|
||||
RequestCandidateStatus, Response, Router, Sha256, StatusCode, StoredAuthApiKeySnapshot,
|
||||
StoredMinimalCandidateSelectionRow, StoredProviderCatalogEndpoint, StoredProviderCatalogKey,
|
||||
StoredProviderCatalogProvider, StoredProviderModelMapping, DEVELOPMENT_ENCRYPTION_KEY,
|
||||
TRACE_ID_HEADER,
|
||||
encrypt_python_fernet_plaintext, json, run_stream_provider_gemini_test, start_server,
|
||||
strip_sse_keepalive_comments, to_bytes, Arc, Body, Bytes, Digest, HeaderName, HeaderValue,
|
||||
InMemoryAuthApiKeySnapshotRepository, InMemoryMinimalCandidateSelectionReadRepository,
|
||||
InMemoryProviderCatalogReadRepository, InMemoryRequestCandidateRepository, Json, Mutex,
|
||||
Request, RequestCandidateReadRepository, RequestCandidateStatus, Response, Router, Sha256,
|
||||
StatusCode, StoredAuthApiKeySnapshot, StoredMinimalCandidateSelectionRow,
|
||||
StoredProviderCatalogEndpoint, StoredProviderCatalogKey, StoredProviderCatalogProvider,
|
||||
StoredProviderModelMapping, DEVELOPMENT_ENCRYPTION_KEY, TRACE_ID_HEADER,
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_gemini_chat_stream_via_local_decision_gate_with_local_stream_decision() {
|
||||
#[test]
|
||||
fn gateway_executes_gemini_chat_stream_via_local_decision_gate_with_local_stream_decision() {
|
||||
run_stream_provider_gemini_test(
|
||||
"gateway_executes_gemini_chat_stream_via_local_decision_gate_with_local_stream_decision",
|
||||
gateway_executes_gemini_chat_stream_via_local_decision_gate_with_local_stream_decision_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_gemini_chat_stream_via_local_decision_gate_with_local_stream_decision_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
trace_id: String,
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
use super::{
|
||||
any, build_router_with_state, build_state_with_execution_runtime_override,
|
||||
encrypt_python_fernet_plaintext, json, start_server, strip_sse_keepalive_comments, to_bytes,
|
||||
Arc, Body, Bytes, Digest, HeaderName, HeaderValue, InMemoryAuthApiKeySnapshotRepository,
|
||||
InMemoryMinimalCandidateSelectionReadRepository, InMemoryProviderCatalogReadRepository,
|
||||
InMemoryRequestCandidateRepository, Json, Mutex, Request, RequestCandidateReadRepository,
|
||||
RequestCandidateStatus, Response, Router, Sha256, StatusCode, StoredAuthApiKeySnapshot,
|
||||
StoredMinimalCandidateSelectionRow, StoredProviderCatalogEndpoint, StoredProviderCatalogKey,
|
||||
StoredProviderCatalogProvider, StoredProviderModelMapping, DEVELOPMENT_ENCRYPTION_KEY,
|
||||
TRACE_ID_HEADER,
|
||||
encrypt_python_fernet_plaintext, json, run_stream_provider_gemini_test, start_server,
|
||||
strip_sse_keepalive_comments, to_bytes, Arc, Body, Bytes, Digest, HeaderName, HeaderValue,
|
||||
InMemoryAuthApiKeySnapshotRepository, InMemoryMinimalCandidateSelectionReadRepository,
|
||||
InMemoryProviderCatalogReadRepository, InMemoryRequestCandidateRepository, Json, Mutex,
|
||||
Request, RequestCandidateReadRepository, RequestCandidateStatus, Response, Router, Sha256,
|
||||
StatusCode, StoredAuthApiKeySnapshot, StoredMinimalCandidateSelectionRow,
|
||||
StoredProviderCatalogEndpoint, StoredProviderCatalogKey, StoredProviderCatalogProvider,
|
||||
StoredProviderModelMapping, DEVELOPMENT_ENCRYPTION_KEY, TRACE_ID_HEADER,
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_gemini_cli_stream_via_local_decision_gate_with_local_stream_decision() {
|
||||
#[test]
|
||||
fn gateway_executes_gemini_cli_stream_via_local_decision_gate_with_local_stream_decision() {
|
||||
run_stream_provider_gemini_test(
|
||||
"gateway_executes_gemini_cli_stream_via_local_decision_gate_with_local_stream_decision",
|
||||
gateway_executes_gemini_cli_stream_via_local_decision_gate_with_local_stream_decision_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_gemini_cli_stream_via_local_decision_gate_with_local_stream_decision_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
trace_id: String,
|
||||
@@ -446,8 +454,15 @@ async fn gateway_executes_gemini_cli_stream_via_local_decision_gate_with_local_s
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_gemini_cli_stream_via_local_decision_gate_after_oauth_refresh() {
|
||||
#[test]
|
||||
fn gateway_executes_gemini_cli_stream_via_local_decision_gate_after_oauth_refresh() {
|
||||
run_stream_provider_gemini_test(
|
||||
"gateway_executes_gemini_cli_stream_via_local_decision_gate_after_oauth_refresh",
|
||||
gateway_executes_gemini_cli_stream_via_local_decision_gate_after_oauth_refresh_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_gemini_cli_stream_via_local_decision_gate_after_oauth_refresh_impl() {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
trace_id: String,
|
||||
@@ -1001,8 +1016,16 @@ async fn gateway_executes_gemini_cli_stream_via_local_decision_gate_after_oauth_
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_vertex_ai_gemini_cli_stream_via_local_decision_gate_with_local_stream_decision(
|
||||
#[test]
|
||||
fn gateway_executes_vertex_ai_gemini_cli_stream_via_local_decision_gate_with_local_stream_decision()
|
||||
{
|
||||
run_stream_provider_gemini_test(
|
||||
"gateway_executes_vertex_ai_gemini_cli_stream_via_local_decision_gate_with_local_stream_decision",
|
||||
gateway_executes_vertex_ai_gemini_cli_stream_via_local_decision_gate_with_local_stream_decision_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_vertex_ai_gemini_cli_stream_via_local_decision_gate_with_local_stream_decision_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
@@ -1436,8 +1459,15 @@ async fn gateway_executes_vertex_ai_gemini_cli_stream_via_local_decision_gate_wi
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_antigravity_gemini_cli_stream_via_local_decision_gate_after_oauth_refresh(
|
||||
#[test]
|
||||
fn gateway_executes_antigravity_gemini_cli_stream_via_local_decision_gate_after_oauth_refresh() {
|
||||
run_stream_provider_gemini_test(
|
||||
"gateway_executes_antigravity_gemini_cli_stream_via_local_decision_gate_after_oauth_refresh",
|
||||
gateway_executes_antigravity_gemini_cli_stream_via_local_decision_gate_after_oauth_refresh_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_antigravity_gemini_cli_stream_via_local_decision_gate_after_oauth_refresh_impl(
|
||||
) {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeStreamRequest {
|
||||
|
||||
@@ -40,5 +40,29 @@ use aether_data_contracts::repository::provider_catalog::{
|
||||
};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
const STREAM_PROVIDER_GEMINI_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_stream_provider_gemini_test<F, Fut>(test_name: &'static str, make_future: F)
|
||||
where
|
||||
F: FnOnce() -> Fut + Send + 'static,
|
||||
Fut: std::future::Future<Output = ()> + 'static,
|
||||
{
|
||||
let handle = std::thread::Builder::new()
|
||||
.name(test_name.to_string())
|
||||
.stack_size(STREAM_PROVIDER_GEMINI_TEST_STACK_BYTES)
|
||||
.spawn(move || {
|
||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("test runtime should build");
|
||||
runtime.block_on(make_future());
|
||||
})
|
||||
.expect("stream provider gemini test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
mod local_chat;
|
||||
mod local_cli;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use super::{
|
||||
any, build_router_with_state, build_state_with_execution_runtime_override, json, start_server,
|
||||
to_bytes, Arc, Body, Json, Mutex, Request, Router, StatusCode,
|
||||
to_bytes, wait_until, Arc, Body, Json, Mutex, Request, Router, StatusCode,
|
||||
EXECUTION_PATH_EXECUTION_RUNTIME_SYNC, EXECUTION_PATH_HEADER, TRACE_ID_HEADER,
|
||||
};
|
||||
use crate::constants::{
|
||||
EXECUTION_PATH_LOCAL_API_KEY_CONCURRENCY_LIMITED, LOCAL_EXECUTION_RUNTIME_MISS_REASON_HEADER,
|
||||
};
|
||||
use crate::constants::LOCAL_EXECUTION_RUNTIME_MISS_REASON_HEADER;
|
||||
use aether_crypto::{encrypt_python_fernet_plaintext, DEVELOPMENT_ENCRYPTION_KEY};
|
||||
use aether_data::repository::auth::{
|
||||
InMemoryAuthApiKeySnapshotRepository, StoredAuthApiKeySnapshot,
|
||||
@@ -780,6 +778,7 @@ async fn gateway_waits_for_api_key_concurrency_slot_then_executes_openai_respons
|
||||
"auth_context": {
|
||||
"user_id": "user-openai-cli-local-limit-123",
|
||||
"api_key_id": "key-openai-cli-local-limit-123",
|
||||
"api_key_concurrent_limit": 1,
|
||||
"access_allowed": true
|
||||
},
|
||||
"public_path": "/v1/responses"
|
||||
@@ -969,15 +968,15 @@ async fn gateway_waits_for_api_key_concurrency_slot_then_executes_openai_respons
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gateway_returns_concurrency_limited_after_wait_budget_expires_for_openai_responses_sync() {
|
||||
fn gateway_executes_openai_responses_sync_after_api_key_concurrency_wait_budget_elapses() {
|
||||
run_cli_sync_test(
|
||||
"gateway_returns_concurrency_limited_after_wait_budget_expires_for_openai_responses_sync",
|
||||
gateway_returns_concurrency_limited_after_wait_budget_expires_for_openai_responses_sync_impl,
|
||||
"gateway_executes_openai_responses_sync_after_api_key_concurrency_wait_budget_elapses",
|
||||
gateway_executes_openai_responses_sync_after_api_key_concurrency_wait_budget_elapses_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_returns_concurrency_limited_after_wait_budget_expires_for_openai_responses_sync_impl(
|
||||
) {
|
||||
async fn gateway_executes_openai_responses_sync_after_api_key_concurrency_wait_budget_elapses_impl()
|
||||
{
|
||||
fn hash_api_key(value: &str) -> String {
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(value.as_bytes());
|
||||
@@ -1126,36 +1125,7 @@ async fn gateway_returns_concurrency_limited_after_wait_budget_expires_for_opena
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let public_hits = Arc::new(Mutex::new(0usize));
|
||||
let public_hits_clone = Arc::clone(&public_hits);
|
||||
let now_unix_ms = chrono::Utc::now().timestamp_millis().max(0);
|
||||
let request_candidate_repository = Arc::new(InMemoryRequestCandidateRepository::seed(vec![
|
||||
aether_data_contracts::repository::candidates::StoredRequestCandidate::new(
|
||||
"cand-pending-openai-cli-local-timeout-1".to_string(),
|
||||
"req-inflight-openai-cli-local-timeout-1".to_string(),
|
||||
Some("user-openai-cli-local-timeout-123".to_string()),
|
||||
Some("key-openai-cli-local-timeout-123".to_string()),
|
||||
Some("alice".to_string()),
|
||||
Some("default".to_string()),
|
||||
0,
|
||||
0,
|
||||
Some("provider-openai-cli-local-timeout-1".to_string()),
|
||||
Some("endpoint-openai-cli-local-timeout-1".to_string()),
|
||||
Some("key-openai-cli-local-timeout-1".to_string()),
|
||||
RequestCandidateStatus::Pending,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
now_unix_ms,
|
||||
Some(now_unix_ms),
|
||||
None,
|
||||
)
|
||||
.expect("pending candidate should build"),
|
||||
]));
|
||||
let request_candidate_repository = Arc::new(InMemoryRequestCandidateRepository::default());
|
||||
|
||||
let upstream = Router::new()
|
||||
.route(
|
||||
@@ -1171,6 +1141,7 @@ async fn gateway_returns_concurrency_limited_after_wait_budget_expires_for_opena
|
||||
"auth_context": {
|
||||
"user_id": "user-openai-cli-local-timeout-123",
|
||||
"api_key_id": "key-openai-cli-local-timeout-123",
|
||||
"api_key_concurrent_limit": 1,
|
||||
"access_allowed": true
|
||||
},
|
||||
"public_path": "/v1/responses"
|
||||
@@ -1204,6 +1175,7 @@ async fn gateway_returns_concurrency_limited_after_wait_budget_expires_for_opena
|
||||
*execution_runtime_hits_inner
|
||||
.lock()
|
||||
.expect("mutex should lock") += 1;
|
||||
tokio::time::sleep(std::time::Duration::from_millis(300)).await;
|
||||
Json(json!({
|
||||
"request_id": "trace-openai-cli-local-timeout-123",
|
||||
"status_code": 200,
|
||||
@@ -1265,8 +1237,51 @@ async fn gateway_returns_concurrency_limited_after_wait_budget_expires_for_opena
|
||||
let gateway = build_router_with_state(gateway_state);
|
||||
let (gateway_url, gateway_handle) = start_server(gateway).await;
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let first_client = client.clone();
|
||||
let first_gateway_url = gateway_url.clone();
|
||||
let first_request = tokio::spawn(async move {
|
||||
first_client
|
||||
.post(format!("{first_gateway_url}/v1/responses"))
|
||||
.header(http::header::CONTENT_TYPE, "application/json")
|
||||
.header(
|
||||
http::header::AUTHORIZATION,
|
||||
"Bearer sk-client-openai-cli-local-timeout",
|
||||
)
|
||||
.header(
|
||||
TRACE_ID_HEADER,
|
||||
"trace-openai-cli-local-timeout-inflight-123",
|
||||
)
|
||||
.body("{\"model\":\"gpt-5\",\"input\":\"first\",\"store\":false}")
|
||||
.send()
|
||||
.await
|
||||
.expect("inflight request should complete")
|
||||
});
|
||||
wait_until(1_000, || {
|
||||
*execution_runtime_hits.lock().expect("mutex should lock") >= 1
|
||||
})
|
||||
.await;
|
||||
let pending_deadline = tokio::time::Instant::now() + std::time::Duration::from_millis(1_000);
|
||||
loop {
|
||||
let inflight_candidates = request_candidate_repository
|
||||
.list_by_request_id("trace-openai-cli-local-timeout-inflight-123")
|
||||
.await
|
||||
.expect("inflight request candidate trace should read");
|
||||
if inflight_candidates
|
||||
.iter()
|
||||
.any(|candidate| candidate.status == RequestCandidateStatus::Pending)
|
||||
{
|
||||
break;
|
||||
}
|
||||
assert!(
|
||||
tokio::time::Instant::now() < pending_deadline,
|
||||
"inflight request candidate did not become pending"
|
||||
);
|
||||
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
|
||||
}
|
||||
|
||||
let started_at = std::time::Instant::now();
|
||||
let response = reqwest::Client::new()
|
||||
let response = client
|
||||
.post(format!("{gateway_url}/v1/responses"))
|
||||
.header(http::header::CONTENT_TYPE, "application/json")
|
||||
.header(
|
||||
@@ -1281,44 +1296,40 @@ async fn gateway_returns_concurrency_limited_after_wait_budget_expires_for_opena
|
||||
|
||||
assert!(
|
||||
started_at.elapsed() >= std::time::Duration::from_millis(100),
|
||||
"request should wait for the bounded concurrency window before failing"
|
||||
"request should wait for the bounded concurrency window before retrying"
|
||||
);
|
||||
assert_eq!(response.status(), StatusCode::SERVICE_UNAVAILABLE);
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
assert_eq!(
|
||||
response
|
||||
.headers()
|
||||
.get(EXECUTION_PATH_HEADER)
|
||||
.and_then(|value| value.to_str().ok()),
|
||||
Some(EXECUTION_PATH_LOCAL_API_KEY_CONCURRENCY_LIMITED)
|
||||
Some(EXECUTION_PATH_EXECUTION_RUNTIME_SYNC)
|
||||
);
|
||||
assert_eq!(
|
||||
response
|
||||
.headers()
|
||||
.get(LOCAL_EXECUTION_RUNTIME_MISS_REASON_HEADER)
|
||||
.and_then(|value| value.to_str().ok()),
|
||||
Some("auth_api_key_concurrency_limit_reached")
|
||||
None
|
||||
);
|
||||
let payload: serde_json::Value = response.json().await.expect("body should parse");
|
||||
assert_eq!(
|
||||
payload["error"]["message"],
|
||||
serde_json::Value::String("当前调用方 API Key 并发请求数已达上限,请稍后重试".to_string())
|
||||
);
|
||||
assert_eq!(payload["model"], "gpt-5-upstream");
|
||||
|
||||
let stored_candidates = request_candidate_repository
|
||||
.list_by_request_id("trace-openai-cli-local-timeout-123")
|
||||
.await
|
||||
.expect("request candidate trace should read");
|
||||
assert_eq!(stored_candidates.len(), 1);
|
||||
assert_eq!(stored_candidates[0].status, RequestCandidateStatus::Skipped);
|
||||
assert_eq!(
|
||||
stored_candidates[0].skip_reason.as_deref(),
|
||||
Some("auth_api_key_concurrency_limit_reached")
|
||||
);
|
||||
assert_eq!(stored_candidates[0].status, RequestCandidateStatus::Success);
|
||||
assert_eq!(stored_candidates[0].skip_reason.as_deref(), None);
|
||||
assert_eq!(
|
||||
*execution_runtime_hits.lock().expect("mutex should lock"),
|
||||
0
|
||||
2
|
||||
);
|
||||
assert_eq!(*public_hits.lock().expect("mutex should lock"), 0);
|
||||
let first_response = first_request.await.expect("inflight request should join");
|
||||
assert_eq!(first_response.status(), StatusCode::OK);
|
||||
|
||||
gateway_handle.abort();
|
||||
execution_runtime_handle.abort();
|
||||
|
||||
@@ -43,8 +43,15 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_converts_openai_image_sync_to_gemini_image_provider() {
|
||||
#[test]
|
||||
fn gateway_converts_openai_image_sync_to_gemini_image_provider() {
|
||||
run_image_sync_test(
|
||||
"gateway_converts_openai_image_sync_to_gemini_image_provider",
|
||||
gateway_converts_openai_image_sync_to_gemini_image_provider_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_converts_openai_image_sync_to_gemini_image_provider_impl() {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeSyncRequest {
|
||||
trace_id: String,
|
||||
@@ -765,8 +772,15 @@ async fn gateway_converts_gemini_image_sync_to_openai_image_provider_impl() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_executes_codex_image_sync_via_local_decision_gate_after_oauth_refresh() {
|
||||
#[test]
|
||||
fn gateway_executes_codex_image_sync_via_local_decision_gate_after_oauth_refresh() {
|
||||
run_image_sync_test(
|
||||
"gateway_executes_codex_image_sync_via_local_decision_gate_after_oauth_refresh",
|
||||
gateway_executes_codex_image_sync_via_local_decision_gate_after_oauth_refresh_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_executes_codex_image_sync_via_local_decision_gate_after_oauth_refresh_impl() {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeSyncRequest {
|
||||
trace_id: String,
|
||||
@@ -1271,8 +1285,15 @@ async fn gateway_executes_codex_image_sync_via_local_decision_gate_after_oauth_r
|
||||
refresh_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_plans_chatgpt_web_image_sync_with_internal_web_executor_url() {
|
||||
#[test]
|
||||
fn gateway_plans_chatgpt_web_image_sync_with_internal_web_executor_url() {
|
||||
run_image_sync_test(
|
||||
"gateway_plans_chatgpt_web_image_sync_with_internal_web_executor_url",
|
||||
gateway_plans_chatgpt_web_image_sync_with_internal_web_executor_url_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_plans_chatgpt_web_image_sync_with_internal_web_executor_url_impl() {
|
||||
#[derive(Debug, Clone)]
|
||||
struct SeenExecutionRuntimeSyncRequest {
|
||||
trace_id: String,
|
||||
|
||||
Reference in New Issue
Block a user