Documentation
¶
Index ¶
- Constants
- Variables
- func CompareSnapshots(before, after *NetworkHealthSnapshot) bool
- type ChaosInjector
- func (ci *ChaosInjector) GetActiveFaults() map[string]FaultConfig
- func (ci *ChaosInjector) InjectFault(ctx context.Context, config FaultConfig) error
- func (ci *ChaosInjector) InjectRandomFault(ctx context.Context, faultTypes []FaultType, probability float64, ...) error
- func (ci *ChaosInjector) PartitionNodesByID(ctx context.Context, nodeIDs []ids.NodeID, duration time.Duration) error
- func (ci *ChaosInjector) Stop()
- type FaultConfig
- type FaultType
- type NetworkHealthSnapshot
- type RecoveryVerifier
- func (rv *RecoveryVerifier) CaptureHealthSnapshot(ctx context.Context) (*NetworkHealthSnapshot, error)
- func (rv *RecoveryVerifier) VerifyConsensusProgressing(ctx context.Context, minBlocks uint64) error
- func (rv *RecoveryVerifier) VerifyFullRecovery(ctx context.Context, tc tests.TestContext) error
- func (rv *RecoveryVerifier) VerifyNetworkHealth(ctx context.Context) error
- func (rv *RecoveryVerifier) VerifyNodeConnectivity(ctx context.Context) error
- func (rv *RecoveryVerifier) WaitForNetworkHealth(ctx context.Context, timeout time.Duration) error
- func (rv *RecoveryVerifier) WaitForNodeConnectivity(ctx context.Context, timeout time.Duration) error
Constants ¶
const ( // DefaultHealthCheckTimeout is default timeout for health checks DefaultHealthCheckTimeout = 2 * time.Minute // DefaultHealthCheckInterval is default interval between health checks DefaultHealthCheckInterval = 2 * time.Second // DefaultConsensusTimeout is default timeout for consensus verification DefaultConsensusTimeout = 5 * time.Minute // DefaultConsensusInterval is default interval between consensus checks DefaultConsensusInterval = 5 * time.Second )
Variables ¶
Functions ¶
func CompareSnapshots ¶
func CompareSnapshots(before, after *NetworkHealthSnapshot) bool
CompareSnapshots compares two health snapshots and returns whether recovery occurred
Types ¶
type ChaosInjector ¶
type ChaosInjector struct {
// contains filtered or unexported fields
}
ChaosInjector manages chaos injection into a network
func NewChaosInjector ¶
func NewChaosInjector(network *tmpnet.Network, logger log.Logger) *ChaosInjector
NewChaosInjector creates a new chaos injector for the given network
func (*ChaosInjector) GetActiveFaults ¶
func (ci *ChaosInjector) GetActiveFaults() map[string]FaultConfig
GetActiveFaults returns the currently active faults
func (*ChaosInjector) InjectFault ¶
func (ci *ChaosInjector) InjectFault(ctx context.Context, config FaultConfig) error
InjectFault injects a specific fault into the network
func (*ChaosInjector) InjectRandomFault ¶
func (ci *ChaosInjector) InjectRandomFault(ctx context.Context, faultTypes []FaultType, probability float64, duration time.Duration) error
InjectRandomFault injects a random fault based on probability
func (*ChaosInjector) PartitionNodesByID ¶
func (ci *ChaosInjector) PartitionNodesByID(ctx context.Context, nodeIDs []ids.NodeID, duration time.Duration) error
PartitionNodesByID partitions network by isolating specific node IDs
type FaultConfig ¶
type FaultConfig struct {
Type FaultType
TargetNodes []*tmpnet.Node
Duration time.Duration
Probability float64 // 0.0 to 1.0
Parameters map[string]interface{}
}
FaultConfig defines configuration for a specific fault injection
type FaultType ¶
type FaultType string
FaultType defines the type of chaos injection
const ( // Network faults FaultTypePartition FaultType = "partition" FaultTypeLatency FaultType = "latency" FaultTypePacketLoss FaultType = "packet_loss" FaultTypeBandwidth FaultType = "bandwidth" // Node faults FaultTypeCrash FaultType = "crash" FaultTypeShutdown FaultType = "shutdown" FaultTypeFreeze FaultType = "freeze" // Byzantine faults FaultTypeInvalidMessage FaultType = "invalid_message" FaultTypeEquivocation FaultType = "equivocation" FaultTypeWithhold FaultType = "withhold" // Resource faults FaultTypeCPUThrottle FaultType = "cpu_throttle" FaultTypeMemory FaultType = "memory_pressure" FaultTypeDiskIO FaultType = "disk_io" )
type NetworkHealthSnapshot ¶
type NetworkHealthSnapshot struct {
Timestamp time.Time
HealthyNodes int
TotalNodes int
Connectivity map[ids.NodeID]int // NodeID -> peer count
}
NetworkHealthSnapshot captures current network health state
type RecoveryVerifier ¶
type RecoveryVerifier struct {
// contains filtered or unexported fields
}
RecoveryVerifier verifies that a network has recovered from chaos injection
func NewRecoveryVerifier ¶
func NewRecoveryVerifier(network *tmpnet.Network, logger log.Logger) *RecoveryVerifier
NewRecoveryVerifier creates a new recovery verifier
func (*RecoveryVerifier) CaptureHealthSnapshot ¶
func (rv *RecoveryVerifier) CaptureHealthSnapshot(ctx context.Context) (*NetworkHealthSnapshot, error)
CaptureHealthSnapshot captures current network health state
func (*RecoveryVerifier) VerifyConsensusProgressing ¶
func (rv *RecoveryVerifier) VerifyConsensusProgressing(ctx context.Context, minBlocks uint64) error
VerifyConsensusProgressing checks that consensus is making progress by verifying that P-Chain height is increasing
func (*RecoveryVerifier) VerifyFullRecovery ¶
func (rv *RecoveryVerifier) VerifyFullRecovery(ctx context.Context, tc tests.TestContext) error
VerifyFullRecovery performs comprehensive recovery verification
func (*RecoveryVerifier) VerifyNetworkHealth ¶
func (rv *RecoveryVerifier) VerifyNetworkHealth(ctx context.Context) error
VerifyNetworkHealth checks that all nodes in the network are healthy
func (*RecoveryVerifier) VerifyNodeConnectivity ¶
func (rv *RecoveryVerifier) VerifyNodeConnectivity(ctx context.Context) error
VerifyNodeConnectivity checks that all nodes are connected to their peers
func (*RecoveryVerifier) WaitForNetworkHealth ¶
WaitForNetworkHealth waits for all nodes to become healthy with timeout
func (*RecoveryVerifier) WaitForNodeConnectivity ¶
func (rv *RecoveryVerifier) WaitForNodeConnectivity(ctx context.Context, timeout time.Duration) error
WaitForNodeConnectivity waits for all nodes to be connected with timeout