e2e
v9.24.1
Documentation
pkg.go.dev ↗Package e2e provides end-to-end testing scenarios for the maintenance notifications system.
This package contains comprehensive test scenarios that validate the maintenance notifications functionality in realistic environments. The tests are designed to work with Redis Enterprise clusters and require specific environment configuration.
Environment Variables:
- E2E_SCENARIO_TESTS: Set to "true" to enable scenario tests
- REDIS_ENDPOINTS_CONFIG_PATH: Path to endpoints configuration file
- FAULT_INJECTION_API_URL: URL for fault injection API (optional)
Test Scenarios:
- Basic Push Notifications: Core functionality testing
- Endpoint Types: Different endpoint resolution strategies
- Timeout Configurations: Various timeout strategies
- TLS Configurations: Different TLS setups
- Stress Testing: Extreme load and concurrent operations
Note: Maintenance notifications are currently supported only in standalone Redis clients. Cluster clients (ClusterClient, FailoverClient, etc.) do not yet support this functionality.
Variables
StandaloneEffects
var StandaloneEffects = []StandaloneEffect{
StandaloneDataMovementConnDrop,
StandaloneDataMovementNoConnDrop,
StandaloneConnDrop,
StandaloneDNSResolutionChange,
}
StandaloneEffects lists every effect, in matrix order.
Functions
DebugE2E
func DebugE2E() bool
DebugE2E returns true if E2E_DEBUG environment variable is set to "true" Use this to control verbose debug logging in e2e tests
FormatSlotRange
func FormatSlotRange(start, end int) string
FormatSlotRange formats a slot range for Redis commands
GetClusterNodes
func GetClusterNodes() []string
GetClusterNodes returns a list of cluster node IDs
GetMasterNodes
func GetMasterNodes() []string
GetMasterNodes returns a list of master node IDs
GetSlaveNodes
func GetSlaveNodes() []string
GetSlaveNodes returns a list of slave node IDs
ParseNodeID
func ParseNodeID(nodeAddr string) string
ParseNodeID extracts node ID from various formats
Types
ActionListItem
type ActionListItem struct {
JobID string `json:"job_id"`
ActionType string `json:"action_type"`
Status string `json:"status"`
SubmittedAt string `json:"submitted_at"`
}
ActionListItem represents a single action in the list actions response
ActionRequest
type ActionRequest struct {
Type ActionType `json:"type"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
}
ActionRequest represents a request to trigger an action
ActionResponse
type ActionResponse struct {
ActionID string `json:"action_id"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
}
ActionResponse represents the response from triggering an action
ActionStatus
type ActionStatus string
ActionStatus represents the status of an action
StatusPending (6 declarations)
const ( StatusPending ActionStatus = "pending" StatusRunning ActionStatus = "running" StatusFinished ActionStatus = "finished" StatusFailed ActionStatus = "failed" StatusSuccess ActionStatus = "success" StatusCancelled ActionStatus = "cancelled" )
ActionStatusResponse
type ActionStatusResponse struct {
ActionID string `json:"action_id"`
Status ActionStatus `json:"status"`
Error interface{} `json:"error,omitempty"`
Output map[string]interface{} `json:"output,omitempty"`
Progress float64 `json:"progress,omitempty"`
StartTime time.Time `json:"start_time,omitempty"`
EndTime time.Time `json:"end_time,omitempty"`
}
ActionStatusResponse represents the status of an action
ActionType
type ActionType string
ActionType represents the type of fault injection action
ActionClusterFailover (26 declarations)
const ( // Redis cluster actions ActionClusterFailover ActionType = "cluster_failover" ActionClusterReshard ActionType = "cluster_reshard" ActionClusterAddNode ActionType = "cluster_add_node" ActionClusterRemoveNode ActionType = "cluster_remove_node" ActionClusterMigrate ActionType = "cluster_migrate" // Node-level actions ActionNodeRestart ActionType = "node_restart" ActionNodeStop ActionType = "node_stop" ActionNodeStart ActionType = "node_start" ActionNodeKill ActionType = "node_kill" // Network simulation actions ActionNetworkPartition ActionType = "network_partition" ActionNetworkLatency ActionType = "network_latency" ActionNetworkPacketLoss ActionType = "network_packet_loss" ActionNetworkBandwidth ActionType = "network_bandwidth" ActionNetworkRestore ActionType = "network_restore" // Redis configuration actions ActionConfigChange ActionType = "config_change" ActionMaintenanceMode ActionType = "maintenance_mode" ActionSlotMigration ActionType = "slot_migrate" // Sequence and complex actions ActionSequence ActionType = "sequence_of_actions" ActionExecuteCommand ActionType = "execute_command" // Database management actions ActionDeleteDatabase ActionType = "delete_database" ActionCreateDatabase ActionType = "create_database" ActionFailover ActionType = "failover" ActionMigrate ActionType = "migrate" ActionBind ActionType = "bind" // Slot migrate action (OSS Cluster API testing) ActionSlotMigrate ActionType = "slot_migrate" // ActionNetworkFailure is used by multidb/e2e's Active-Active failover // scenarios. Verified against the real service's source // (re_fault_injector/actions/network_failure.py): blocks ingress/egress // on every node hosting a bdb within a cluster/region for a duration, // then restores automatically. ActionNetworkFailure ActionType = "network_failure" )
ActionProxyFailure
const ( // ActionProxyFailure stops, starts or restarts the DMC proxy. ActionProxyFailure ActionType = "proxy_failure" )
ActionsListResponse
type ActionsListResponse struct {
Actions []ActionListItem `json:"actions"`
}
ActionsListResponse is the wrapper response from the /action GET endpoint
DatabaseConfig
type DatabaseConfig struct {
Name string `json:"name"`
Port int `json:"port"`
MemorySize int64 `json:"memory_size"`
Replication bool `json:"replication"`
EvictionPolicy string `json:"eviction_policy"`
Sharding bool `json:"sharding"`
AutoUpgrade bool `json:"auto_upgrade"`
ShardsCount int `json:"shards_count"`
ModuleList []DatabaseModule `json:"module_list,omitempty"`
OSSCluster bool `json:"oss_cluster"`
OSSClusterAPIPreferredIPType string `json:"oss_cluster_api_preferred_ip_type,omitempty"`
ProxyPolicy string `json:"proxy_policy,omitempty"`
ShardsPlacement string `json:"shards_placement,omitempty"`
ShardKeyRegex []ShardKeyRegexPattern `json:"shard_key_regex,omitempty"`
}
EnvDatabaseConfig represents the configuration for creating a database
DatabaseModule
type DatabaseModule struct {
ModuleArgs string `json:"module_args"`
ModuleName string `json:"module_name"`
}
DatabaseModule represents a Redis module configuration
FaultInjectorClient
type FaultInjectorClient struct {
// contains filtered or unexported fields
}
FaultInjectorClient provides programmatic control over test infrastructure
NewFaultInjectorClient
func NewFaultInjectorClient(baseURL string) *FaultInjectorClient
NewFaultInjectorClient creates a new fault injector client
FaultInjectorClient.ChangeConfig
func (c *FaultInjectorClient) ChangeConfig(ctx context.Context, nodeID string, config map[string]string) (*ActionResponse, error)
ChangeConfig changes Redis configuration
FaultInjectorClient.CreateDatabase
func (c *FaultInjectorClient) CreateDatabase(ctx context.Context, clusterIndex int, databaseConfig DatabaseConfig) (*ActionResponse, error)
CreateDatabase creates a new database Parameters:
- clusterIndex: The index of the cluster
- databaseConfig: The database configuration
FaultInjectorClient.CreateDatabaseConfigWithPortRetry
func (c *FaultInjectorClient) CreateDatabaseConfigWithPortRetry(ctx context.Context, clusterIndex int, databaseConfig DatabaseConfig, maxRetries int) (*ActionResponse, int, error)
CreateDatabaseConfigWithPortRetry creates a new database using DatabaseConfig, retrying with incremented port numbers if the port is unavailable Parameters:
- clusterIndex: The index of the cluster
- databaseConfig: The database configuration
- maxRetries: Maximum number of port increments to try (default 100 if <= 0)
Returns the ActionResponse and the final port used
FaultInjectorClient.CreateDatabaseFromMap
func (c *FaultInjectorClient) CreateDatabaseFromMap(ctx context.Context, clusterIndex int, databaseConfig map[string]interface{}) (*ActionResponse, error)
CreateDatabaseFromMap creates a new database using a map for configuration This is useful when you want to pass a raw configuration map Parameters:
- clusterIndex: The index of the cluster
- databaseConfig: The database configuration as a map
FaultInjectorClient.CreateDatabaseWithPortRetry
func (c *FaultInjectorClient) CreateDatabaseWithPortRetry(ctx context.Context, clusterIndex int, databaseConfig map[string]interface{}, maxRetries int) (*ActionResponse, int, error)
CreateDatabaseWithPortRetry creates a new database, retrying with incremented port numbers if the port is unavailable Parameters:
- clusterIndex: The index of the cluster
- databaseConfig: The database configuration as a map (must contain "port" key)
- maxRetries: Maximum number of port increments to try (default 100 if <= 0)
Returns the ActionResponse and the final port used
FaultInjectorClient.DeleteDatabase
func (c *FaultInjectorClient) DeleteDatabase(ctx context.Context, clusterIndex int, bdbID int) (*ActionResponse, error)
DeleteDatabase deletes a database Parameters:
- clusterIndex: The index of the cluster
- bdbID: The database ID to delete
FaultInjectorClient.DisableMaintenanceMode
func (c *FaultInjectorClient) DisableMaintenanceMode(ctx context.Context, nodeID string) (*ActionResponse, error)
DisableMaintenanceMode disables maintenance mode
FaultInjectorClient.EnableMaintenanceMode
func (c *FaultInjectorClient) EnableMaintenanceMode(ctx context.Context, nodeID string) (*ActionResponse, error)
EnableMaintenanceMode enables maintenance mode
FaultInjectorClient.ExecuteCommand
func (c *FaultInjectorClient) ExecuteCommand(ctx context.Context, nodeID, command string) (*ActionResponse, error)
ExecuteCommand executes a custom command
FaultInjectorClient.ExecuteSequence
func (c *FaultInjectorClient) ExecuteSequence(ctx context.Context, actions []SequenceAction) (*ActionResponse, error)
ExecuteSequence executes a sequence of actions
FaultInjectorClient.GetActionStatus
func (c *FaultInjectorClient) GetActionStatus(ctx context.Context, actionID string) (*ActionStatusResponse, error)
GetActionStatus gets the status of a specific action
FaultInjectorClient.GetBaseURL
func (c *FaultInjectorClient) GetBaseURL() string
GetBaseURL returns the base URL of the fault injector server
FaultInjectorClient.GetSlotMigrateTriggers
func (c *FaultInjectorClient) GetSlotMigrateTriggers(ctx context.Context, effect SlotMigrateEffect, clusterIndex int) (*SlotMigrateTriggersResponse, error)
GetSlotMigrateTriggers returns available triggers for a slot migration effect This is useful for discovering what database configurations are needed for each effect/variant
FaultInjectorClient.GetSlotMigrateTriggersRaw
func (c *FaultInjectorClient) GetSlotMigrateTriggersRaw(ctx context.Context, effect SlotMigrateEffect, clusterIndex int) ([]byte, error)
GetSlotMigrateTriggersRaw returns the raw JSON response from GET /slot-migrate This is useful for debugging when the response structure doesn't match expectations
FaultInjectorClient.GetStandaloneTriggers
func (c *FaultInjectorClient) GetStandaloneTriggers(ctx context.Context, effect StandaloneEffect, clusterIndex int) (*StandaloneTriggersResponse, error)
GetStandaloneTriggers lists the triggers (and the database configs that support them) for an effect. An empty list means the cluster cannot run it, for example because it has fewer than 3 nodes.
FaultInjectorClient.KillNode
func (c *FaultInjectorClient) KillNode(ctx context.Context, nodeID string) (*ActionResponse, error)
KillNode forcefully kills a Redis node
FaultInjectorClient.LimitBandwidth
func (c *FaultInjectorClient) LimitBandwidth(ctx context.Context, nodes []string, bandwidth string) (*ActionResponse, error)
LimitBandwidth limits network bandwidth
FaultInjectorClient.ListActions
func (c *FaultInjectorClient) ListActions(ctx context.Context) ([]ActionListItem, error)
ListActions lists all available actions
FaultInjectorClient.RestartNode
func (c *FaultInjectorClient) RestartNode(ctx context.Context, nodeID string, graceful bool) (*ActionResponse, error)
RestartNode restarts a specific Redis node
FaultInjectorClient.RestoreNetwork
func (c *FaultInjectorClient) RestoreNetwork(ctx context.Context, nodes []string) (*ActionResponse, error)
RestoreNetwork restores normal network conditions
FaultInjectorClient.SetupTopologyChangeStandalone
func (c *FaultInjectorClient) SetupTopologyChangeStandalone(ctx context.Context, effect StandaloneEffect, trigger string, clusterIndex, variantIndex int) (*StandaloneSetup, error)
SetupTopologyChangeStandalone provisions a database for effect/trigger and blocks until it is ready. variantIndex selects the entry of the trigger's requirements list.
FaultInjectorClient.SimulateClusterUpgrade
func (c *FaultInjectorClient) SimulateClusterUpgrade(ctx context.Context, nodes []string) (*ActionResponse, error)
SimulateClusterUpgrade simulates a complete cluster upgrade scenario
FaultInjectorClient.SimulateNetworkIssues
func (c *FaultInjectorClient) SimulateNetworkIssues(ctx context.Context, nodes []string) (*ActionResponse, error)
SimulateNetworkIssues simulates various network issues
FaultInjectorClient.SimulateNetworkLatency
func (c *FaultInjectorClient) SimulateNetworkLatency(ctx context.Context, nodes []string, latency time.Duration, jitter time.Duration) (*ActionResponse, error)
SimulateNetworkLatency adds network latency
FaultInjectorClient.SimulateNetworkPartition
func (c *FaultInjectorClient) SimulateNetworkPartition(ctx context.Context, nodes []string, duration time.Duration) (*ActionResponse, error)
SimulateNetworkPartition simulates a network partition
FaultInjectorClient.SimulatePacketLoss
func (c *FaultInjectorClient) SimulatePacketLoss(ctx context.Context, nodes []string, lossPercent float64) (*ActionResponse, error)
SimulatePacketLoss simulates packet loss
FaultInjectorClient.StartNode
func (c *FaultInjectorClient) StartNode(ctx context.Context, nodeID string) (*ActionResponse, error)
StartNode starts a specific Redis node
FaultInjectorClient.StopNode
func (c *FaultInjectorClient) StopNode(ctx context.Context, nodeID string, graceful bool) (*ActionResponse, error)
StopNode stops a specific Redis node
FaultInjectorClient.TeardownTopologyChangeStandalone
func (c *FaultInjectorClient) TeardownTopologyChangeStandalone(ctx context.Context, s *StandaloneSetup) error
TeardownTopologyChangeStandalone deletes the database and restores node state (maintenance mode off, max_listeners reset). It sends both setup_id and bdb_id: the FI keeps the setup registry in memory, so after a restart only bdb_id still resolves. Blocks until the FI finished.
FaultInjectorClient.TriggerAction
func (c *FaultInjectorClient) TriggerAction(ctx context.Context, action ActionRequest) (*ActionResponse, error)
TriggerAction triggers a specific action
FaultInjectorClient.TriggerBDBNetworkLatency
func (c *FaultInjectorClient) TriggerBDBNetworkLatency(ctx context.Context, bdbID, clusterIndex int, delay, duration time.Duration) (*ActionResponse, error)
TriggerBDBNetworkLatency adds delay to every node hosting BDBID with tc/netem for duration, then the node removes it by itself. A duration is required: without one the latency is permanent and only removable over SSH, so this refuses to send such a request. (SimulateNetworkLatency is the older, node-addressed variant and takes different parameters.)
FaultInjectorClient.TriggerClusterFailover
func (c *FaultInjectorClient) TriggerClusterFailover(ctx context.Context, nodeID string, force bool) (*ActionResponse, error)
TriggerClusterFailover triggers a cluster failover
FaultInjectorClient.TriggerClusterReshard
func (c *FaultInjectorClient) TriggerClusterReshard(ctx context.Context, slots []int, sourceNode, targetNode string) (*ActionResponse, error)
TriggerClusterReshard is DEPRECATED - use TriggerSlotMigrateSlotShuffle instead The fault injector does not support a 'cluster_reshard' action type. Use the /slot-migrate endpoint with effect=slot-shuffle instead.
FaultInjectorClient.TriggerNetworkFailure
func (c *FaultInjectorClient) TriggerNetworkFailure(ctx context.Context, bdbID, clusterIndex, delaySeconds int) (*ActionResponse, error)
TriggerNetworkFailure triggers a network_failure action: blocks traffic to every node hosting bdbID within the cluster/region at clusterIndex for delaySeconds, then restores automatically. Used by multidb/e2e's Active-Active failover scenarios.
FaultInjectorClient.TriggerProxyFailure
func (c *FaultInjectorClient) TriggerProxyFailure(ctx context.Context, req ProxyFailureRequest) (*ActionResponse, error)
TriggerProxyFailure runs a proxy_failure action. A stop is NOT undone by the fault injector: the caller must send a start (see ProxyStart).
FaultInjectorClient.TriggerSequence
func (c *FaultInjectorClient) TriggerSequence(ctx context.Context, bdbID int, actions []SequenceAction) (*ActionResponse, error)
FaultInjectorClient.TriggerSlotMigrate
func (c *FaultInjectorClient) TriggerSlotMigrate(ctx context.Context, req SlotMigrateRequest) (*ActionResponse, error)
TriggerSlotMigrate triggers a slot migration with the specified effect and variant This is the new API for testing OSS Cluster API client behavior during endpoint changes
Effects:
- remove-add: One endpoint removed, one added (migrate all shards to empty node)
- remove: One endpoint removed (migrate all shards to existing node)
- add: One endpoint added (migrate one shard to empty node)
- slot-shuffle: Slots moved without endpoint change (migrate one shard between existing nodes)
Variants:
- default/migrate: Use rladmin migrate to move shards
- maintenance_mode: Put node in maintenance mode (only for remove-add, remove)
- failover: Trigger failover to swap master/replica roles (requires replication)
FaultInjectorClient.TriggerSlotMigrateAdd
func (c *FaultInjectorClient) TriggerSlotMigrateAdd(ctx context.Context, bdbID string, trigger SlotMigrateVariant) (*ActionResponse, error)
TriggerSlotMigrateAdd triggers an add slot migration This migrates one shard to an empty node Result: One endpoint added
FaultInjectorClient.TriggerSlotMigrateRemove
func (c *FaultInjectorClient) TriggerSlotMigrateRemove(ctx context.Context, bdbID string, trigger SlotMigrateVariant) (*ActionResponse, error)
TriggerSlotMigrateRemove triggers a remove slot migration This migrates all shards from source node to an existing node Result: One endpoint removed
FaultInjectorClient.TriggerSlotMigrateRemoveAdd
func (c *FaultInjectorClient) TriggerSlotMigrateRemoveAdd(ctx context.Context, bdbID string, trigger SlotMigrateVariant) (*ActionResponse, error)
TriggerSlotMigrateRemoveAdd triggers a remove-add slot migration This migrates all shards from source node to an empty node Result: One endpoint removed, one endpoint added
FaultInjectorClient.TriggerSlotMigrateSlotShuffle
func (c *FaultInjectorClient) TriggerSlotMigrateSlotShuffle(ctx context.Context, bdbID string, trigger SlotMigrateVariant) (*ActionResponse, error)
TriggerSlotMigrateSlotShuffle triggers a slot-shuffle migration This migrates one shard between existing nodes Result: Slots move, endpoints unchanged
FaultInjectorClient.TriggerSlotMigration
func (c *FaultInjectorClient) TriggerSlotMigration(ctx context.Context, startSlot, endSlot int, sourceNode, targetNode string) (*ActionResponse, error)
TriggerSlotMigration triggers migration of specific slots (legacy API)
FaultInjectorClient.TriggerTopologyChangeStandalone
func (c *FaultInjectorClient) TriggerTopologyChangeStandalone(ctx context.Context, req StandaloneTriggerRequest) (*ActionResponse, error)
TriggerTopologyChangeStandalone starts the topology change and returns the action to poll with WaitForAction.
FaultInjectorClient.WaitForAction
func (c *FaultInjectorClient) WaitForAction(ctx context.Context, actionID string, options ...WaitOption) (*ActionStatusResponse, error)
WaitForAction waits for an action to complete
ProxyFailureOp
type ProxyFailureOp string
ProxyFailureOp is what proxy_failure does to the proxy process.
ProxyStop (3 declarations)
const ( ProxyStop ProxyFailureOp = "stop" ProxyStart ProxyFailureOp = "start" ProxyRestart ProxyFailureOp = "restart" )
ProxyFailureRequest
type ProxyFailureRequest struct {
BDBID int
ClusterIndex int
Op ProxyFailureOp
// WaitForActive blocks the action until the database is active and its
// endpoint available again. Only meaningful for start and restart: after
// stop the database never becomes active.
WaitForActive bool
}
ProxyFailureRequest targets the proxy on every node hosting BDBID. Targeting a single node (node_id) is deliberately not exposed: it is not needed for client scenarios, and the proxy of a shared cluster node serves other databases too.
ProxyFaultInjectorServer
type ProxyFaultInjectorServer struct {
// contains filtered or unexported fields
}
ProxyFaultInjectorServer mimics the fault injector server using cae-resp-proxy This allows existing e2e tests to work unchanged - they just point to this server instead of the real fault injector
NewProxyFaultInjectorServer
func NewProxyFaultInjectorServer(listenAddr string, proxyAPIPort int) *ProxyFaultInjectorServer
NewProxyFaultInjectorServer creates a new proxy-based fault injector server
NewProxyFaultInjectorServerWithURL
func NewProxyFaultInjectorServerWithURL(listenAddr string, proxyAPIURL string) *ProxyFaultInjectorServer
NewProxyFaultInjectorServerWithURL creates a new proxy-based fault injector server with a custom proxy API URL
ProxyFaultInjectorServer.GetClusterAddrs
func (s *ProxyFaultInjectorServer) GetClusterAddrs() []string
GetClusterAddrs returns the cluster addresses for connecting
ProxyFaultInjectorServer.Start
func (s *ProxyFaultInjectorServer) Start() error
Start starts both the proxy and the fault injector API server
ProxyFaultInjectorServer.Stop
func (s *ProxyFaultInjectorServer) Stop() error
Stop stops both the proxy and the HTTP server Only stops the server if this instance started it
SequenceAction
type SequenceAction struct {
Type ActionType `json:"type"`
Parameters map[string]interface{} `json:"params,omitempty"`
Delay time.Duration `json:"delay,omitempty"`
}
SequenceAction represents an action in a sequence
ShardKeyRegexPattern
type ShardKeyRegexPattern struct {
Regex string `json:"regex"`
}
ShardKeyRegexPattern represents a shard key regex pattern
SlotMigrateEffect
type SlotMigrateEffect string
SlotMigrateEffect represents the effect type for slot migration
SlotMigrateEffectRemoveAdd (4 declarations)
const ( // SlotMigrateEffectRemoveAdd migrates all shards from source node to empty node // Result: One endpoint removed, one endpoint added SlotMigrateEffectRemoveAdd SlotMigrateEffect = "remove-add" // SlotMigrateEffectRemove migrates all shards from source node to existing node // Result: One endpoint removed SlotMigrateEffectRemove SlotMigrateEffect = "remove" // SlotMigrateEffectAdd migrates one shard to empty node // Result: One endpoint added SlotMigrateEffectAdd SlotMigrateEffect = "add" // SlotMigrateEffectSlotShuffle migrates one shard between existing nodes // Result: Slots move, endpoints unchanged SlotMigrateEffectSlotShuffle SlotMigrateEffect = "slot-shuffle" )
SlotMigrateRequest
type SlotMigrateRequest struct {
Effect SlotMigrateEffect `json:"effect"`
BdbID string `json:"bdb_id"`
ClusterIndex int `json:"cluster_index,omitempty"`
Trigger SlotMigrateVariant `json:"variant,omitempty"`
SourceNode *int `json:"source_node,omitempty"`
TargetNode *int `json:"target_node,omitempty"`
}
SlotMigrateRequest represents a request to trigger a slot migration
SlotMigrateTrigger
type SlotMigrateTrigger struct {
Name string `json:"name"`
Description string `json:"description"`
Requirements []SlotMigrateTriggerRequirement `json:"requirements"`
}
SlotMigrateTrigger represents a trigger configuration for slot migration
SlotMigrateTriggerRequirement
type SlotMigrateTriggerRequirement struct {
DBConfig map[string]interface{} `json:"dbconfig"`
Cluster map[string]interface{} `json:"cluster"`
Description string `json:"description"`
}
SlotMigrateTriggerRequirement represents database configuration requirements
SlotMigrateTriggersResponse
type SlotMigrateTriggersResponse struct {
Effect SlotMigrateEffect `json:"effect"`
Cluster map[string]interface{} `json:"cluster"`
Triggers []SlotMigrateTrigger `json:"triggers"`
}
SlotMigrateTriggersResponse represents the response from GET /slot-migrate
SlotMigrateVariant
type SlotMigrateVariant string
SlotMigrateVariant represents the mechanism to achieve the slot migration effect
SlotMigrateVariantDefault (3 declarations)
const ( // SlotMigrateVariantDefault is an alias for migrate SlotMigrateVariantDefault SlotMigrateVariant = "default" // SlotMigrateVariantMigrate uses rladmin migrate to move shards SlotMigrateVariantMigrate SlotMigrateVariant = "migrate" // SlotMigrateVariantFailover triggers failover to swap master/replica roles // Requires replication to be enabled SlotMigrateVariantFailover SlotMigrateVariant = "failover" )
StandaloneEffect
type StandaloneEffect string
StandaloneEffect is a client-observable effect of /topology-change-standalone.
StandaloneDataMovementConnDrop (4 declarations)
const ( StandaloneDataMovementConnDrop StandaloneEffect = "data_movement_conn_drop" StandaloneDataMovementNoConnDrop StandaloneEffect = "data_movement_no_conn_drop" StandaloneConnDrop StandaloneEffect = "conn_drop" StandaloneDNSResolutionChange StandaloneEffect = "dns_resolution_change" )
StandaloneRequirement
type StandaloneRequirement struct {
Config string `json:"config"`
DBConfig json.RawMessage `json:"dbconfig"`
}
StandaloneRequirement is one database config that supports a trigger. DBConfig stays raw: it is passed to create_database server-side and its shape is not this client's business.
StandaloneSetup
type StandaloneSetup struct {
SetupID string
BDBID string
Effect StandaloneEffect
Trigger string
Config string
ClusterIndex int
DBName string
// Endpoints are redis:// or rediss:// URLs.
Endpoints []string
Password string
TLS bool
}
StandaloneSetup is the body of POST /topology-change-standalone/setup. The FI owns the database: BDBID is a string on the wire in some versions and a number in others, so it is kept as the decoded text.
StandaloneSetup.UnmarshalJSON
func (s *StandaloneSetup) UnmarshalJSON(b []byte) error
UnmarshalJSON accepts a numeric or string bdb_id and ignores unknown fields.
StandaloneTrigger
type StandaloneTrigger struct {
Name string `json:"name"`
Description string `json:"description"`
Requirements []StandaloneRequirement `json:"requirements"`
}
StandaloneTrigger is one mechanism for an effect, as listed by the FI.
StandaloneTriggerRequest
type StandaloneTriggerRequest struct {
Effect StandaloneEffect
Trigger string
SetupID string
BDBID string
ClusterIndex int
SourceNode *int
TargetNode *int
// ReshardFactor is the TARGET master shard count for the reshard trigger.
ReshardFactor *int
// AutomaticallyCleanMM turns maintenance mode off again after 10s
// (maintenance_mode trigger only).
AutomaticallyCleanMM bool
}
StandaloneTriggerRequest runs a topology change on a database from SetupTopologyChangeStandalone (SetupID) or an explicit BDBID.
StandaloneTriggersResponse
type StandaloneTriggersResponse struct {
Effect StandaloneEffect `json:"effect"`
Triggers []StandaloneTrigger `json:"triggers"`
Cluster struct {
Index int `json:"index"`
Nodes int `json:"nodes"`
} `json:"cluster"`
}
StandaloneTriggersResponse is the body of GET /topology-change-standalone.
WaitOption
type WaitOption func(*waitConfig)
WithMaxWaitTime
func WithMaxWaitTime(maxWait time.Duration) WaitOption
WithMaxWaitTime sets the maximum wait time
WithPollInterval
func WithPollInterval(interval time.Duration) WaitOption
WithPollInterval sets the polling interval for waiting