mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-13 21:57:29 +08:00
feat: harden concurrency scheduling and task watchdog
This commit is contained in:
24
pkg/tools/command_tick_limits_test.go
Normal file
24
pkg/tools/command_tick_limits_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package tools
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestComputeDynamicActiveSlots_ReservesTwentyPercent(t *testing.T) {
|
||||
got := computeDynamicActiveSlots(10, 0.20, 0.0, 12)
|
||||
if got != 8 {
|
||||
t.Fatalf("expected 8 active slots with 20%% reserve on 10 CPU, got %d", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestComputeDynamicActiveSlots_ReducesWithSystemUsage(t *testing.T) {
|
||||
got := computeDynamicActiveSlots(10, 0.20, 0.5, 12)
|
||||
if got != 3 {
|
||||
t.Fatalf("expected 3 active slots when system usage is 50%%, got %d", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestComputeDynamicActiveSlots_AlwaysKeepsOne(t *testing.T) {
|
||||
got := computeDynamicActiveSlots(8, 0.20, 0.95, 12)
|
||||
if got != 1 {
|
||||
t.Fatalf("expected at least 1 active slot under high system usage, got %d", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user