All checks were successful
release-tag / release-image (push) Successful in 2m32s
36 lines
1.3 KiB
Go
36 lines
1.3 KiB
Go
package engine
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/local/glpi-neural-brain/internal/config"
|
|
"github.com/local/glpi-neural-brain/internal/ollama"
|
|
"github.com/local/glpi-neural-brain/internal/workqueue"
|
|
)
|
|
|
|
func TestApplyRuntimePerformanceRaisesAndRestoresLimits(t *testing.T) {
|
|
pool := ollama.NewPool(ollama.PoolConfig{
|
|
Nodes: []ollama.NodeConfig{{Name: "gpu-a", URL: "http://unused"}, {Name: "gpu-b", URL: "http://unused"}},
|
|
NodeMaxInflight: 1,
|
|
}, "qwen3:8b", "embeddinggemma")
|
|
limiter := workqueue.New(2, 8)
|
|
e := &Engine{
|
|
Cfg: config.Config{ResearchOllamaMaxInflight: 2, ResearchOllamaQueueSize: 8, OllamaNodeMaxInflight: 1},
|
|
Ollama: pool,
|
|
sharedWork: limiter,
|
|
}
|
|
e.applyRuntimePerformance(RuntimeSettings{SpeedMode: true, SpeedCPUWorkers: 6, SpeedGPUInflight: 3})
|
|
status := limiter.Status()
|
|
if status.MaxInflight != 6 || status.QueueSize < 96 {
|
|
t.Fatalf("unexpected speed limiter: %+v", status)
|
|
}
|
|
if got := pool.NodeMaxInflight(); got != 3 {
|
|
t.Fatalf("gpu limit=%d want 3", got)
|
|
}
|
|
e.applyRuntimePerformance(RuntimeSettings{SpeedMode: false})
|
|
status = limiter.Status()
|
|
if status.MaxInflight != 2 || status.QueueSize != 8 || pool.NodeMaxInflight() != 1 {
|
|
t.Fatalf("normal limits not restored: limiter=%+v gpu=%d", status, pool.NodeMaxInflight())
|
|
}
|
|
}
|