mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-05 00:47:48 +08:00
Improve gateway transport and usage runtime
This commit is contained in:
@@ -27,6 +27,30 @@ use crate::constants::{
|
||||
};
|
||||
use crate::data::GatewayDataState;
|
||||
|
||||
const PROVIDER_KEYS_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_provider_keys_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(PROVIDER_KEYS_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("provider keys test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
struct SummaryNullingProviderCatalogReadRepository {
|
||||
inner: InMemoryProviderCatalogReadRepository,
|
||||
}
|
||||
@@ -879,8 +903,15 @@ async fn provider_key_concurrent_limit_reads_existing_list_response() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_fetches_allowed_models_immediately_when_creating_key_with_auto_fetch() {
|
||||
#[test]
|
||||
fn gateway_fetches_allowed_models_immediately_when_creating_key_with_auto_fetch() {
|
||||
run_provider_keys_test(
|
||||
"gateway_fetches_allowed_models_immediately_when_creating_key_with_auto_fetch",
|
||||
gateway_fetches_allowed_models_immediately_when_creating_key_with_auto_fetch_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_fetches_allowed_models_immediately_when_creating_key_with_auto_fetch_impl() {
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -1759,8 +1790,15 @@ async fn provider_key_concurrent_limit_update_presence_semantics() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_clears_allowed_models_when_disabling_auto_fetch_on_provider_key_update() {
|
||||
#[test]
|
||||
fn gateway_clears_allowed_models_when_disabling_auto_fetch_on_provider_key_update() {
|
||||
run_provider_keys_test(
|
||||
"gateway_clears_allowed_models_when_disabling_auto_fetch_on_provider_key_update",
|
||||
gateway_clears_allowed_models_when_disabling_auto_fetch_on_provider_key_update_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_clears_allowed_models_when_disabling_auto_fetch_on_provider_key_update_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -1835,8 +1873,15 @@ async fn gateway_clears_allowed_models_when_disabling_auto_fetch_on_provider_key
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_overwrites_allowed_models_immediately_when_enabling_auto_fetch() {
|
||||
#[test]
|
||||
fn gateway_overwrites_allowed_models_immediately_when_enabling_auto_fetch() {
|
||||
run_provider_keys_test(
|
||||
"gateway_overwrites_allowed_models_immediately_when_enabling_auto_fetch",
|
||||
gateway_overwrites_allowed_models_immediately_when_enabling_auto_fetch_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_overwrites_allowed_models_immediately_when_enabling_auto_fetch_impl() {
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -1948,8 +1993,16 @@ async fn gateway_overwrites_allowed_models_immediately_when_enabling_auto_fetch(
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_fetches_allowed_models_immediately_when_enabling_auto_fetch_from_empty_state() {
|
||||
#[test]
|
||||
fn gateway_fetches_allowed_models_immediately_when_enabling_auto_fetch_from_empty_state() {
|
||||
run_provider_keys_test(
|
||||
"gateway_fetches_allowed_models_immediately_when_enabling_auto_fetch_from_empty_state",
|
||||
gateway_fetches_allowed_models_immediately_when_enabling_auto_fetch_from_empty_state_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_fetches_allowed_models_immediately_when_enabling_auto_fetch_from_empty_state_impl()
|
||||
{
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -2054,8 +2107,16 @@ async fn gateway_fetches_allowed_models_immediately_when_enabling_auto_fetch_fro
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_refreshes_allowed_models_when_updating_include_patterns_with_auto_fetch_enabled() {
|
||||
#[test]
|
||||
fn gateway_refreshes_allowed_models_when_updating_include_patterns_with_auto_fetch_enabled() {
|
||||
run_provider_keys_test(
|
||||
"gateway_refreshes_allowed_models_when_updating_include_patterns_with_auto_fetch_enabled",
|
||||
gateway_refreshes_allowed_models_when_updating_include_patterns_with_auto_fetch_enabled_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_refreshes_allowed_models_when_updating_include_patterns_with_auto_fetch_enabled_impl(
|
||||
) {
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -2158,8 +2219,16 @@ async fn gateway_refreshes_allowed_models_when_updating_include_patterns_with_au
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_refreshes_allowed_models_when_updating_exclude_patterns_with_auto_fetch_enabled() {
|
||||
#[test]
|
||||
fn gateway_refreshes_allowed_models_when_updating_exclude_patterns_with_auto_fetch_enabled() {
|
||||
run_provider_keys_test(
|
||||
"gateway_refreshes_allowed_models_when_updating_exclude_patterns_with_auto_fetch_enabled",
|
||||
gateway_refreshes_allowed_models_when_updating_exclude_patterns_with_auto_fetch_enabled_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_refreshes_allowed_models_when_updating_exclude_patterns_with_auto_fetch_enabled_impl(
|
||||
) {
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let execution_runtime = Router::new().route(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,16 +32,16 @@ use crate::constants::{
|
||||
};
|
||||
use crate::data::{GatewayDataConfig, GatewayDataState};
|
||||
|
||||
const SUB2API_PROVIDER_OPS_BALANCE_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
const PROVIDER_OPS_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_sub2api_provider_ops_balance_test<F, Fut>(test_name: &'static str, make_future: F)
|
||||
fn run_provider_ops_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(SUB2API_PROVIDER_OPS_BALANCE_TEST_STACK_BYTES)
|
||||
.stack_size(PROVIDER_OPS_TEST_STACK_BYTES)
|
||||
.spawn(move || {
|
||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
@@ -49,7 +49,7 @@ where
|
||||
.expect("test runtime should build");
|
||||
runtime.block_on(make_future());
|
||||
})
|
||||
.expect("sub2api provider ops balance test thread should spawn");
|
||||
.expect("provider ops test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
@@ -117,8 +117,16 @@ fn assert_provider_ops_architectures_payload(payload: &serde_json::Value) {
|
||||
assert_eq!(new_api["supported_auth_types"][0]["type"], "api_key");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_architectures_locally_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_architectures_locally_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_architectures_locally_with_trusted_admin_principal",
|
||||
gateway_handles_admin_provider_ops_architectures_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_architectures_locally_with_trusted_admin_principal_impl(
|
||||
) {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -157,8 +165,15 @@ async fn gateway_handles_admin_provider_ops_architectures_locally_with_trusted_a
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_architectures_locally_with_bearer_admin_session() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_architectures_locally_with_bearer_admin_session() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_architectures_locally_with_bearer_admin_session",
|
||||
gateway_handles_admin_provider_ops_architectures_locally_with_bearer_admin_session_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_architectures_locally_with_bearer_admin_session_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -197,8 +212,15 @@ async fn gateway_handles_admin_provider_ops_architectures_locally_with_bearer_ad
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_architecture_detail_locally_with_trusted_admin_principal(
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_architecture_detail_locally_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_architecture_detail_locally_with_trusted_admin_principal",
|
||||
gateway_handles_admin_provider_ops_architecture_detail_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_architecture_detail_locally_with_trusted_admin_principal_impl(
|
||||
) {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
@@ -241,8 +263,15 @@ async fn gateway_handles_admin_provider_ops_architecture_detail_locally_with_tru
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_status_locally_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_status_locally_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_status_locally_with_trusted_admin_principal",
|
||||
gateway_handles_admin_provider_ops_status_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_status_locally_with_trusted_admin_principal_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -328,8 +357,15 @@ async fn gateway_handles_admin_provider_ops_status_locally_with_trusted_admin_pr
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_config_locally_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_config_locally_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_config_locally_with_trusted_admin_principal",
|
||||
gateway_handles_admin_provider_ops_config_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_config_locally_with_trusted_admin_principal_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -427,8 +463,15 @@ async fn gateway_handles_admin_provider_ops_config_locally_with_trusted_admin_pr
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_saves_admin_provider_ops_config_locally_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_saves_admin_provider_ops_config_locally_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_saves_admin_provider_ops_config_locally_with_trusted_admin_principal",
|
||||
gateway_saves_admin_provider_ops_config_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_saves_admin_provider_ops_config_locally_with_trusted_admin_principal_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -592,8 +635,15 @@ async fn gateway_saves_admin_provider_ops_config_locally_with_trusted_admin_prin
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_deletes_admin_provider_ops_config_locally_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_deletes_admin_provider_ops_config_locally_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_deletes_admin_provider_ops_config_locally_with_trusted_admin_principal",
|
||||
gateway_deletes_admin_provider_ops_config_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_deletes_admin_provider_ops_config_locally_with_trusted_admin_principal_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -688,8 +738,15 @@ async fn gateway_deletes_admin_provider_ops_config_locally_with_trusted_admin_pr
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_disconnects_admin_provider_ops_locally_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_disconnects_admin_provider_ops_locally_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_disconnects_admin_provider_ops_locally_with_trusted_admin_principal",
|
||||
gateway_disconnects_admin_provider_ops_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_disconnects_admin_provider_ops_locally_with_trusted_admin_principal_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -729,9 +786,16 @@ async fn gateway_disconnects_admin_provider_ops_locally_with_trusted_admin_princ
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_generic_api_with_trusted_admin_principal()
|
||||
{
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_locally_for_generic_api_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_locally_for_generic_api_with_trusted_admin_principal",
|
||||
gateway_verifies_admin_provider_ops_locally_for_generic_api_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_generic_api_with_trusted_admin_principal_impl(
|
||||
) {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -830,8 +894,16 @@ async fn gateway_verifies_admin_provider_ops_locally_for_generic_api_with_truste
|
||||
verify_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_locally_for_anyrouter_with_trusted_admin_principal",
|
||||
gateway_verifies_admin_provider_ops_locally_for_anyrouter_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_with_trusted_admin_principal_impl(
|
||||
) {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -961,8 +1033,15 @@ async fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_with_trusted_
|
||||
verify_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_with_cookie_auth_failure_message(
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_with_cookie_auth_failure_message() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_locally_for_anyrouter_with_cookie_auth_failure_message",
|
||||
gateway_verifies_admin_provider_ops_locally_for_anyrouter_with_cookie_auth_failure_message_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_with_cookie_auth_failure_message_impl(
|
||||
) {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
@@ -1052,8 +1131,16 @@ async fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_with_cookie_a
|
||||
verify_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_when_acw_redirect_body_contains_arg1(
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_when_acw_redirect_body_contains_arg1()
|
||||
{
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_locally_for_anyrouter_when_acw_redirect_body_contains_arg1",
|
||||
gateway_verifies_admin_provider_ops_locally_for_anyrouter_when_acw_redirect_body_contains_arg1_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_when_acw_redirect_body_contains_arg1_impl(
|
||||
) {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
@@ -1177,8 +1264,15 @@ async fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_when_acw_redi
|
||||
verify_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_proxy_mode() {
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_proxy_mode() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_locally_for_anyrouter_proxy_mode",
|
||||
gateway_verifies_admin_provider_ops_locally_for_anyrouter_proxy_mode_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_proxy_mode_impl() {
|
||||
let execution_plans = Arc::new(Mutex::new(Vec::<ExecutionPlan>::new()));
|
||||
let execution_plans_clone = Arc::clone(&execution_plans);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -1327,8 +1421,16 @@ async fn gateway_verifies_admin_provider_ops_locally_for_anyrouter_proxy_mode()
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_sub2api_proxy_mode_via_execution_runtime_http1_only() {
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_sub2api_proxy_mode_via_execution_runtime_http1_only() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_sub2api_proxy_mode_via_execution_runtime_http1_only",
|
||||
gateway_verifies_admin_provider_ops_sub2api_proxy_mode_via_execution_runtime_http1_only_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_sub2api_proxy_mode_via_execution_runtime_http1_only_impl(
|
||||
) {
|
||||
let execution_plans = Arc::new(Mutex::new(Vec::<ExecutionPlan>::new()));
|
||||
let execution_plans_clone = Arc::clone(&execution_plans);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -1475,8 +1577,16 @@ async fn gateway_verifies_admin_provider_ops_sub2api_proxy_mode_via_execution_ru
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_new_api_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_locally_for_new_api_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_locally_for_new_api_with_trusted_admin_principal",
|
||||
gateway_verifies_admin_provider_ops_locally_for_new_api_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_new_api_with_trusted_admin_principal_impl()
|
||||
{
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -1616,8 +1726,15 @@ async fn gateway_verifies_admin_provider_ops_locally_for_new_api_with_trusted_ad
|
||||
verify_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_new_api_proxy_node_mode() {
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_locally_for_new_api_proxy_node_mode() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_locally_for_new_api_proxy_node_mode",
|
||||
gateway_verifies_admin_provider_ops_locally_for_new_api_proxy_node_mode_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_new_api_proxy_node_mode_impl() {
|
||||
let execution_plans = Arc::new(Mutex::new(Vec::<ExecutionPlan>::new()));
|
||||
let execution_plans_clone = Arc::clone(&execution_plans);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -1741,8 +1858,15 @@ async fn gateway_verifies_admin_provider_ops_locally_for_new_api_proxy_node_mode
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_new_api_without_proxy_via_execution_runtime(
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_locally_for_new_api_without_proxy_via_execution_runtime() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_locally_for_new_api_without_proxy_via_execution_runtime",
|
||||
gateway_verifies_admin_provider_ops_locally_for_new_api_without_proxy_via_execution_runtime_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_new_api_without_proxy_via_execution_runtime_impl(
|
||||
) {
|
||||
let execution_plans = Arc::new(Mutex::new(Vec::<ExecutionPlan>::new()));
|
||||
let execution_plans_clone = Arc::clone(&execution_plans);
|
||||
@@ -1844,8 +1968,16 @@ async fn gateway_verifies_admin_provider_ops_locally_for_new_api_without_proxy_v
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_sub2api_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_locally_for_sub2api_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_locally_for_sub2api_with_trusted_admin_principal",
|
||||
gateway_verifies_admin_provider_ops_locally_for_sub2api_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_locally_for_sub2api_with_trusted_admin_principal_impl()
|
||||
{
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -1974,8 +2106,16 @@ async fn gateway_verifies_admin_provider_ops_locally_for_sub2api_with_trusted_ad
|
||||
verify_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_sub2api_against_site_root_when_base_url_has_path() {
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_sub2api_against_site_root_when_base_url_has_path() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_sub2api_against_site_root_when_base_url_has_path",
|
||||
gateway_verifies_admin_provider_ops_sub2api_against_site_root_when_base_url_has_path_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_sub2api_against_site_root_when_base_url_has_path_impl()
|
||||
{
|
||||
let nested_refresh_hits = Arc::new(Mutex::new(0usize));
|
||||
let nested_refresh_hits_clone = Arc::clone(&nested_refresh_hits);
|
||||
let root_refresh_hits = Arc::new(Mutex::new(0usize));
|
||||
@@ -2104,8 +2244,16 @@ async fn gateway_verifies_admin_provider_ops_sub2api_against_site_root_when_base
|
||||
verify_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_sub2api_with_cached_access_token_without_refresh() {
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_sub2api_with_cached_access_token_without_refresh() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_sub2api_with_cached_access_token_without_refresh",
|
||||
gateway_verifies_admin_provider_ops_sub2api_with_cached_access_token_without_refresh_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_sub2api_with_cached_access_token_without_refresh_impl()
|
||||
{
|
||||
let refresh_hits = Arc::new(Mutex::new(0usize));
|
||||
let refresh_hits_clone = Arc::clone(&refresh_hits);
|
||||
let ops = Router::new()
|
||||
@@ -2233,8 +2381,15 @@ async fn gateway_verifies_admin_provider_ops_sub2api_with_cached_access_token_wi
|
||||
ops_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verifies_admin_provider_ops_sub2api_persists_rotated_runtime_credentials() {
|
||||
#[test]
|
||||
fn gateway_verifies_admin_provider_ops_sub2api_persists_rotated_runtime_credentials() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verifies_admin_provider_ops_sub2api_persists_rotated_runtime_credentials",
|
||||
gateway_verifies_admin_provider_ops_sub2api_persists_rotated_runtime_credentials_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verifies_admin_provider_ops_sub2api_persists_rotated_runtime_credentials_impl() {
|
||||
let ops = Router::new()
|
||||
.route(
|
||||
"/api/v1/auth/refresh",
|
||||
@@ -2409,8 +2564,15 @@ async fn gateway_verifies_admin_provider_ops_sub2api_persists_rotated_runtime_cr
|
||||
ops_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_rejects_admin_provider_ops_connect_locally_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_rejects_admin_provider_ops_connect_locally_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_rejects_admin_provider_ops_connect_locally_with_trusted_admin_principal",
|
||||
gateway_rejects_admin_provider_ops_connect_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_rejects_admin_provider_ops_connect_locally_with_trusted_admin_principal_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -2493,8 +2655,15 @@ async fn gateway_rejects_admin_provider_ops_connect_locally_with_trusted_admin_p
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_balance_locally_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_balance_locally_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_balance_locally_with_trusted_admin_principal",
|
||||
gateway_handles_admin_provider_ops_balance_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_balance_locally_with_trusted_admin_principal_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -2624,8 +2793,15 @@ async fn gateway_handles_admin_provider_ops_balance_locally_with_trusted_admin_p
|
||||
ops_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_balance_locally_for_generic_api_proxy_node_mode() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_balance_locally_for_generic_api_proxy_node_mode() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_balance_locally_for_generic_api_proxy_node_mode",
|
||||
gateway_handles_admin_provider_ops_balance_locally_for_generic_api_proxy_node_mode_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_balance_locally_for_generic_api_proxy_node_mode_impl() {
|
||||
let execution_plans = Arc::new(Mutex::new(Vec::<ExecutionPlan>::new()));
|
||||
let execution_plans_clone = Arc::clone(&execution_plans);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -2774,8 +2950,16 @@ async fn gateway_handles_admin_provider_ops_balance_locally_for_generic_api_prox
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_balance_locally_without_proxy_via_execution_runtime() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_balance_locally_without_proxy_via_execution_runtime() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_balance_locally_without_proxy_via_execution_runtime",
|
||||
gateway_handles_admin_provider_ops_balance_locally_without_proxy_via_execution_runtime_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_balance_locally_without_proxy_via_execution_runtime_impl(
|
||||
) {
|
||||
let execution_plans = Arc::new(Mutex::new(Vec::<ExecutionPlan>::new()));
|
||||
let execution_plans_clone = Arc::clone(&execution_plans);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -2913,8 +3097,15 @@ async fn gateway_handles_admin_provider_ops_balance_locally_without_proxy_via_ex
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_checkin_locally_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_checkin_locally_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_checkin_locally_with_trusted_admin_principal",
|
||||
gateway_handles_admin_provider_ops_checkin_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_checkin_locally_with_trusted_admin_principal_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -3025,8 +3216,15 @@ async fn gateway_handles_admin_provider_ops_checkin_locally_with_trusted_admin_p
|
||||
ops_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_checkin_locally_for_generic_api_proxy_node_mode() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_checkin_locally_for_generic_api_proxy_node_mode() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_checkin_locally_for_generic_api_proxy_node_mode",
|
||||
gateway_handles_admin_provider_ops_checkin_locally_for_generic_api_proxy_node_mode_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_checkin_locally_for_generic_api_proxy_node_mode_impl() {
|
||||
let execution_plans = Arc::new(Mutex::new(Vec::<ExecutionPlan>::new()));
|
||||
let execution_plans_clone = Arc::clone(&execution_plans);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -3150,8 +3348,16 @@ async fn gateway_handles_admin_provider_ops_checkin_locally_for_generic_api_prox
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_batch_balance_locally_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_batch_balance_locally_with_trusted_admin_principal() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_batch_balance_locally_with_trusted_admin_principal",
|
||||
gateway_handles_admin_provider_ops_batch_balance_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_batch_balance_locally_with_trusted_admin_principal_impl(
|
||||
) {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -3387,8 +3593,15 @@ async fn gateway_handles_admin_provider_ops_batch_balance_locally_with_trusted_a
|
||||
ops_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_anyrouter_balance_with_auth_expired_cookie() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_anyrouter_balance_with_auth_expired_cookie() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_anyrouter_balance_with_auth_expired_cookie",
|
||||
gateway_handles_admin_provider_ops_anyrouter_balance_with_auth_expired_cookie_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_anyrouter_balance_with_auth_expired_cookie_impl() {
|
||||
let ops = Router::new()
|
||||
.route(
|
||||
"/",
|
||||
@@ -3519,8 +3732,15 @@ async fn gateway_handles_admin_provider_ops_anyrouter_balance_with_auth_expired_
|
||||
ops_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_balance_cache_refresh_modes_with_redis() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_balance_cache_refresh_modes_with_redis() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_balance_cache_refresh_modes_with_redis",
|
||||
gateway_handles_admin_provider_ops_balance_cache_refresh_modes_with_redis_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_balance_cache_refresh_modes_with_redis_impl() {
|
||||
let Some(redis) = start_managed_redis_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
@@ -3672,8 +3892,16 @@ async fn gateway_handles_admin_provider_ops_balance_cache_refresh_modes_with_red
|
||||
ops_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_balance_cache_miss_without_refresh_returns_live_payload_once_with_redis(
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_balance_cache_miss_without_refresh_returns_live_payload_once_with_redis(
|
||||
) {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_balance_cache_miss_without_refresh_returns_live_payload_once_with_redis",
|
||||
gateway_handles_admin_provider_ops_balance_cache_miss_without_refresh_returns_live_payload_once_with_redis_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_balance_cache_miss_without_refresh_returns_live_payload_once_with_redis_impl(
|
||||
) {
|
||||
let Some(redis) = start_managed_redis_or_skip().await else {
|
||||
return;
|
||||
@@ -3801,8 +4029,15 @@ async fn gateway_handles_admin_provider_ops_balance_cache_miss_without_refresh_r
|
||||
ops_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_clears_admin_provider_ops_balance_cache_after_config_save_with_redis() {
|
||||
#[test]
|
||||
fn gateway_clears_admin_provider_ops_balance_cache_after_config_save_with_redis() {
|
||||
run_provider_ops_test(
|
||||
"gateway_clears_admin_provider_ops_balance_cache_after_config_save_with_redis",
|
||||
gateway_clears_admin_provider_ops_balance_cache_after_config_save_with_redis_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_clears_admin_provider_ops_balance_cache_after_config_save_with_redis_impl() {
|
||||
let Some(redis) = start_managed_redis_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
@@ -3989,8 +4224,15 @@ async fn gateway_clears_admin_provider_ops_balance_cache_after_config_save_with_
|
||||
ops_v2_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_verify_does_not_pollute_balance_cache_and_balance_uses_saved_action_config() {
|
||||
#[test]
|
||||
fn gateway_verify_does_not_pollute_balance_cache_and_balance_uses_saved_action_config() {
|
||||
run_provider_ops_test(
|
||||
"gateway_verify_does_not_pollute_balance_cache_and_balance_uses_saved_action_config",
|
||||
gateway_verify_does_not_pollute_balance_cache_and_balance_uses_saved_action_config_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_verify_does_not_pollute_balance_cache_and_balance_uses_saved_action_config_impl() {
|
||||
let Some(redis) = start_managed_redis_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
@@ -4222,8 +4464,15 @@ async fn gateway_verify_does_not_pollute_balance_cache_and_balance_uses_saved_ac
|
||||
verify_ops_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_ops_batch_balance_with_pending_cache_hits_and_redis() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_batch_balance_with_pending_cache_hits_and_redis() {
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_batch_balance_with_pending_cache_hits_and_redis",
|
||||
gateway_handles_admin_provider_ops_batch_balance_with_pending_cache_hits_and_redis_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_ops_batch_balance_with_pending_cache_hits_and_redis_impl() {
|
||||
let Some(redis) = start_managed_redis_or_skip().await else {
|
||||
return;
|
||||
};
|
||||
@@ -4354,7 +4603,7 @@ async fn gateway_handles_admin_provider_ops_batch_balance_with_pending_cache_hit
|
||||
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_sub2api_balance_with_refresh_token_rotation() {
|
||||
run_sub2api_provider_ops_balance_test(
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_sub2api_balance_with_refresh_token_rotation",
|
||||
gateway_handles_admin_provider_ops_sub2api_balance_with_refresh_token_rotation_impl,
|
||||
);
|
||||
@@ -4566,7 +4815,7 @@ async fn gateway_handles_admin_provider_ops_sub2api_balance_with_refresh_token_r
|
||||
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_sub2api_balance_against_site_root_when_base_url_has_path() {
|
||||
run_sub2api_provider_ops_balance_test(
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_sub2api_balance_against_site_root_when_base_url_has_path",
|
||||
gateway_handles_admin_provider_ops_sub2api_balance_against_site_root_when_base_url_has_path_impl,
|
||||
);
|
||||
@@ -4782,7 +5031,7 @@ async fn gateway_handles_admin_provider_ops_sub2api_balance_against_site_root_wh
|
||||
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_ops_sub2api_balance_with_session_login() {
|
||||
run_sub2api_provider_ops_balance_test(
|
||||
run_provider_ops_test(
|
||||
"gateway_handles_admin_provider_ops_sub2api_balance_with_session_login",
|
||||
gateway_handles_admin_provider_ops_sub2api_balance_with_session_login_impl,
|
||||
);
|
||||
|
||||
@@ -29,6 +29,30 @@ use crate::constants::{
|
||||
};
|
||||
use crate::data::GatewayDataState;
|
||||
|
||||
const PROVIDER_QUERY_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_provider_query_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(PROVIDER_QUERY_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("provider query test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
fn crc32(data: &[u8]) -> u32 {
|
||||
let mut crc = 0xffff_ffffu32;
|
||||
for &byte in data {
|
||||
@@ -122,8 +146,15 @@ async fn assert_admin_provider_query_route(
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_models_fetches_upstream_for_selected_key() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_models_fetches_upstream_for_selected_key() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_models_fetches_upstream_for_selected_key",
|
||||
gateway_handles_admin_provider_query_models_fetches_upstream_for_selected_key_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_models_fetches_upstream_for_selected_key_impl() {
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -244,8 +275,15 @@ async fn gateway_handles_admin_provider_query_models_fetches_upstream_for_select
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_models_fetches_windsurf_model_configs() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_models_fetches_windsurf_model_configs() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_models_fetches_windsurf_model_configs",
|
||||
gateway_handles_admin_provider_query_models_fetches_windsurf_model_configs_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_models_fetches_windsurf_model_configs_impl() {
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -382,8 +420,15 @@ async fn gateway_handles_admin_provider_query_models_fetches_windsurf_model_conf
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_models_with_openai_responses_endpoint() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_models_with_openai_responses_endpoint() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_models_with_openai_responses_endpoint",
|
||||
gateway_handles_admin_provider_query_models_with_openai_responses_endpoint_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_models_with_openai_responses_endpoint_impl() {
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -492,8 +537,15 @@ async fn gateway_handles_admin_provider_query_models_with_openai_responses_endpo
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_models_falls_back_to_codex_preset_when_token_invalidated(
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_models_falls_back_to_codex_preset_when_token_invalidated() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_models_falls_back_to_codex_preset_when_token_invalidated",
|
||||
gateway_handles_admin_provider_query_models_falls_back_to_codex_preset_when_token_invalidated_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_models_falls_back_to_codex_preset_when_token_invalidated_impl(
|
||||
) {
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
@@ -598,8 +650,15 @@ async fn gateway_handles_admin_provider_query_models_falls_back_to_codex_preset_
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_models_respecting_key_api_formats() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_models_respecting_key_api_formats() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_models_respecting_key_api_formats",
|
||||
gateway_handles_admin_provider_query_models_respecting_key_api_formats_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_models_respecting_key_api_formats_impl() {
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -729,8 +788,15 @@ async fn gateway_handles_admin_provider_query_models_respecting_key_api_formats(
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_models_aggregating_active_keys() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_models_aggregating_active_keys() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_models_aggregating_active_keys",
|
||||
gateway_handles_admin_provider_query_models_aggregating_active_keys_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_models_aggregating_active_keys_impl() {
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -871,8 +937,15 @@ async fn gateway_handles_admin_provider_query_models_aggregating_active_keys() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_models_for_fixed_provider_without_endpoint() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_models_for_fixed_provider_without_endpoint() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_models_for_fixed_provider_without_endpoint",
|
||||
gateway_handles_admin_provider_query_models_for_fixed_provider_without_endpoint_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_models_for_fixed_provider_without_endpoint_impl() {
|
||||
let execution_runtime_hits = Arc::new(Mutex::new(0usize));
|
||||
let execution_runtime_hits_clone = Arc::clone(&execution_runtime_hits);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -946,8 +1019,16 @@ async fn gateway_handles_admin_provider_query_models_for_fixed_provider_without_
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_test_model_locally_with_trusted_admin_principal() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_test_model_locally_with_trusted_admin_principal() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_test_model_locally_with_trusted_admin_principal",
|
||||
gateway_handles_admin_provider_query_test_model_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_test_model_locally_with_trusted_admin_principal_impl()
|
||||
{
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -1056,8 +1137,15 @@ async fn gateway_handles_admin_provider_query_test_model_locally_with_trusted_ad
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_embedding_model_test() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_embedding_model_test() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_embedding_model_test",
|
||||
gateway_handles_admin_provider_query_embedding_model_test_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_embedding_model_test_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -1167,8 +1255,15 @@ async fn gateway_handles_admin_provider_query_embedding_model_test() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_doubao_text_embedding_model_test() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_doubao_text_embedding_model_test() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_doubao_text_embedding_model_test",
|
||||
gateway_handles_admin_provider_query_doubao_text_embedding_model_test_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_doubao_text_embedding_model_test_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -1281,8 +1376,15 @@ async fn gateway_handles_admin_provider_query_doubao_text_embedding_model_test()
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_gemini_embedding_model_test() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_gemini_embedding_model_test() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_gemini_embedding_model_test",
|
||||
gateway_handles_admin_provider_query_gemini_embedding_model_test_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_gemini_embedding_model_test_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -1396,8 +1498,15 @@ async fn gateway_handles_admin_provider_query_gemini_embedding_model_test() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_vertex_gemini_embedding_model_test() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_vertex_gemini_embedding_model_test() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_vertex_gemini_embedding_model_test",
|
||||
gateway_handles_admin_provider_query_vertex_gemini_embedding_model_test_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_vertex_gemini_embedding_model_test_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -1536,8 +1645,15 @@ async fn gateway_handles_admin_provider_query_vertex_gemini_embedding_model_test
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_jina_embedding_model_test() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_jina_embedding_model_test() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_jina_embedding_model_test",
|
||||
gateway_handles_admin_provider_query_jina_embedding_model_test_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_jina_embedding_model_test_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -1647,8 +1763,15 @@ async fn gateway_handles_admin_provider_query_jina_embedding_model_test() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_openai_rerank_model_test() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_openai_rerank_model_test() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_openai_rerank_model_test",
|
||||
gateway_handles_admin_provider_query_openai_rerank_model_test_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_openai_rerank_model_test_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -1765,8 +1888,15 @@ async fn gateway_handles_admin_provider_query_openai_rerank_model_test() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_rerank_model_test() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_rerank_model_test() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_rerank_model_test",
|
||||
gateway_handles_admin_provider_query_rerank_model_test_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_rerank_model_test_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -1886,8 +2016,15 @@ async fn gateway_handles_admin_provider_query_rerank_model_test() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_maps_admin_provider_model_before_model_list_test_request() {
|
||||
#[test]
|
||||
fn gateway_maps_admin_provider_model_before_model_list_test_request() {
|
||||
run_provider_query_test(
|
||||
"gateway_maps_admin_provider_model_before_model_list_test_request",
|
||||
gateway_maps_admin_provider_model_before_model_list_test_request_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_maps_admin_provider_model_before_model_list_test_request_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -2141,8 +2278,15 @@ async fn gateway_maps_admin_provider_model_before_model_list_test_request() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_streams_codex_openai_responses_upstream_for_admin_pool_model_test() {
|
||||
#[test]
|
||||
fn gateway_streams_codex_openai_responses_upstream_for_admin_pool_model_test() {
|
||||
run_provider_query_test(
|
||||
"gateway_streams_codex_openai_responses_upstream_for_admin_pool_model_test",
|
||||
gateway_streams_codex_openai_responses_upstream_for_admin_pool_model_test_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_streams_codex_openai_responses_upstream_for_admin_pool_model_test_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -2247,8 +2391,15 @@ async fn gateway_streams_codex_openai_responses_upstream_for_admin_pool_model_te
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_routes_grok_responses_admin_pool_model_test_through_grok_runtime() {
|
||||
#[test]
|
||||
fn gateway_routes_grok_responses_admin_pool_model_test_through_grok_runtime() {
|
||||
run_provider_query_test(
|
||||
"gateway_routes_grok_responses_admin_pool_model_test_through_grok_runtime",
|
||||
gateway_routes_grok_responses_admin_pool_model_test_through_grok_runtime_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_routes_grok_responses_admin_pool_model_test_through_grok_runtime_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -2385,8 +2536,15 @@ async fn gateway_routes_grok_responses_admin_pool_model_test_through_grok_runtim
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_streams_windsurf_connect_upstream_for_admin_model_test() {
|
||||
#[test]
|
||||
fn gateway_streams_windsurf_connect_upstream_for_admin_model_test() {
|
||||
run_provider_query_test(
|
||||
"gateway_streams_windsurf_connect_upstream_for_admin_model_test",
|
||||
gateway_streams_windsurf_connect_upstream_for_admin_model_test_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_streams_windsurf_connect_upstream_for_admin_model_test_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -2501,8 +2659,15 @@ async fn gateway_streams_windsurf_connect_upstream_for_admin_model_test() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_uses_pool_scheduler_order_for_admin_pool_model_test() {
|
||||
#[test]
|
||||
fn gateway_uses_pool_scheduler_order_for_admin_pool_model_test() {
|
||||
run_provider_query_test(
|
||||
"gateway_uses_pool_scheduler_order_for_admin_pool_model_test",
|
||||
gateway_uses_pool_scheduler_order_for_admin_pool_model_test_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_uses_pool_scheduler_order_for_admin_pool_model_test_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -2649,8 +2814,15 @@ async fn gateway_uses_pool_scheduler_order_for_admin_pool_model_test() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_test_model_failover_locally_with_trusted_admin_principal(
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_test_model_failover_locally_with_trusted_admin_principal() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_test_model_failover_locally_with_trusted_admin_principal",
|
||||
gateway_handles_admin_provider_query_test_model_failover_locally_with_trusted_admin_principal_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_test_model_failover_locally_with_trusted_admin_principal_impl(
|
||||
) {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
@@ -2825,8 +2997,15 @@ async fn gateway_handles_admin_provider_query_test_model_failover_locally_with_t
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_test_model_for_kiro_locally() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_test_model_for_kiro_locally() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_test_model_for_kiro_locally",
|
||||
gateway_handles_admin_provider_query_test_model_for_kiro_locally_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_test_model_for_kiro_locally_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -2949,8 +3128,15 @@ async fn gateway_handles_admin_provider_query_test_model_for_kiro_locally() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_uses_kiro_mapped_model_name_for_explicit_model_mapping_test() {
|
||||
#[test]
|
||||
fn gateway_uses_kiro_mapped_model_name_for_explicit_model_mapping_test() {
|
||||
run_provider_query_test(
|
||||
"gateway_uses_kiro_mapped_model_name_for_explicit_model_mapping_test",
|
||||
gateway_uses_kiro_mapped_model_name_for_explicit_model_mapping_test_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_uses_kiro_mapped_model_name_for_explicit_model_mapping_test_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -3141,8 +3327,15 @@ async fn gateway_uses_kiro_mapped_model_name_for_explicit_model_mapping_test() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_test_model_failover_for_kiro_locally() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_test_model_failover_for_kiro_locally() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_test_model_failover_for_kiro_locally",
|
||||
gateway_handles_admin_provider_query_test_model_failover_for_kiro_locally_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_test_model_failover_for_kiro_locally_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -3298,8 +3491,15 @@ async fn gateway_handles_admin_provider_query_test_model_failover_for_kiro_local
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_retries_kiro_failover_after_http_error_without_message() {
|
||||
#[test]
|
||||
fn gateway_retries_kiro_failover_after_http_error_without_message() {
|
||||
run_provider_query_test(
|
||||
"gateway_retries_kiro_failover_after_http_error_without_message",
|
||||
gateway_retries_kiro_failover_after_http_error_without_message_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_retries_kiro_failover_after_http_error_without_message_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -3443,8 +3643,15 @@ async fn gateway_retries_kiro_failover_after_http_error_without_message() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_non_kiro_multi_model_failover_locally() {
|
||||
#[test]
|
||||
fn gateway_handles_non_kiro_multi_model_failover_locally() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_non_kiro_multi_model_failover_locally",
|
||||
gateway_handles_non_kiro_multi_model_failover_locally_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_non_kiro_multi_model_failover_locally_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -3558,8 +3765,15 @@ async fn gateway_handles_non_kiro_multi_model_failover_locally() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_openai_responses_test_model_locally() {
|
||||
#[test]
|
||||
fn gateway_handles_openai_responses_test_model_locally() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_openai_responses_test_model_locally",
|
||||
gateway_handles_openai_responses_test_model_locally_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_openai_responses_test_model_locally_impl() {
|
||||
let prompt = "Tell me whether the CLI request preserved this prompt.";
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
@@ -3728,8 +3942,15 @@ async fn gateway_handles_openai_responses_test_model_locally() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_openai_image_test_model_locally() {
|
||||
#[test]
|
||||
fn gateway_handles_openai_image_test_model_locally() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_openai_image_test_model_locally",
|
||||
gateway_handles_openai_image_test_model_locally_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_openai_image_test_model_locally_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -3846,8 +4067,15 @@ async fn gateway_handles_openai_image_test_model_locally() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_reports_transport_unsupported_reason_for_non_kiro_provider() {
|
||||
#[test]
|
||||
fn gateway_reports_transport_unsupported_reason_for_non_kiro_provider() {
|
||||
run_provider_query_test(
|
||||
"gateway_reports_transport_unsupported_reason_for_non_kiro_provider",
|
||||
gateway_reports_transport_unsupported_reason_for_non_kiro_provider_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_reports_transport_unsupported_reason_for_non_kiro_provider_impl() {
|
||||
let mut provider = sample_provider("provider-antigravity", "Antigravity", 10);
|
||||
provider.provider_type = "antigravity".to_string();
|
||||
let provider_catalog_repository = Arc::new(InMemoryProviderCatalogReadRepository::seed(
|
||||
@@ -3904,8 +4132,15 @@ async fn gateway_reports_transport_unsupported_reason_for_non_kiro_provider() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_antigravity_endpoint_test_model_locally() {
|
||||
#[test]
|
||||
fn gateway_handles_antigravity_endpoint_test_model_locally() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_antigravity_endpoint_test_model_locally",
|
||||
gateway_handles_antigravity_endpoint_test_model_locally_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_antigravity_endpoint_test_model_locally_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -4070,8 +4305,15 @@ async fn gateway_handles_antigravity_endpoint_test_model_locally() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_prefers_supported_non_kiro_endpoint_when_api_format_is_omitted() {
|
||||
#[test]
|
||||
fn gateway_prefers_supported_non_kiro_endpoint_when_api_format_is_omitted() {
|
||||
run_provider_query_test(
|
||||
"gateway_prefers_supported_non_kiro_endpoint_when_api_format_is_omitted",
|
||||
gateway_prefers_supported_non_kiro_endpoint_when_api_format_is_omitted_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_prefers_supported_non_kiro_endpoint_when_api_format_is_omitted_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -4172,8 +4414,15 @@ async fn gateway_prefers_supported_non_kiro_endpoint_when_api_format_is_omitted(
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_prefers_transport_supported_non_kiro_endpoint_when_api_format_is_omitted() {
|
||||
#[test]
|
||||
fn gateway_prefers_transport_supported_non_kiro_endpoint_when_api_format_is_omitted() {
|
||||
run_provider_query_test(
|
||||
"gateway_prefers_transport_supported_non_kiro_endpoint_when_api_format_is_omitted",
|
||||
gateway_prefers_transport_supported_non_kiro_endpoint_when_api_format_is_omitted_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_prefers_transport_supported_non_kiro_endpoint_when_api_format_is_omitted_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -4272,8 +4521,15 @@ async fn gateway_prefers_transport_supported_non_kiro_endpoint_when_api_format_i
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_prefers_supported_non_kiro_endpoint_with_compatible_key_when_api_format_is_omitted(
|
||||
#[test]
|
||||
fn gateway_prefers_supported_non_kiro_endpoint_with_compatible_key_when_api_format_is_omitted() {
|
||||
run_provider_query_test(
|
||||
"gateway_prefers_supported_non_kiro_endpoint_with_compatible_key_when_api_format_is_omitted",
|
||||
gateway_prefers_supported_non_kiro_endpoint_with_compatible_key_when_api_format_is_omitted_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_prefers_supported_non_kiro_endpoint_with_compatible_key_when_api_format_is_omitted_impl(
|
||||
) {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
@@ -4368,8 +4624,15 @@ async fn gateway_prefers_supported_non_kiro_endpoint_with_compatible_key_when_ap
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_uses_compatible_cli_endpoint_when_api_format_is_omitted() {
|
||||
#[test]
|
||||
fn gateway_uses_compatible_cli_endpoint_when_api_format_is_omitted() {
|
||||
run_provider_query_test(
|
||||
"gateway_uses_compatible_cli_endpoint_when_api_format_is_omitted",
|
||||
gateway_uses_compatible_cli_endpoint_when_api_format_is_omitted_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_uses_compatible_cli_endpoint_when_api_format_is_omitted_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -4463,8 +4726,16 @@ async fn gateway_uses_compatible_cli_endpoint_when_api_format_is_omitted() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_uses_runnable_cli_endpoint_after_chat_preference_when_api_format_is_omitted() {
|
||||
#[test]
|
||||
fn gateway_uses_runnable_cli_endpoint_after_chat_preference_when_api_format_is_omitted() {
|
||||
run_provider_query_test(
|
||||
"gateway_uses_runnable_cli_endpoint_after_chat_preference_when_api_format_is_omitted",
|
||||
gateway_uses_runnable_cli_endpoint_after_chat_preference_when_api_format_is_omitted_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_uses_runnable_cli_endpoint_after_chat_preference_when_api_format_is_omitted_impl()
|
||||
{
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -4560,8 +4831,15 @@ async fn gateway_uses_runnable_cli_endpoint_after_chat_preference_when_api_forma
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_openai_responses_test_model_failover_locally() {
|
||||
#[test]
|
||||
fn gateway_handles_openai_responses_test_model_failover_locally() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_openai_responses_test_model_failover_locally",
|
||||
gateway_handles_openai_responses_test_model_failover_locally_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_openai_responses_test_model_failover_locally_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -4653,8 +4931,15 @@ async fn gateway_handles_openai_responses_test_model_failover_locally() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_claude_cli_test_model_locally() {
|
||||
#[test]
|
||||
fn gateway_handles_claude_cli_test_model_locally() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_claude_cli_test_model_locally",
|
||||
gateway_handles_claude_cli_test_model_locally_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_claude_cli_test_model_locally_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -4744,8 +5029,15 @@ async fn gateway_handles_claude_cli_test_model_locally() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_uses_compatible_claude_cli_endpoint_when_api_format_is_omitted() {
|
||||
#[test]
|
||||
fn gateway_uses_compatible_claude_cli_endpoint_when_api_format_is_omitted() {
|
||||
run_provider_query_test(
|
||||
"gateway_uses_compatible_claude_cli_endpoint_when_api_format_is_omitted",
|
||||
gateway_uses_compatible_claude_cli_endpoint_when_api_format_is_omitted_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_uses_compatible_claude_cli_endpoint_when_api_format_is_omitted_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -4831,8 +5123,15 @@ async fn gateway_uses_compatible_claude_cli_endpoint_when_api_format_is_omitted(
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_claude_cli_test_model_failover_locally() {
|
||||
#[test]
|
||||
fn gateway_handles_claude_cli_test_model_failover_locally() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_claude_cli_test_model_failover_locally",
|
||||
gateway_handles_claude_cli_test_model_failover_locally_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_claude_cli_test_model_failover_locally_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -4924,8 +5223,15 @@ async fn gateway_handles_claude_cli_test_model_failover_locally() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_gemini_cli_test_model_locally() {
|
||||
#[test]
|
||||
fn gateway_handles_gemini_cli_test_model_locally() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_gemini_cli_test_model_locally",
|
||||
gateway_handles_gemini_cli_test_model_locally_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_gemini_cli_test_model_locally_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -5018,8 +5324,15 @@ async fn gateway_handles_gemini_cli_test_model_locally() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_gemini_cli_test_model_with_oauth_header_fallback() {
|
||||
#[test]
|
||||
fn gateway_handles_gemini_cli_test_model_with_oauth_header_fallback() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_gemini_cli_test_model_with_oauth_header_fallback",
|
||||
gateway_handles_gemini_cli_test_model_with_oauth_header_fallback_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_gemini_cli_test_model_with_oauth_header_fallback_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -5137,8 +5450,15 @@ async fn gateway_handles_gemini_cli_test_model_with_oauth_header_fallback() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_hydrates_gemini_cli_project_id_from_load_code_assist_for_test_model() {
|
||||
#[test]
|
||||
fn gateway_hydrates_gemini_cli_project_id_from_load_code_assist_for_test_model() {
|
||||
run_provider_query_test(
|
||||
"gateway_hydrates_gemini_cli_project_id_from_load_code_assist_for_test_model",
|
||||
gateway_hydrates_gemini_cli_project_id_from_load_code_assist_for_test_model_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_hydrates_gemini_cli_project_id_from_load_code_assist_for_test_model_impl() {
|
||||
let seen_urls = Arc::new(Mutex::new(Vec::<String>::new()));
|
||||
let seen_urls_clone = Arc::clone(&seen_urls);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -5306,8 +5626,15 @@ async fn gateway_hydrates_gemini_cli_project_id_from_load_code_assist_for_test_m
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_uses_compatible_gemini_cli_endpoint_when_api_format_is_omitted() {
|
||||
#[test]
|
||||
fn gateway_uses_compatible_gemini_cli_endpoint_when_api_format_is_omitted() {
|
||||
run_provider_query_test(
|
||||
"gateway_uses_compatible_gemini_cli_endpoint_when_api_format_is_omitted",
|
||||
gateway_uses_compatible_gemini_cli_endpoint_when_api_format_is_omitted_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_uses_compatible_gemini_cli_endpoint_when_api_format_is_omitted_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -5393,8 +5720,15 @@ async fn gateway_uses_compatible_gemini_cli_endpoint_when_api_format_is_omitted(
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_gemini_cli_test_model_failover_locally() {
|
||||
#[test]
|
||||
fn gateway_handles_gemini_cli_test_model_failover_locally() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_gemini_cli_test_model_failover_locally",
|
||||
gateway_handles_gemini_cli_test_model_failover_locally_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_gemini_cli_test_model_failover_locally_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -5486,8 +5820,15 @@ async fn gateway_handles_gemini_cli_test_model_failover_locally() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_unwraps_gemini_cli_v1internal_response_for_failover_model_test() {
|
||||
#[test]
|
||||
fn gateway_unwraps_gemini_cli_v1internal_response_for_failover_model_test() {
|
||||
run_provider_query_test(
|
||||
"gateway_unwraps_gemini_cli_v1internal_response_for_failover_model_test",
|
||||
gateway_unwraps_gemini_cli_v1internal_response_for_failover_model_test_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_unwraps_gemini_cli_v1internal_response_for_failover_model_test_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -5613,8 +5954,16 @@ async fn gateway_unwraps_gemini_cli_v1internal_response_for_failover_model_test(
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_handles_admin_provider_query_test_model_failover_with_single_model_name_alias() {
|
||||
#[test]
|
||||
fn gateway_handles_admin_provider_query_test_model_failover_with_single_model_name_alias() {
|
||||
run_provider_query_test(
|
||||
"gateway_handles_admin_provider_query_test_model_failover_with_single_model_name_alias",
|
||||
gateway_handles_admin_provider_query_test_model_failover_with_single_model_name_alias_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_handles_admin_provider_query_test_model_failover_with_single_model_name_alias_impl(
|
||||
) {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -5703,8 +6052,15 @@ async fn gateway_handles_admin_provider_query_test_model_failover_with_single_mo
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_retries_non_kiro_failover_after_http_error_without_message() {
|
||||
#[test]
|
||||
fn gateway_retries_non_kiro_failover_after_http_error_without_message() {
|
||||
run_provider_query_test(
|
||||
"gateway_retries_non_kiro_failover_after_http_error_without_message",
|
||||
gateway_retries_non_kiro_failover_after_http_error_without_message_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_retries_non_kiro_failover_after_http_error_without_message_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -5825,8 +6181,15 @@ async fn gateway_retries_non_kiro_failover_after_http_error_without_message() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_retries_non_kiro_failover_after_success_status_without_body() {
|
||||
#[test]
|
||||
fn gateway_retries_non_kiro_failover_after_success_status_without_body() {
|
||||
run_provider_query_test(
|
||||
"gateway_retries_non_kiro_failover_after_success_status_without_body",
|
||||
gateway_retries_non_kiro_failover_after_success_status_without_body_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_retries_non_kiro_failover_after_success_status_without_body_impl() {
|
||||
let execution_runtime = Router::new().route(
|
||||
"/v1/execute/sync",
|
||||
any(move |Json(plan): Json<ExecutionPlan>| async move {
|
||||
@@ -5953,8 +6316,15 @@ async fn gateway_retries_non_kiro_failover_after_success_status_without_body() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_preserves_non_success_status_for_test_model_local_wrapper() {
|
||||
#[test]
|
||||
fn gateway_preserves_non_success_status_for_test_model_local_wrapper() {
|
||||
run_provider_query_test(
|
||||
"gateway_preserves_non_success_status_for_test_model_local_wrapper",
|
||||
gateway_preserves_non_success_status_for_test_model_local_wrapper_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_preserves_non_success_status_for_test_model_local_wrapper_impl() {
|
||||
let gateway = build_router_with_state(AppState::new().expect("gateway should build"));
|
||||
let (gateway_url, gateway_handle) = start_server(gateway).await;
|
||||
|
||||
@@ -5979,8 +6349,15 @@ async fn gateway_preserves_non_success_status_for_test_model_local_wrapper() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_rejects_admin_provider_query_invalid_json_body() {
|
||||
#[test]
|
||||
fn gateway_rejects_admin_provider_query_invalid_json_body() {
|
||||
run_provider_query_test(
|
||||
"gateway_rejects_admin_provider_query_invalid_json_body",
|
||||
gateway_rejects_admin_provider_query_invalid_json_body_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_rejects_admin_provider_query_invalid_json_body_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().route(
|
||||
@@ -6019,8 +6396,15 @@ async fn gateway_rejects_admin_provider_query_invalid_json_body() {
|
||||
upstream_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_rejects_admin_provider_query_test_model_without_provider_id() {
|
||||
#[test]
|
||||
fn gateway_rejects_admin_provider_query_test_model_without_provider_id() {
|
||||
run_provider_query_test(
|
||||
"gateway_rejects_admin_provider_query_test_model_without_provider_id",
|
||||
gateway_rejects_admin_provider_query_test_model_without_provider_id_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_rejects_admin_provider_query_test_model_without_provider_id_impl() {
|
||||
assert_admin_provider_query_route(
|
||||
"/api/admin/provider-query/test-model",
|
||||
json!({ "model": "gpt-4.1" }),
|
||||
@@ -6032,8 +6416,15 @@ async fn gateway_rejects_admin_provider_query_test_model_without_provider_id() {
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_rejects_admin_provider_query_test_model_without_model() {
|
||||
#[test]
|
||||
fn gateway_rejects_admin_provider_query_test_model_without_model() {
|
||||
run_provider_query_test(
|
||||
"gateway_rejects_admin_provider_query_test_model_without_model",
|
||||
gateway_rejects_admin_provider_query_test_model_without_model_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_rejects_admin_provider_query_test_model_without_model_impl() {
|
||||
assert_admin_provider_query_route(
|
||||
"/api/admin/provider-query/test-model",
|
||||
json!({ "provider_id": "provider-openai" }),
|
||||
@@ -6045,8 +6436,15 @@ async fn gateway_rejects_admin_provider_query_test_model_without_model() {
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_rejects_admin_provider_query_test_model_failover_without_provider_id() {
|
||||
#[test]
|
||||
fn gateway_rejects_admin_provider_query_test_model_failover_without_provider_id() {
|
||||
run_provider_query_test(
|
||||
"gateway_rejects_admin_provider_query_test_model_failover_without_provider_id",
|
||||
gateway_rejects_admin_provider_query_test_model_failover_without_provider_id_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_rejects_admin_provider_query_test_model_failover_without_provider_id_impl() {
|
||||
assert_admin_provider_query_route(
|
||||
"/api/admin/provider-query/test-model-failover",
|
||||
json!({ "failover_models": ["gpt-4.1"] }),
|
||||
@@ -6058,8 +6456,15 @@ async fn gateway_rejects_admin_provider_query_test_model_failover_without_provid
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_rejects_admin_provider_query_test_model_failover_without_models() {
|
||||
#[test]
|
||||
fn gateway_rejects_admin_provider_query_test_model_failover_without_models() {
|
||||
run_provider_query_test(
|
||||
"gateway_rejects_admin_provider_query_test_model_failover_without_models",
|
||||
gateway_rejects_admin_provider_query_test_model_failover_without_models_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_rejects_admin_provider_query_test_model_failover_without_models_impl() {
|
||||
assert_admin_provider_query_route(
|
||||
"/api/admin/provider-query/test-model-failover",
|
||||
json!({ "provider_id": "provider-openai", "failover_models": [] }),
|
||||
|
||||
@@ -264,8 +264,39 @@ fn sample_import_admin_user(user_id: &str) -> StoredUserAuthRecord {
|
||||
.expect("admin user should build")
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_imports_admin_system_config_locally_and_persists_data() {
|
||||
const ADMIN_SYSTEM_IMPORT_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_admin_system_import_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(ADMIN_SYSTEM_IMPORT_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("admin system import test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gateway_imports_admin_system_config_locally_and_persists_data() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_imports_admin_system_config_locally_and_persists_data",
|
||||
gateway_imports_admin_system_config_locally_and_persists_data_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_imports_admin_system_config_locally_and_persists_data_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().fallback(any(move |_request: Request| {
|
||||
@@ -499,8 +530,15 @@ async fn gateway_imports_admin_system_config_locally_and_persists_data() {
|
||||
let _ = upstream_url;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_imports_admin_system_config_openai_image_aliases() {
|
||||
#[test]
|
||||
fn gateway_imports_admin_system_config_openai_image_aliases() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_imports_admin_system_config_openai_image_aliases",
|
||||
gateway_imports_admin_system_config_openai_image_aliases_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_imports_admin_system_config_openai_image_aliases_impl() {
|
||||
let provider_catalog_repository = Arc::new(InMemoryProviderCatalogReadRepository::seed(
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
@@ -566,8 +604,15 @@ async fn gateway_imports_admin_system_config_openai_image_aliases() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_returns_503_for_admin_system_config_import_when_local_data_is_unavailable() {
|
||||
#[test]
|
||||
fn gateway_returns_503_for_admin_system_config_import_when_local_data_is_unavailable() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_returns_503_for_admin_system_config_import_when_local_data_is_unavailable",
|
||||
gateway_returns_503_for_admin_system_config_import_when_local_data_is_unavailable_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_returns_503_for_admin_system_config_import_when_local_data_is_unavailable_impl() {
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
let upstream_hits_clone = Arc::clone(&upstream_hits);
|
||||
let upstream = Router::new().fallback(any(move |_request: Request| {
|
||||
@@ -603,8 +648,15 @@ async fn gateway_returns_503_for_admin_system_config_import_when_local_data_is_u
|
||||
let _ = upstream_url;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_imports_legacy_admin_system_config_versions_and_model_test_succeeds() {
|
||||
#[test]
|
||||
fn gateway_imports_legacy_admin_system_config_versions_and_model_test_succeeds() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_imports_legacy_admin_system_config_versions_and_model_test_succeeds",
|
||||
gateway_imports_legacy_admin_system_config_versions_and_model_test_succeeds_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_imports_legacy_admin_system_config_versions_and_model_test_succeeds_impl() {
|
||||
for (
|
||||
fixture_name,
|
||||
expected_provider_name,
|
||||
@@ -828,8 +880,15 @@ async fn assert_legacy_admin_system_config_import_model_test_succeeds(
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_rejects_unknown_admin_system_config_import_versions() {
|
||||
#[test]
|
||||
fn gateway_rejects_unknown_admin_system_config_import_versions() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_rejects_unknown_admin_system_config_import_versions",
|
||||
gateway_rejects_unknown_admin_system_config_import_versions_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_rejects_unknown_admin_system_config_import_versions_impl() {
|
||||
let gateway = build_router_with_state(
|
||||
AppState::new()
|
||||
.expect("gateway should build")
|
||||
@@ -867,8 +926,15 @@ async fn gateway_rejects_unknown_admin_system_config_import_versions() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_imports_admin_system_users_locally_and_persists_data() {
|
||||
#[test]
|
||||
fn gateway_imports_admin_system_users_locally_and_persists_data() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_imports_admin_system_users_locally_and_persists_data",
|
||||
gateway_imports_admin_system_users_locally_and_persists_data_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_imports_admin_system_users_locally_and_persists_data_impl() {
|
||||
let user_wallet_updated_at = "2024-05-06T07:08:09Z";
|
||||
let standalone_wallet_updated_at = "2024-06-07T08:09:10Z";
|
||||
let upstream_hits = Arc::new(Mutex::new(0usize));
|
||||
@@ -1142,8 +1208,15 @@ async fn gateway_imports_admin_system_users_locally_and_persists_data() {
|
||||
let _ = upstream_url;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_overwrites_existing_admin_system_user_key_usage_totals() {
|
||||
#[test]
|
||||
fn gateway_overwrites_existing_admin_system_user_key_usage_totals() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_overwrites_existing_admin_system_user_key_usage_totals",
|
||||
gateway_overwrites_existing_admin_system_user_key_usage_totals_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_overwrites_existing_admin_system_user_key_usage_totals_impl() {
|
||||
let user_key_hash = hash_api_key("sk-existing-user-key");
|
||||
let standalone_key_hash = hash_api_key("sk-existing-standalone-key");
|
||||
let existing_user = StoredUserAuthRecord::new(
|
||||
@@ -1347,8 +1420,15 @@ async fn gateway_overwrites_existing_admin_system_user_key_usage_totals() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_imports_admin_system_config_fixture_v22() {
|
||||
#[test]
|
||||
fn gateway_imports_admin_system_config_fixture_v22() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_imports_admin_system_config_fixture_v22",
|
||||
gateway_imports_admin_system_config_fixture_v22_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_imports_admin_system_config_fixture_v22_impl() {
|
||||
let gateway = build_router_with_state(
|
||||
AppState::new()
|
||||
.expect("gateway should build")
|
||||
@@ -1374,8 +1454,15 @@ async fn gateway_imports_admin_system_config_fixture_v22() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_imports_admin_system_config_fixtures_from_legacy_exports() {
|
||||
#[test]
|
||||
fn gateway_imports_admin_system_config_fixtures_from_legacy_exports() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_imports_admin_system_config_fixtures_from_legacy_exports",
|
||||
gateway_imports_admin_system_config_fixtures_from_legacy_exports_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_imports_admin_system_config_fixtures_from_legacy_exports_impl() {
|
||||
for fixture in ["v20", "v21"] {
|
||||
let gateway = build_router_with_state(
|
||||
AppState::new()
|
||||
@@ -1409,8 +1496,15 @@ async fn gateway_imports_admin_system_config_fixtures_from_legacy_exports() {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_imports_python_cli_alias_export_and_model_test_smoke() {
|
||||
#[test]
|
||||
fn gateway_imports_python_cli_alias_export_and_model_test_smoke() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_imports_python_cli_alias_export_and_model_test_smoke",
|
||||
gateway_imports_python_cli_alias_export_and_model_test_smoke_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_imports_python_cli_alias_export_and_model_test_smoke_impl() {
|
||||
let seen_plan = Arc::new(Mutex::new(None::<ExecutionPlan>));
|
||||
let seen_plan_clone = Arc::clone(&seen_plan);
|
||||
let execution_runtime = Router::new().route(
|
||||
@@ -1561,8 +1655,15 @@ async fn gateway_imports_python_cli_alias_export_and_model_test_smoke() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_rejects_legacy_user_import_string_bool_field() {
|
||||
#[test]
|
||||
fn gateway_rejects_legacy_user_import_string_bool_field() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_rejects_legacy_user_import_string_bool_field",
|
||||
gateway_rejects_legacy_user_import_string_bool_field_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_rejects_legacy_user_import_string_bool_field_impl() {
|
||||
let auth_repository = Arc::new(InMemoryAuthApiKeySnapshotRepository::default());
|
||||
let state = AppState::new()
|
||||
.expect("gateway should build")
|
||||
@@ -1600,8 +1701,15 @@ async fn gateway_rejects_legacy_user_import_string_bool_field() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_reports_field_path_for_invalid_admin_system_config_import_shape() {
|
||||
#[test]
|
||||
fn gateway_reports_field_path_for_invalid_admin_system_config_import_shape() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_reports_field_path_for_invalid_admin_system_config_import_shape",
|
||||
gateway_reports_field_path_for_invalid_admin_system_config_import_shape_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_reports_field_path_for_invalid_admin_system_config_import_shape_impl() {
|
||||
let gateway = build_router_with_state(
|
||||
AppState::new()
|
||||
.expect("gateway should build")
|
||||
@@ -1641,8 +1749,15 @@ async fn gateway_reports_field_path_for_invalid_admin_system_config_import_shape
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_imports_admin_system_config_with_numeric_string_prices() {
|
||||
#[test]
|
||||
fn gateway_imports_admin_system_config_with_numeric_string_prices() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_imports_admin_system_config_with_numeric_string_prices",
|
||||
gateway_imports_admin_system_config_with_numeric_string_prices_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_imports_admin_system_config_with_numeric_string_prices_impl() {
|
||||
let provider_catalog_repository = Arc::new(InMemoryProviderCatalogReadRepository::seed(
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
@@ -1714,8 +1829,15 @@ async fn gateway_imports_admin_system_config_with_numeric_string_prices() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_imports_oauth_provider_key_credentials_from_admin_system_config() {
|
||||
#[test]
|
||||
fn gateway_imports_oauth_provider_key_credentials_from_admin_system_config() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_imports_oauth_provider_key_credentials_from_admin_system_config",
|
||||
gateway_imports_oauth_provider_key_credentials_from_admin_system_config_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_imports_oauth_provider_key_credentials_from_admin_system_config_impl() {
|
||||
let provider_catalog_repository = Arc::new(InMemoryProviderCatalogReadRepository::seed(
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
@@ -1804,8 +1926,15 @@ async fn gateway_imports_oauth_provider_key_credentials_from_admin_system_config
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_overwrites_oauth_provider_key_credentials_from_admin_system_import() {
|
||||
#[test]
|
||||
fn gateway_overwrites_oauth_provider_key_credentials_from_admin_system_import() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_overwrites_oauth_provider_key_credentials_from_admin_system_import",
|
||||
gateway_overwrites_oauth_provider_key_credentials_from_admin_system_import_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_overwrites_oauth_provider_key_credentials_from_admin_system_import_impl() {
|
||||
let provider_catalog_repository = Arc::new(InMemoryProviderCatalogReadRepository::seed(
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
@@ -1898,8 +2027,12 @@ async fn gateway_overwrites_oauth_provider_key_credentials_from_admin_system_imp
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_overwrites_oauth_provider_key_credentials_from_admin_system_import_without_refresh(
|
||||
#[test]
|
||||
fn gateway_overwrites_oauth_provider_key_credentials_from_admin_system_import_without_refresh() {
|
||||
run_admin_system_import_test("gateway_overwrites_oauth_provider_key_credentials_from_admin_system_import_without_refresh", gateway_overwrites_oauth_provider_key_credentials_from_admin_system_import_without_refresh_impl);
|
||||
}
|
||||
|
||||
async fn gateway_overwrites_oauth_provider_key_credentials_from_admin_system_import_without_refresh_impl(
|
||||
) {
|
||||
let seen_refresh = Arc::new(Mutex::new(false));
|
||||
let seen_refresh_clone = Arc::clone(&seen_refresh);
|
||||
@@ -2058,8 +2191,15 @@ async fn gateway_overwrites_oauth_provider_key_credentials_from_admin_system_imp
|
||||
refresh_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_skips_proxy_nodes_during_admin_system_config_import() {
|
||||
#[test]
|
||||
fn gateway_skips_proxy_nodes_during_admin_system_config_import() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_skips_proxy_nodes_during_admin_system_config_import",
|
||||
gateway_skips_proxy_nodes_during_admin_system_config_import_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_skips_proxy_nodes_during_admin_system_config_import_impl() {
|
||||
let gateway = build_router_with_state(
|
||||
AppState::new()
|
||||
.expect("gateway should build")
|
||||
@@ -2103,8 +2243,15 @@ async fn gateway_skips_proxy_nodes_during_admin_system_config_import() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gateway_preserves_manual_proxy_configs_while_skipping_proxy_nodes_during_import() {
|
||||
#[test]
|
||||
fn gateway_preserves_manual_proxy_configs_while_skipping_proxy_nodes_during_import() {
|
||||
run_admin_system_import_test(
|
||||
"gateway_preserves_manual_proxy_configs_while_skipping_proxy_nodes_during_import",
|
||||
gateway_preserves_manual_proxy_configs_while_skipping_proxy_nodes_during_import_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gateway_preserves_manual_proxy_configs_while_skipping_proxy_nodes_during_import_impl() {
|
||||
let provider_catalog_repository = Arc::new(InMemoryProviderCatalogReadRepository::seed(
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
|
||||
@@ -20,6 +20,30 @@ use crate::constants::{
|
||||
};
|
||||
use aether_data_contracts::repository::candidate_selection::StoredMinimalCandidateSelectionRow;
|
||||
|
||||
const EMBEDDING_PROXY_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_embedding_proxy_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(EMBEDDING_PROXY_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("embedding proxy test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
fn embedding_success_state(execution_runtime_url: String) -> AppState {
|
||||
let mut snapshot =
|
||||
sample_currently_usable_auth_snapshot("key-embedding-success", "user-embedding-success");
|
||||
@@ -746,8 +770,15 @@ fn aliyun_embedding_execution_result(plan: &ExecutionPlan) -> ExecutionResult {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_accepts_openai_payload() {
|
||||
#[test]
|
||||
fn embeddings_route_accepts_openai_payload() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_accepts_openai_payload",
|
||||
embeddings_route_accepts_openai_payload_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_accepts_openai_payload_impl() {
|
||||
let (execution_runtime_url, execution_runtime_handle) =
|
||||
start_server(embedding_execution_runtime()).await;
|
||||
let gateway = build_router_with_state(embedding_success_state(execution_runtime_url));
|
||||
@@ -816,8 +847,15 @@ async fn embeddings_route_accepts_openai_payload() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_converts_openai_payload_to_gemini_embedding_provider() {
|
||||
#[test]
|
||||
fn embeddings_route_converts_openai_payload_to_gemini_embedding_provider() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_converts_openai_payload_to_gemini_embedding_provider",
|
||||
embeddings_route_converts_openai_payload_to_gemini_embedding_provider_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_converts_openai_payload_to_gemini_embedding_provider_impl() {
|
||||
let (execution_runtime_url, execution_runtime_handle) =
|
||||
start_server(gemini_embedding_conversion_execution_runtime()).await;
|
||||
let gateway = build_router_with_state(gemini_embedding_success_state(
|
||||
@@ -867,8 +905,15 @@ async fn embeddings_route_converts_openai_payload_to_gemini_embedding_provider()
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_converts_openai_payload_to_vertex_gemini_embedding_provider() {
|
||||
#[test]
|
||||
fn embeddings_route_converts_openai_payload_to_vertex_gemini_embedding_provider() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_converts_openai_payload_to_vertex_gemini_embedding_provider",
|
||||
embeddings_route_converts_openai_payload_to_vertex_gemini_embedding_provider_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_converts_openai_payload_to_vertex_gemini_embedding_provider_impl() {
|
||||
let (execution_runtime_url, execution_runtime_handle) =
|
||||
start_server(vertex_gemini_embedding_conversion_execution_runtime()).await;
|
||||
let gateway =
|
||||
@@ -911,8 +956,15 @@ async fn embeddings_route_converts_openai_payload_to_vertex_gemini_embedding_pro
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_converts_openai_batch_payload_to_gemini_batch_endpoint() {
|
||||
#[test]
|
||||
fn embeddings_route_converts_openai_batch_payload_to_gemini_batch_endpoint() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_converts_openai_batch_payload_to_gemini_batch_endpoint",
|
||||
embeddings_route_converts_openai_batch_payload_to_gemini_batch_endpoint_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_converts_openai_batch_payload_to_gemini_batch_endpoint_impl() {
|
||||
let (execution_runtime_url, execution_runtime_handle) =
|
||||
start_server(gemini_embedding_batch_conversion_execution_runtime()).await;
|
||||
let gateway = build_router_with_state(gemini_embedding_success_state(
|
||||
@@ -957,8 +1009,15 @@ async fn embeddings_route_converts_openai_batch_payload_to_gemini_batch_endpoint
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_converts_text_payload_to_aliyun_embedding_provider() {
|
||||
#[test]
|
||||
fn embeddings_route_converts_text_payload_to_aliyun_embedding_provider() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_converts_text_payload_to_aliyun_embedding_provider",
|
||||
embeddings_route_converts_text_payload_to_aliyun_embedding_provider_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_converts_text_payload_to_aliyun_embedding_provider_impl() {
|
||||
let (execution_runtime_url, execution_runtime_handle) =
|
||||
start_server(aliyun_embedding_conversion_execution_runtime(
|
||||
json!([{ "text": "hello" }]),
|
||||
@@ -1006,8 +1065,15 @@ async fn embeddings_route_converts_text_payload_to_aliyun_embedding_provider() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_converts_multimodal_payload_to_aliyun_embedding_provider() {
|
||||
#[test]
|
||||
fn embeddings_route_converts_multimodal_payload_to_aliyun_embedding_provider() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_converts_multimodal_payload_to_aliyun_embedding_provider",
|
||||
embeddings_route_converts_multimodal_payload_to_aliyun_embedding_provider_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_converts_multimodal_payload_to_aliyun_embedding_provider_impl() {
|
||||
let expected_contents = json!([
|
||||
{ "text": "white running shoes" },
|
||||
{ "image": "https://example.com/shoe.png" },
|
||||
@@ -1049,8 +1115,15 @@ async fn embeddings_route_converts_multimodal_payload_to_aliyun_embedding_provid
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_skips_openai_candidate_for_multimodal_payload() {
|
||||
#[test]
|
||||
fn embeddings_route_skips_openai_candidate_for_multimodal_payload() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_skips_openai_candidate_for_multimodal_payload",
|
||||
embeddings_route_skips_openai_candidate_for_multimodal_payload_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_skips_openai_candidate_for_multimodal_payload_impl() {
|
||||
let expected_contents = json!([
|
||||
{ "text": "white running shoes" },
|
||||
{ "image": "https://example.com/shoe.png" }
|
||||
@@ -1090,8 +1163,15 @@ async fn embeddings_route_skips_openai_candidate_for_multimodal_payload() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_converts_fusion_payload_to_aliyun_embedding_provider() {
|
||||
#[test]
|
||||
fn embeddings_route_converts_fusion_payload_to_aliyun_embedding_provider() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_converts_fusion_payload_to_aliyun_embedding_provider",
|
||||
embeddings_route_converts_fusion_payload_to_aliyun_embedding_provider_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_converts_fusion_payload_to_aliyun_embedding_provider_impl() {
|
||||
let expected_contents = json!([
|
||||
{
|
||||
"text": "white running shoes",
|
||||
@@ -1134,8 +1214,15 @@ async fn embeddings_route_converts_fusion_payload_to_aliyun_embedding_provider()
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gemini_embed_content_route_uses_native_gemini_embedding_provider() {
|
||||
#[test]
|
||||
fn gemini_embed_content_route_uses_native_gemini_embedding_provider() {
|
||||
run_embedding_proxy_test(
|
||||
"gemini_embed_content_route_uses_native_gemini_embedding_provider",
|
||||
gemini_embed_content_route_uses_native_gemini_embedding_provider_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn gemini_embed_content_route_uses_native_gemini_embedding_provider_impl() {
|
||||
let (execution_runtime_url, execution_runtime_handle) =
|
||||
start_server(gemini_embedding_native_execution_runtime()).await;
|
||||
let gateway = build_router_with_state(gemini_embedding_success_state(
|
||||
@@ -1188,8 +1275,15 @@ async fn gemini_embed_content_route_uses_native_gemini_embedding_provider() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_accepts_all_canonical_input_shapes() {
|
||||
#[test]
|
||||
fn embeddings_route_accepts_all_canonical_input_shapes() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_accepts_all_canonical_input_shapes",
|
||||
embeddings_route_accepts_all_canonical_input_shapes_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_accepts_all_canonical_input_shapes_impl() {
|
||||
let (execution_runtime_url, execution_runtime_handle) =
|
||||
start_server(embedding_execution_runtime()).await;
|
||||
let gateway = build_router_with_state(embedding_success_state(execution_runtime_url));
|
||||
@@ -1229,8 +1323,15 @@ async fn embeddings_route_accepts_all_canonical_input_shapes() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_rejects_invalid_local_payloads() {
|
||||
#[test]
|
||||
fn embeddings_route_rejects_invalid_local_payloads() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_rejects_invalid_local_payloads",
|
||||
embeddings_route_rejects_invalid_local_payloads_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_rejects_invalid_local_payloads_impl() {
|
||||
let gateway = build_router_with_state(AppState::new().expect("gateway should build"));
|
||||
let (gateway_url, gateway_handle) = start_server(gateway).await;
|
||||
let client = reqwest::Client::new();
|
||||
@@ -1294,8 +1395,15 @@ async fn embeddings_route_rejects_invalid_local_payloads() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_rejects_non_json_content_type() {
|
||||
#[test]
|
||||
fn embeddings_route_rejects_non_json_content_type() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_rejects_non_json_content_type",
|
||||
embeddings_route_rejects_non_json_content_type_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_rejects_non_json_content_type_impl() {
|
||||
let gateway = build_router_with_state(AppState::new().expect("gateway should build"));
|
||||
let (gateway_url, gateway_handle) = start_server(gateway).await;
|
||||
|
||||
@@ -1317,8 +1425,15 @@ async fn embeddings_route_rejects_non_json_content_type() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_rejects_chat_only_model() {
|
||||
#[test]
|
||||
fn embeddings_route_rejects_chat_only_model() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_rejects_chat_only_model",
|
||||
embeddings_route_rejects_chat_only_model_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_rejects_chat_only_model_impl() {
|
||||
let mut snapshot = sample_currently_usable_auth_snapshot("key-embedding-1", "user-embedding-1");
|
||||
snapshot.user_allowed_api_formats = Some(vec!["openai:embedding".to_string()]);
|
||||
snapshot.api_key_allowed_api_formats = Some(vec!["openai:embedding".to_string()]);
|
||||
@@ -1366,8 +1481,15 @@ async fn embeddings_route_rejects_chat_only_model() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn embeddings_route_rejects_chat_only_api_format() {
|
||||
#[test]
|
||||
fn embeddings_route_rejects_chat_only_api_format() {
|
||||
run_embedding_proxy_test(
|
||||
"embeddings_route_rejects_chat_only_api_format",
|
||||
embeddings_route_rejects_chat_only_api_format_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn embeddings_route_rejects_chat_only_api_format_impl() {
|
||||
let mut snapshot = sample_currently_usable_auth_snapshot("key-embedding-2", "user-embedding-2");
|
||||
snapshot.user_allowed_api_formats = Some(vec!["openai:chat".to_string()]);
|
||||
snapshot.api_key_allowed_api_formats = Some(vec!["openai:chat".to_string()]);
|
||||
|
||||
@@ -20,6 +20,30 @@ use crate::constants::{
|
||||
EXECUTION_PATH_LOCAL_AUTH_DENIED,
|
||||
};
|
||||
|
||||
const RERANK_PROXY_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
|
||||
|
||||
fn run_rerank_proxy_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(RERANK_PROXY_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("rerank proxy test thread should spawn");
|
||||
|
||||
if let Err(payload) = handle.join() {
|
||||
std::panic::resume_unwind(payload);
|
||||
}
|
||||
}
|
||||
|
||||
fn rerank_success_state(execution_runtime_url: String) -> AppState {
|
||||
let mut snapshot =
|
||||
sample_currently_usable_auth_snapshot("key-rerank-success", "user-rerank-success");
|
||||
@@ -142,8 +166,15 @@ fn rerank_execution_result(plan: &ExecutionPlan) -> ExecutionResult {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn rerank_route_accepts_openai_payload() {
|
||||
#[test]
|
||||
fn rerank_route_accepts_openai_payload() {
|
||||
run_rerank_proxy_test(
|
||||
"rerank_route_accepts_openai_payload",
|
||||
rerank_route_accepts_openai_payload_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn rerank_route_accepts_openai_payload_impl() {
|
||||
let (execution_runtime_url, execution_runtime_handle) =
|
||||
start_server(rerank_execution_runtime()).await;
|
||||
let gateway = build_router_with_state(rerank_success_state(execution_runtime_url));
|
||||
@@ -200,8 +231,15 @@ async fn rerank_route_accepts_openai_payload() {
|
||||
execution_runtime_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn rerank_route_rejects_invalid_local_payloads() {
|
||||
#[test]
|
||||
fn rerank_route_rejects_invalid_local_payloads() {
|
||||
run_rerank_proxy_test(
|
||||
"rerank_route_rejects_invalid_local_payloads",
|
||||
rerank_route_rejects_invalid_local_payloads_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn rerank_route_rejects_invalid_local_payloads_impl() {
|
||||
let gateway = build_router_with_state(AppState::new().expect("gateway should build"));
|
||||
let (gateway_url, gateway_handle) = start_server(gateway).await;
|
||||
let client = reqwest::Client::new();
|
||||
@@ -257,8 +295,15 @@ async fn rerank_route_rejects_invalid_local_payloads() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn rerank_route_rejects_non_json_content_type() {
|
||||
#[test]
|
||||
fn rerank_route_rejects_non_json_content_type() {
|
||||
run_rerank_proxy_test(
|
||||
"rerank_route_rejects_non_json_content_type",
|
||||
rerank_route_rejects_non_json_content_type_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn rerank_route_rejects_non_json_content_type_impl() {
|
||||
let gateway = build_router_with_state(AppState::new().expect("gateway should build"));
|
||||
let (gateway_url, gateway_handle) = start_server(gateway).await;
|
||||
|
||||
@@ -280,8 +325,15 @@ async fn rerank_route_rejects_non_json_content_type() {
|
||||
gateway_handle.abort();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn rerank_route_rejects_chat_only_api_format() {
|
||||
#[test]
|
||||
fn rerank_route_rejects_chat_only_api_format() {
|
||||
run_rerank_proxy_test(
|
||||
"rerank_route_rejects_chat_only_api_format",
|
||||
rerank_route_rejects_chat_only_api_format_impl,
|
||||
);
|
||||
}
|
||||
|
||||
async fn rerank_route_rejects_chat_only_api_format_impl() {
|
||||
let mut snapshot = sample_currently_usable_auth_snapshot("key-rerank-2", "user-rerank-2");
|
||||
snapshot.user_allowed_api_formats = Some(vec!["openai:chat".to_string()]);
|
||||
snapshot.api_key_allowed_api_formats = Some(vec!["openai:chat".to_string()]);
|
||||
|
||||
Reference in New Issue
Block a user