diff --git a/apps/aether-gateway/src/scheduler/candidate/tests/required_capability.rs b/apps/aether-gateway/src/scheduler/candidate/tests/required_capability.rs index 89e7db9e7..ecdee7a79 100644 --- a/apps/aether-gateway/src/scheduler/candidate/tests/required_capability.rs +++ b/apps/aether-gateway/src/scheduler/candidate/tests/required_capability.rs @@ -19,7 +19,9 @@ use super::super::{ list_selectable_candidates_for_required_capability_without_requested_model, list_selectable_candidates_for_required_capability_without_requested_model_with_auth_limit_signal, }; -use super::support::{sample_auth_snapshot, sample_provider, sample_row}; +use super::support::{ + sample_auth_snapshot, sample_provider, sample_row, sample_row_without_model_mappings, +}; #[tokio::test] async fn compatible_required_capability_prefers_matching_keys_without_hard_filtering() { @@ -77,7 +79,7 @@ async fn compatible_required_capability_prefers_matching_keys_without_hard_filte #[tokio::test] async fn exclusive_required_capability_keeps_hard_filtering_only_matching_keys() { - let mut incompatible = sample_row(); + let mut incompatible = sample_row_without_model_mappings(); incompatible.provider_id = "provider-a".to_string(); incompatible.provider_name = "provider-a".to_string(); incompatible.endpoint_id = "endpoint-a".to_string(); @@ -89,7 +91,7 @@ async fn exclusive_required_capability_keeps_hard_filtering_only_matching_keys() incompatible.global_model_name = "gemini-2.5-pro".to_string(); incompatible.key_capabilities = Some(serde_json::json!({})); - let mut compatible = sample_row(); + let mut compatible = sample_row_without_model_mappings(); compatible.provider_id = "provider-b".to_string(); compatible.provider_name = "provider-b".to_string(); compatible.endpoint_id = "endpoint-b".to_string(); @@ -133,7 +135,7 @@ async fn exclusive_required_capability_keeps_hard_filtering_only_matching_keys() #[tokio::test] async fn required_capability_without_model_uses_session_scoped_affinity() { - let mut fallback = sample_row(); + let mut fallback = sample_row_without_model_mappings(); fallback.provider_id = "provider-a".to_string(); fallback.provider_name = "provider-a".to_string(); fallback.endpoint_id = "endpoint-a".to_string(); diff --git a/apps/aether-gateway/src/scheduler/candidate/tests/selection.rs b/apps/aether-gateway/src/scheduler/candidate/tests/selection.rs index 3a1179e5f..ef13bfb0a 100644 --- a/apps/aether-gateway/src/scheduler/candidate/tests/selection.rs +++ b/apps/aether-gateway/src/scheduler/candidate/tests/selection.rs @@ -35,7 +35,10 @@ use super::super::selection::{ collect_selectable_candidates_with_skip_reasons as collect_selectable_candidates_with_skip_reasons_impl, is_exact_all_skipped_by_auth_limit, select_minimal_candidate as select_candidate_impl, }; -use super::support::{sample_auth_snapshot, sample_key, sample_provider, sample_row}; +use super::support::{ + sample_auth_snapshot, sample_key, sample_provider, sample_row, + sample_row_without_model_mappings, +}; async fn state_with_routing_default_policy( data_state: GatewayDataState, @@ -2225,7 +2228,7 @@ async fn keeps_codex_candidate_selectable_when_oauth_token_is_expired() { #[tokio::test] async fn keeps_refreshable_kiro_candidate_selectable_with_runtime_oauth_invalid_marker() { - let mut row = sample_row(); + let mut row = sample_row_without_model_mappings(); row.provider_id = "provider-kiro".to_string(); row.provider_name = "kiro".to_string(); row.provider_type = "kiro".to_string(); @@ -2286,7 +2289,7 @@ async fn keeps_refreshable_kiro_candidate_selectable_with_runtime_oauth_invalid_ #[tokio::test] async fn keeps_refreshable_kiro_candidate_selectable_when_oauth_token_expired() { - let mut row = sample_row(); + let mut row = sample_row_without_model_mappings(); row.provider_id = "provider-kiro".to_string(); row.provider_name = "kiro".to_string(); row.provider_type = "kiro".to_string(); @@ -2346,7 +2349,7 @@ async fn keeps_refreshable_kiro_candidate_selectable_when_oauth_token_expired() #[tokio::test] async fn keeps_kiro_candidate_selectable_after_refresh_token_failure_until_access_token_expiry() { - let mut row = sample_row(); + let mut row = sample_row_without_model_mappings(); row.provider_id = "provider-kiro".to_string(); row.provider_name = "kiro".to_string(); row.provider_type = "kiro".to_string(); @@ -2411,7 +2414,7 @@ async fn keeps_kiro_candidate_selectable_after_refresh_token_failure_until_acces #[tokio::test] async fn skips_kiro_candidate_after_refresh_token_failure_and_access_token_expiry() { - let mut row = sample_row(); + let mut row = sample_row_without_model_mappings(); row.provider_id = "provider-kiro".to_string(); row.provider_name = "kiro".to_string(); row.provider_type = "kiro".to_string(); @@ -2477,7 +2480,7 @@ async fn skips_kiro_candidate_after_refresh_token_failure_and_access_token_expir #[tokio::test] async fn skips_refreshable_kiro_candidate_when_oauth_marker_is_account_block() { - let mut row = sample_row(); + let mut row = sample_row_without_model_mappings(); row.provider_id = "provider-kiro".to_string(); row.provider_name = "kiro".to_string(); row.provider_type = "kiro".to_string(); @@ -2620,7 +2623,7 @@ async fn keeps_codex_candidate_selectable_when_exhausted_account_flag_is_disable #[tokio::test] async fn skips_kiro_candidate_when_account_quota_is_exhausted_and_pool_flag_enabled() { - let mut first = sample_row(); + let mut first = sample_row_without_model_mappings(); first.provider_id = "provider-kiro".to_string(); first.provider_name = "kiro".to_string(); first.provider_type = "kiro".to_string(); @@ -2632,7 +2635,7 @@ async fn skips_kiro_candidate_when_account_quota_is_exhausted_and_pool_flag_enab first.key_api_formats = Some(vec!["claude:messages".to_string()]); first.key_global_priority_by_format = Some(serde_json::json!({"claude:messages": 1})); - let mut second = sample_row(); + let mut second = sample_row_without_model_mappings(); second.provider_id = "provider-openai".to_string(); second.provider_name = "openai".to_string(); second.endpoint_id = "endpoint-openai".to_string(); diff --git a/apps/aether-gateway/src/scheduler/candidate/tests/support.rs b/apps/aether-gateway/src/scheduler/candidate/tests/support.rs index 1bf9e6f13..80cca955d 100644 --- a/apps/aether-gateway/src/scheduler/candidate/tests/support.rs +++ b/apps/aether-gateway/src/scheduler/candidate/tests/support.rs @@ -56,6 +56,14 @@ pub(super) fn sample_row() -> StoredMinimalCandidateSelectionRow { } } +/// 共享夹具默认把上游名映射限定在 openai 格式;需要其它端点/格式的用例 +/// 用本函数移除映射约束(无映射的行在所有端点按默认上游名可用)。 +pub(super) fn sample_row_without_model_mappings() -> StoredMinimalCandidateSelectionRow { + let mut row = sample_row(); + row.model_provider_model_mappings = None; + row +} + pub(super) fn sample_provider( id: &str, concurrent_limit: Option,