feat(go): add 100k ingest hardening baseline

This commit is contained in:
lingniu
2026-07-03 17:55:22 +08:00
parent 378a5d5e57
commit 79e591f864
20 changed files with 1360 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
package loadsim
import "testing"
func TestConnectionBatchesSpreadsConnectionsByRate(t *testing.T) {
got := ConnectionBatches(2500, 1000)
want := []int{1000, 1000, 500}
if len(got) != len(want) {
t.Fatalf("len = %d, want %d: %#v", len(got), len(want), got)
}
for i := range want {
if got[i] != want[i] {
t.Fatalf("batch[%d] = %d, want %d: %#v", i, got[i], want[i], got)
}
}
}
func TestConnectionBatchesUsesOneBatchWhenTargetBelowRate(t *testing.T) {
got := ConnectionBatches(300, 1000)
if len(got) != 1 || got[0] != 300 {
t.Fatalf("ConnectionBatches() = %#v, want []int{300}", got)
}
}