文档首页/跨模块业务回归

跨模块业务回归

English · 全功能实现说明

本目录集中存放后台业务回归;internal 保留生产模块及其单元测试。providerconfig 负责测试元数据解析,testsupport 提供共用的 PostgreSQL 隔离夹具。

职责与实现契约

本目录通过真实 HTTP 网关、真实 PostgreSQL、独立 schema 与随机监听端口验收业务链。默认上游为可编排的本地 fake,真实模型通过 live 环境显式启用;Redis 可选但冷却和热状态验收必须连接真实 Redis。 harness_test 构造服务、租户、模型与请求辅助,setup/chain_support 提供资源流程,mode_test 为业务链切换模拟/真实上游。用例不能只判断 HTTP 200,要观察上游次数、调用 ID、模型/权限/模板来源、费用响应头、日志、费率快照及五个费用作用域。 route_template_config_test 覆盖完整配置往返、平台播种一次、整文档优先级、作用域隔离、重试只计一笔、权重、超时热更新、冷却、表单保持/清空、引用删除和跨组织拒绝。route_template_live_test 验证真实模型在模板选择变化后推理、记日志并推动五层费用。pricing_live_test 对真实 usage 做数量×费率与快照核对。公开函数主要为 Test 入口,不是生产 HTTP API;完整文件矩阵与执行流程见回归方案。 多供应商确定性用例只通过共享解析器读取 testdata/config_provider.yaml,把其中的 base 替换成两个独立环回上游,写入具名合成凭据且不读取 key_env;调用记录只保留解析后的供应商身份,不保存原始凭据值。配置部署使用 litellm_params.deployment_id,通过 /model/new 创建的数据库部署使用 model_info.id。覆盖候选约束与注入抽样的权重边界、物理连接完全相同的数据库重复行、模板继承、作用域/模型隔离、重试、零权重、流式、并发、响应亲和、禁用、账务,以及 supplier A/B 冷却 key 的 Redis 隔离;详细契约见多供应商同模型回归。

源码职责与入口

doc.go

内部实现和协议边界见 doc.go。

对外 HTTP 边界

无本目录直接登记的 HTTP 路由。导出的 Go API 由上层调用;运行时目录调度或调用宿主的入口应沿依赖链追踪。

依赖关系

internal/logx.

验证与维护入口

测试文件 场景入口
acceptance_limits_test.go TestAcceptanceLimitsAndAccountingContract
acceptance_surfaces_test.go TestAcceptanceGuardrailMonitor, TestAcceptanceModelLifecycle
budget_chain_test.go TestPersonalBudgetChain, TestTeamBudgetChain, TestProjectBudgetChain, TestOrganizationBudgetChain, TestKeyBudgetChain, TestBudgetNamesTheNarrowestExhaustedScope
budget_test.go TestBudgetAccumulatesAcrossCalls, TestRateLimitIsSeparateFromBudget, TestUnlimitedScopeIsUnlimited
chain_support_test.go fixture/辅助函数,无顶层 Test
chain_test.go TestRequestChain
consistency_test.go TestResponseUsageAndLogsAgree, TestUsageCountersMatchTheBill, TestCacheHitIsFreeAndLoggedAsOne, TestFailedCallIsLoggedButNotCharged, TestLogDetailMatchesTheRowInTheList
endpoint_redesign_test.go TestEndpointAvailableContract, TestEndpointRedesignNativeLifecycle, TestEndpointDialogueMatrix, TestEndpointRetiredGlobals, TestEndpointGoogleGuardrails
endpoints_test.go TestChatEndpointRewritesAndAnswers, TestEmbeddingEndpointUsesItsOwnPath, TestSeedanceBypassCreatesAndPollsATask, TestABypassCannotBeFilledInFromTheConsole
fal_billing_test.go TestFalSettlementUsesOutputSecondsAndDeduplicates
fallback_test.go TestFallbackChain, TestCooldownSkipsADeployment
guardrail_test.go TestGuardrailBlocksBeforeTheUpstreamIsDialed, TestGuardrailBlockIsLoggedButNotCharged, TestGuardrailOnlyAppliesToTheModelsItCovers, TestGuardrailTrialDoesNotChangeStorage, TestGuardrailRedactRewritesInsteadOfBlocking
harness_test.go TestMain
interaction_test.go TestGuardrailBlockDoesNotConsumeBudget, TestCacheHitDoesNotConsumeBudget, TestManagerActionsAreAudited, TestChangingABudgetTakesEffectImmediately, TestBlockingAKeyTakesEffectImmediately, TestDeletingATeamPreservesPersonalKeys, TestModelRestrictionAndBudgetAreIndependent
internal_modules_test.go TestInternalLLMRouteBoundary, TestInternalLLMProtocolHelpersBoundary, TestInternalEstimateBoundary, TestInternalCatalogClassificationBoundary, TestInternalCacheAndPluginBoundary, TestInternalLiveUnavailableBoundary, TestInternalProviderProtocolBoundary, TestInternalProxyParameterBoundary, TestInternalConfigLoadBoundary, TestInternalGeminiNativeStreamBoundary
layout_test.go TestProductionModulesExcludeRegressionFixtures
live_mode_test.go fixture/辅助函数,无顶层 Test
live_test.go TestLiveConfiguredVendorsAnswer, TestLiveBypassCreatesAndPollsARealTask
logs_test.go TestEveryLogViewAgreesOnTheSameTraffic, TestCallIdIsTheSameEverywhereItAppears, TestTenantSeesOnlyItsOwnLogs, TestDailyActivityCountsTheCalls, TestPromptStorageFollowsTheSwitch, TestSpendCalculateUsesThePriceCatalog
mode_test.go fixture/辅助函数,无顶层 Test
model_alias_test.go TestDialogueAliasLifecycle
model_credential_test.go TestOfficialCredentialSupportsNativeModel
model_discovery_test.go TestModelDiscoveryPathFallback, TestDiscoveryTreatsProviderNamesUniformly
model_fallback_test.go TestModelFallbackLifecycle, TestModelFallbackPersistenceBoundaries, TestModelFallbackBudgetRecheck, TestModelFallbackTemplatePrecedence
model_limit_test.go TestModelLimitChain
model_weights_test.go TestModelWeightsLifecycle
models_test.go TestModelListShowsWhatTheCallerMayUse, TestModelsOfEveryEndpointTypeAreListed, TestModelAvailableCarriesThePriceFromTheCatalog, TestModelAvailableLeavesUnknownPricesEmpty, TestEveryDeclaredTransportExistsInTheCatalog, TestTransportsAreRegisteredBypasses, TestPriceCatalogRatesArePerToken, TestAddingAModelMakesItCallable, TestDeletingAModelStopsIt, TestConfigModelCannotBeDeletedFromTheConsole, TestDisabledModelIsRefused, TestMissingCredentialStillBlamesTheCredential, TestUnknownModelIsRefused
more_cases_test.go TestIdempotencyReplaysWithoutASecondCharge, TestStreamSkipsIdempotency, TestMalformedRequestsNeverDial, TestTPMLimitIsNotABudgetError, TestUpstream429FailsOverAndAMissingKeyIsSkipped, TestGuardrailDoesNotCoverEmbeddings, TestEachInferenceFamilyReachesItsOwnUpstreamPath
multi_supplier_test.go TestMultiSupplierConfiguredWeights, TestMultiSupplierTemplateWeights, TestMultiSupplierModelRulesAndScopeIsolation, TestMultiSupplierRetryAndBilling, TestMultiSupplierZeroWeightExcludesFailover, TestMultiSupplierAllZeroRejects, TestMultiSupplierResponseAffinity, TestMultiSupplierStreamingAndConcurrentWeights, TestMultiSupplierDatabaseDuplicateDeployments, TestMultiSupplierCooldownIsolation
permission_test.go TestTenantIsolationAcrossOrganizations, TestMemberCannotReadAnotherTenant, TestMemberCannotAdminister, TestKeyLifecycleAndScope, TestKeyRegenerateInvalidatesTheOldSecret, TestUnauthenticatedIsRefused, TestInvalidKeyIsRefused, TestOrganizationAndTeamHierarchy
price_selection_test.go TestPriceSelectionContract
pricing_live_test.go TestLiveRealModelsAreBilledFromTheCatalog, TestLiveVendorUsageFieldsAreUnderstood, TestLiveStreamingIsBilledFromTheRealUsage, TestLiveSameVendorViaEitherProtocolIsBilledAlike, TestLiveUsageOracleHonorsExplicitZeroAndNullAliases, TestLiveUsageOracleDistinguishesNestedSubsetFromAnthropicCache, TestParseStreamUsageMergesResponseUsageEvents, TestSameRatePricesHandlesUnequalRateListLengths, TestSameRatePricesRequiresComparableTokenRates
pricing_test.go TestAWindowPricedModelIsChargedTheWindowItLandedIn, TestAPerSecondModelIsNotRecordedAsFree, TestLogDetailExplainsTheChargeWithoutRecomputing, TestTheBreakdownSurvivesAPriceChange, TestAnUnpricedCallIsNotRecordedAsFree, TestACachedCallIsNotBilledAtTheInputRate
pricing_units_test.go TestConsolePriceFormIsBilledForEveryDimension, TestTheFlatPeakFieldIsActuallyRead, TestAnthropicShapedUsageIsBilledWhole, TestTheCatalogPricesEveryMeasureItQuotes, TestEveryCatalogModelIsReachableByTheNamesDeploymentsUse
protocol_test.go TestSameModelAnswersThreeChatProtocols, TestEveryProtocolIsBilledTheSameWay, TestStreamingAnswersArriveAndAreBilled, TestStreamingAndNonStreamingAgreeOnTokens, TestEmbeddingIsBilledFromItsOwnUsage, TestUnknownPathIsNotFound
provider_forms_test.go TestProviderFormsContract, TestPriceReloadRequiresConfiguredSource, TestPriceLocalListingRoutes
provider_transport_test.go TestProviderTransportContract
removed_surfaces_test.go TestRemovedSurfacesStayGone
reset_test.go TestResetSpendChain, TestPasswordResetChain
responses_continuation_test.go TestResponsesIncrementalContinuation
responses_native_continuation_test.go TestResponsesNativeToolContinuation, TestResponsesFailedStreamCannotContinue
route_template_config_test.go TestRouteTemplateConfigurationRoundTrip, TestRouteTemplateModelRulesContainNoDeploymentData, TestRouteTemplateDuplicateModelsAreRejected, TestRouteTemplateDefaultStrategyContract
route_template_live_test.go TestLiveRouteTemplateSelectionAndBilling
route_template_test.go TestRouteTemplateScopePrecedence, TestRouteTemplateRetryPolicyApplies, TestRouteTemplateRejectsLegacyDocuments
router_settings_test.go TestRouterSettingsChain
routing_groups_test.go TestRoutingGroupLifecycle
routing_test.go TestRoutingStrategyChain, TestLeastBusyChain, TestUnknownStrategyChain, TestExactNameBeatsWildcard, TestSessionPinOverridesStrategy
seedance_billing_test.go TestSeedanceSettlementUsesMeasuredBandAndDeduplicates
setup_test.go TestStartupDoesNotInstallRelayCapabilities, TestScopedKeyCallsInference, TestModelAllowListIsEnforced
split_test.go TestWeightedSplitSendsTrafficToBothDeployments, TestWeightedSplitDoesNotChangeSimpleShuffle, TestSplitStillBillsAndLogsEveryCall, TestSplitIsEvenWhenNoWeightsAreSet
supplier_catalog_test.go TestSupplierCatalogLifecycle
template_routing_test.go TestTemplateRoutingUnified
weighted_live_metadata_test.go TestDecodeProviderMetadataRejectsInvalidInput, TestExpectedWeightedCountsAvoidsIntegerOverflow, TestWeightedObserverRejectsSuccessfulFallback, TestHealthyWeightedCycleRequiresEveryRequest
weighted_live_test.go TestLiveConfiguredWeightedRouting
xgo_guardrail_test.go TestXGoGuardrailEnforcesPersistedPolicy
go test ./cmd/regression/... -count=1

Fenno 与七牛的付费全套、实时 RUN/PASS/FAIL 日志和运行目录见真实供应商回归执行说明。入口是 bash scripts/regression-live-log.sh。密钥只放在环境变量里。

数据库验收设置 XHUB_REGRESSION_STRICT=1 并检查跳过项;Redis 和真实供应商需单独配置。每个同时运行的回归进程必须使用专用 Redis,花费队列和冷却 key 属于共享外部状态,不能跨 runner 共用。harness 清理先等待 HTTP handler 结束,在私有 schema 仍存在时排空最终花费记录,再关闭 Redis 客户端。接口、字段或行为改变后同步本说明及相关功能文档。

输入关键词搜索全文,例如:预算、路由、Docker