Files
easyai-ai-gateway/apps/api/internal/capacitycontroller/static_test.go
T
wangbo 7786692d32 feat(routing): 引入多执行池智能调度
将 Worker 发现、路由画像、容量与执行传输抽象为平台无关接口,新增 Kubernetes 和静态容量适配器,并以 shadow 模式接入生产配置。

实现网络与容量评分、路由防抖、池队列、同步 Worker 租约、一次性执行令牌,以及提交状态不明时禁止重复分配的安全语义。

新增 0105 兼容迁移、管理接口、指标、OpenAPI 和回归测试。已执行全量 Go 测试、go vet、OpenAPI、迁移安全、Compose 与 Kustomize 验证。
2026-08-05 22:25:37 +08:00

25 lines
672 B
Go

package capacitycontroller
import (
"context"
"testing"
)
func TestStaticAdapterDoesNotRequireKubernetes(t *testing.T) {
adapter := NewStaticAdapter(map[string]int{"pool-a": 2})
state, err := adapter.PoolState(context.Background(), "pool-a", "ignored")
if err != nil {
t.Fatal(err)
}
if state.PoolID != "pool-a" || state.CurrentReplicas != 2 {
t.Fatalf("state=%+v", state)
}
if err := adapter.ScalePool(context.Background(), "pool-a", "ignored", 4); err != nil {
t.Fatal(err)
}
state, _ = adapter.PoolState(context.Background(), "pool-a", "ignored")
if state.CurrentReplicas != 2 {
t.Fatalf("static adapter scaled to %d", state.CurrentReplicas)
}
}