test(panel): scale item-22 benchmarks to 20-server seed

This commit is contained in:
aaaamoooo
2026-10-21 10:54:36 +00:00
parent 6d97d4e172
commit 0f7495546f
+9 -7
View File
@@ -1,8 +1,10 @@
package main package main
// Benchmarks for round-3 item 22 (per-request full-clone cost). Not run // Benchmarks for round-3 item 22 (per-request full-clone cost). Not run
// by `go test` without -bench. The seed is synthetic data at production // by `go test` without -bench. The seed is synthetic data at the scale
// scale (~11 servers / 26 customers / 25 nodes / ~100 bindings). // fixed for this round's acceptance: 20 servers / 40 customers /
// 40 nodes / ~160 bindings (20-agent steady-state tests use the same
// scale).
import ( import (
"encoding/json" "encoding/json"
@@ -16,14 +18,14 @@ import (
func perfSeedData() *Data { func perfSeedData() *Data {
d := EmptyData() d := EmptyData()
d.Users = []*User{{ID: "usr_1", Username: "admin", PasswordHash: "x", Role: "owner", Status: "active", CreatedAt: NowISO()}} d.Users = []*User{{ID: "usr_1", Username: "admin", PasswordHash: "x", Role: "owner", Status: "active", CreatedAt: NowISO()}}
for i := 0; i < 11; i++ { for i := 0; i < 20; i++ {
d.Servers = append(d.Servers, &Server{ d.Servers = append(d.Servers, &Server{
ID: fmt.Sprintf("srv_%d", i), Name: fmt.Sprintf("S%d", i), PublicAddress: "203.0.113.1", ID: fmt.Sprintf("srv_%d", i), Name: fmt.Sprintf("S%d", i), PublicAddress: "203.0.113.1",
Status: "online", LastSeenAt: StrPtr(NowISO()), PortRangeStart: 20000, PortRangeEnd: 50000, Status: "online", LastSeenAt: StrPtr(NowISO()), PortRangeStart: 20000, PortRangeEnd: 50000,
Labels: []string{}, CreatedAt: NowISO(), UpdatedAt: NowISO(), Labels: []string{}, CreatedAt: NowISO(), UpdatedAt: NowISO(),
}) })
} }
for i := 0; i < 26; i++ { for i := 0; i < 40; i++ {
d.Customers = append(d.Customers, &Customer{ d.Customers = append(d.Customers, &Customer{
ID: fmt.Sprintf("cus_%d", i), Name: fmt.Sprintf("C%d", i), Status: "active", ID: fmt.Sprintf("cus_%d", i), Name: fmt.Sprintf("C%d", i), Status: "active",
SubscriptionToken: fmt.Sprintf("tok-%032d", i), SubscriptionToken: fmt.Sprintf("tok-%032d", i),
@@ -32,9 +34,9 @@ func perfSeedData() *Data {
}) })
} }
protocols := []string{"vless-reality-vision", "shadowsocks-2022-aes128", "socks5-auth", "vless-ws", "hysteria2"} protocols := []string{"vless-reality-vision", "shadowsocks-2022-aes128", "socks5-auth", "vless-ws", "hysteria2"}
for i := 0; i < 25; i++ { for i := 0; i < 40; i++ {
node := &Node{ node := &Node{
ID: fmt.Sprintf("nod_%d", i), Name: fmt.Sprintf("N%d", i), ServerID: fmt.Sprintf("srv_%d", i%11), ID: fmt.Sprintf("nod_%d", i), Name: fmt.Sprintf("N%d", i), ServerID: fmt.Sprintf("srv_%d", i%20),
Protocol: protocols[i%len(protocols)], Topology: "direct", NetworkMode: "ipv4", Port: 23000 + i, Protocol: protocols[i%len(protocols)], Topology: "direct", NetworkMode: "ipv4", Port: 23000 + i,
Status: "active", ResourceID: fmt.Sprintf("res_%d", i), Artifacts: map[string]json.RawMessage{}, Status: "active", ResourceID: fmt.Sprintf("res_%d", i), Artifacts: map[string]json.RawMessage{},
} }
@@ -48,7 +50,7 @@ func perfSeedData() *Data {
for j := 0; j < 4; j++ { for j := 0; j < 4; j++ {
d.NodeClients = append(d.NodeClients, &NodeClient{ d.NodeClients = append(d.NodeClients, &NodeClient{
ID: fmt.Sprintf("nc_%d_%d", i, j), NodeID: node.ID, ID: fmt.Sprintf("nc_%d_%d", i, j), NodeID: node.ID,
CustomerID: fmt.Sprintf("cus_%d", (i+j)%26), Status: "active", CustomerID: fmt.Sprintf("cus_%d", (i+j)%40), Status: "active",
CreatedAt: NowISO(), UpdatedAt: NowISO(), CreatedAt: NowISO(), UpdatedAt: NowISO(),
}) })
} }