feat: support verified bulk load-test setup

This commit is contained in:
richjohnrambo
2026-09-27 01:34:39 +08:00
parent 021169555a
commit b3b5dd55a6
8 changed files with 272 additions and 47 deletions
+36
View File
@@ -43,3 +43,39 @@ func TestApplyConfigEndpointsRefreshesManifest(t *testing.T) {
t.Fatalf("endpoints were not refreshed: %+v", manifest.Accounts)
}
}
func TestRegistrationPhoneUsesDistinctMachineRanges(t *testing.T) {
cfg := &Config{UsersPerMachine: 1000, PhonePrefix: "1990927"}
a, err := registrationPhone(cfg, "a", 1)
if err != nil || a != "19909270001" {
t.Fatalf("machine A phone=%q err=%v", a, err)
}
b, err := registrationPhone(cfg, "b", 1)
if err != nil || b != "19909275001" {
t.Fatalf("machine B phone=%q err=%v", b, err)
}
last, err := registrationPhone(cfg, "b", 1000)
if err != nil || last != "19909276000" {
t.Fatalf("last phone=%q err=%v", last, err)
}
}
func TestReconcileManifestExpandsSmokeRun(t *testing.T) {
existing := &Manifest{Version: manifestVersion, Tenant: "allrich", GroupTopic: "grp-one", Accounts: []AccountRecord{
{Machine: "a", Index: 1, Username: "lta0001", UserID: "usr-a", Token: "token-a", P2PTopic: "p2p-one"},
{Machine: "b", Index: 1, Username: "ltb0001", UserID: "usr-b", Token: "token-b", P2PTopic: "p2p-one"},
}}
cfg := &Config{Tenant: "allrich", UsersPerMachine: 2, PhonePrefix: "1990927", Endpoints: map[string][]string{
"a": {"wss://a"}, "b": {"wss://b"},
}}
expanded, err := reconcileManifest(cfg, existing)
if err != nil {
t.Fatal(err)
}
if len(expanded.Accounts) != 4 || expanded.GroupTopic != "grp-one" || expanded.Accounts[0].Token != "token-a" {
t.Fatalf("unexpected expanded manifest: %+v", expanded)
}
if expanded.Accounts[3].Phone != "19909275002" {
t.Fatalf("machine B phone=%q", expanded.Accounts[3].Phone)
}
}