test(load): add idle and tunable group scenarios
This commit is contained in:
@@ -16,35 +16,44 @@ import (
|
||||
const manifestVersion = 1
|
||||
|
||||
type Config struct {
|
||||
Tenant string `json:"tenant"`
|
||||
HTTPBase string `json:"http_base"`
|
||||
APIKeyEnv string `json:"api_key_env"`
|
||||
PasswordEnv string `json:"password_env"`
|
||||
UsersPerMachine int `json:"users_per_machine"`
|
||||
Endpoints map[string][]string `json:"endpoints"`
|
||||
DialIPs map[string][]string `json:"dial_ips,omitempty"`
|
||||
InsecureTLS bool `json:"insecure_tls"`
|
||||
PrepareWorkers int `json:"prepare_workers"`
|
||||
ConnectRamp string `json:"connect_ramp"`
|
||||
CommandTimeout string `json:"command_timeout"`
|
||||
WSPingInterval string `json:"ws_ping_interval"`
|
||||
P2PMessages int `json:"p2p_messages_per_user"`
|
||||
P2PInterval string `json:"p2p_interval"`
|
||||
DrainP2P string `json:"drain_p2p"`
|
||||
DrainGroup string `json:"drain_group"`
|
||||
DeliveryQuiet string `json:"delivery_quiet_period"`
|
||||
DeliveryTimeout string `json:"delivery_quiet_timeout"`
|
||||
PhonePrefix string `json:"registration_phone_prefix"`
|
||||
VerifyCodeEnv string `json:"verification_code_env"`
|
||||
HistoryWorkers int `json:"history_workers"`
|
||||
HistoryPageSize int `json:"history_page_size"`
|
||||
HistoryInterval string `json:"history_query_interval"`
|
||||
HistoryPageWait string `json:"history_page_wait"`
|
||||
HistorySettle string `json:"history_settle"`
|
||||
HistoryTimeout string `json:"history_timeout"`
|
||||
CloseRamp string `json:"close_ramp"`
|
||||
PreflightWorkers int `json:"preflight_workers"`
|
||||
SkipP2PPreflight bool `json:"skip_p2p_preflight"`
|
||||
Tenant string `json:"tenant"`
|
||||
HTTPBase string `json:"http_base"`
|
||||
APIKeyEnv string `json:"api_key_env"`
|
||||
PasswordEnv string `json:"password_env"`
|
||||
UsersPerMachine int `json:"users_per_machine"`
|
||||
Endpoints map[string][]string `json:"endpoints"`
|
||||
DialIPs map[string][]string `json:"dial_ips,omitempty"`
|
||||
InsecureTLS bool `json:"insecure_tls"`
|
||||
PrepareWorkers int `json:"prepare_workers"`
|
||||
ConnectRamp string `json:"connect_ramp"`
|
||||
ReconnectWorkers int `json:"reconnect_workers"`
|
||||
ReconnectMinWait string `json:"reconnect_min_wait"`
|
||||
ReconnectMaxWait string `json:"reconnect_max_wait"`
|
||||
CommandTimeout string `json:"command_timeout"`
|
||||
WSPingInterval string `json:"ws_ping_interval"`
|
||||
P2PMessages int `json:"p2p_messages_per_user"`
|
||||
P2PInterval string `json:"p2p_interval"`
|
||||
GroupSenders int `json:"group_senders_per_machine"`
|
||||
GroupRounds int `json:"group_rounds"`
|
||||
GroupInterval string `json:"group_publish_interval"`
|
||||
MixedP2PUsers int `json:"mixed_p2p_users_per_machine"`
|
||||
MixedGroupSenders int `json:"mixed_group_senders_per_machine"`
|
||||
IdleDuration string `json:"idle_duration"`
|
||||
DrainP2P string `json:"drain_p2p"`
|
||||
DrainGroup string `json:"drain_group"`
|
||||
DeliveryQuiet string `json:"delivery_quiet_period"`
|
||||
DeliveryTimeout string `json:"delivery_quiet_timeout"`
|
||||
PhonePrefix string `json:"registration_phone_prefix"`
|
||||
VerifyCodeEnv string `json:"verification_code_env"`
|
||||
HistoryWorkers int `json:"history_workers"`
|
||||
HistoryPageSize int `json:"history_page_size"`
|
||||
HistoryInterval string `json:"history_query_interval"`
|
||||
HistoryPageWait string `json:"history_page_wait"`
|
||||
HistorySettle string `json:"history_settle"`
|
||||
HistoryTimeout string `json:"history_timeout"`
|
||||
CloseRamp string `json:"close_ramp"`
|
||||
PreflightWorkers int `json:"preflight_workers"`
|
||||
SkipP2PPreflight bool `json:"skip_p2p_preflight"`
|
||||
}
|
||||
|
||||
func loadConfig(path string) (*Config, error) {
|
||||
@@ -68,6 +77,29 @@ func loadConfig(path string) (*Config, error) {
|
||||
if cfg.ConnectRamp == "" {
|
||||
cfg.ConnectRamp = "20s"
|
||||
}
|
||||
if cfg.ReconnectWorkers <= 0 {
|
||||
cfg.ReconnectWorkers = 8
|
||||
}
|
||||
if cfg.ReconnectWorkers > 128 {
|
||||
return nil, errors.New("reconnect_workers must not exceed 128")
|
||||
}
|
||||
if cfg.ReconnectMinWait == "" {
|
||||
cfg.ReconnectMinWait = "2s"
|
||||
}
|
||||
if _, err = configDuration(cfg.ReconnectMinWait); err != nil {
|
||||
return nil, fmt.Errorf("reconnect_min_wait: %w", err)
|
||||
}
|
||||
if cfg.ReconnectMaxWait == "" {
|
||||
cfg.ReconnectMaxWait = "30s"
|
||||
}
|
||||
minReconnect, _ := configDuration(cfg.ReconnectMinWait)
|
||||
maxReconnect, err := configDuration(cfg.ReconnectMaxWait)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("reconnect_max_wait: %w", err)
|
||||
}
|
||||
if maxReconnect < minReconnect {
|
||||
return nil, errors.New("reconnect_max_wait must be greater than or equal to reconnect_min_wait")
|
||||
}
|
||||
if cfg.CommandTimeout == "" {
|
||||
cfg.CommandTimeout = "20s"
|
||||
}
|
||||
@@ -83,6 +115,30 @@ func loadConfig(path string) (*Config, error) {
|
||||
if cfg.P2PInterval == "" {
|
||||
cfg.P2PInterval = "1s"
|
||||
}
|
||||
if cfg.GroupRounds <= 0 {
|
||||
cfg.GroupRounds = 2
|
||||
}
|
||||
if cfg.GroupInterval == "" {
|
||||
cfg.GroupInterval = "100ms"
|
||||
}
|
||||
if _, err = configDuration(cfg.GroupInterval); err != nil {
|
||||
return nil, fmt.Errorf("group_publish_interval: %w", err)
|
||||
}
|
||||
if cfg.GroupSenders < 0 {
|
||||
return nil, errors.New("group_senders_per_machine must not be negative")
|
||||
}
|
||||
if cfg.MixedP2PUsers < 0 {
|
||||
return nil, errors.New("mixed_p2p_users_per_machine must not be negative")
|
||||
}
|
||||
if cfg.MixedGroupSenders < 0 {
|
||||
return nil, errors.New("mixed_group_senders_per_machine must not be negative")
|
||||
}
|
||||
if cfg.IdleDuration == "" {
|
||||
cfg.IdleDuration = "15m"
|
||||
}
|
||||
if _, err = configDuration(cfg.IdleDuration); err != nil {
|
||||
return nil, fmt.Errorf("idle_duration: %w", err)
|
||||
}
|
||||
if cfg.DrainP2P == "" {
|
||||
cfg.DrainP2P = "30s"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user