Documentation
¶
Index ¶
- Variables
- func TestScenarioRampUpFixed(t *testing.T)
- func TestScenarioSpikeFixed(t *testing.T)
- func TestScenarioStressRecoveryFixed(t *testing.T)
- func TestScenarioSustainedLoadFixed(t *testing.T)
- type Agent
- type BurstPattern
- type CallDepthTest
- type ConstantRatePattern
- type ContractCreationTest
- type ExternalCallTest
- type HashingTest
- type Issuer
- type LargeEventTest
- type LatencyPercentiles
- type LatencyTracker
- type Listener
- type LoadConfig
- type LoadGenerator
- type LoadPattern
- type LoadReport
- type MemoryTest
- type Metrics
- type Orchestrator
- type OrchestratorConfig
- type PureComputeTest
- type RampPattern
- type RandomWeightedTest
- type ReadTest
- type StateModificationTest
- type StepPattern
- type TPSController
- type Test
- type Tracker
- type TransferTest
- type TrieStressTest
- type TxID
- type Wallet
- type WavePattern
- type WeightedTest
- type Worker
- type WriteTest
Constants ¶
This section is empty.
Variables ¶
var ErrFailedToIssueTx = errors.New("failed to issue transaction")
var ErrFailedToReachTargetTPS = errors.New("failed to reach target TPS")
Functions ¶
func TestScenarioRampUpFixed ¶ added in v1.20.5
TestScenarioRampUpFixed tests gradually increasing TPS with improved mocks
func TestScenarioSpikeFixed ¶ added in v1.20.5
TestScenarioSpikeFixed tests sudden TPS burst with improved synchronization
func TestScenarioStressRecoveryFixed ¶ added in v1.20.5
TestScenarioStressRecoveryFixed tests recovery with improved failure handling
func TestScenarioSustainedLoadFixed ¶ added in v1.20.5
TestScenarioSustainedLoadFixed tests constant TPS with better timing
Types ¶
type BurstPattern ¶ added in v1.20.5
type BurstPattern struct {
// contains filtered or unexported fields
}
BurstPattern generates bursts of load
func NewBurstPattern ¶ added in v1.20.5
func NewBurstPattern(burstSize int, burstInterval time.Duration) *BurstPattern
func (*BurstPattern) NextDelay ¶ added in v1.20.5
func (b *BurstPattern) NextDelay() time.Duration
func (*BurstPattern) Reset ¶ added in v1.20.5
func (b *BurstPattern) Reset()
func (*BurstPattern) ShouldSend ¶ added in v1.20.5
func (b *BurstPattern) ShouldSend() bool
type CallDepthTest ¶ added in v1.11.14
type CallDepthTest struct {
Contract *contracts.EVMLoadSimulator
Count *big.Int
}
func (CallDepthTest) Run ¶ added in v1.11.14
func (c CallDepthTest) Run(tc tests.TestContext, wallet *Wallet)
type ConstantRatePattern ¶ added in v1.20.5
type ConstantRatePattern struct {
// contains filtered or unexported fields
}
ConstantRatePattern generates load at a constant rate
func NewConstantRatePattern ¶ added in v1.20.5
func NewConstantRatePattern(tps float64) *ConstantRatePattern
func (*ConstantRatePattern) NextDelay ¶ added in v1.20.5
func (c *ConstantRatePattern) NextDelay() time.Duration
func (*ConstantRatePattern) Reset ¶ added in v1.20.5
func (c *ConstantRatePattern) Reset()
func (*ConstantRatePattern) ShouldSend ¶ added in v1.20.5
func (c *ConstantRatePattern) ShouldSend() bool
type ContractCreationTest ¶ added in v1.11.14
type ContractCreationTest struct {
Contract *contracts.EVMLoadSimulator
}
func (ContractCreationTest) Run ¶ added in v1.11.14
func (c ContractCreationTest) Run(tc tests.TestContext, wallet *Wallet)
type ExternalCallTest ¶ added in v1.11.14
type ExternalCallTest struct {
Contract *contracts.EVMLoadSimulator
}
func (ExternalCallTest) Run ¶ added in v1.11.14
func (e ExternalCallTest) Run(tc tests.TestContext, wallet *Wallet)
type HashingTest ¶ added in v1.11.14
type HashingTest struct {
Contract *contracts.EVMLoadSimulator
Count *big.Int
}
func (HashingTest) Run ¶ added in v1.11.14
func (h HashingTest) Run(tc tests.TestContext, wallet *Wallet)
type LargeEventTest ¶ added in v1.11.14
type LargeEventTest struct {
Contract *contracts.EVMLoadSimulator
NumEvents *big.Int
}
func (LargeEventTest) Run ¶ added in v1.11.14
func (l LargeEventTest) Run(tc tests.TestContext, wallet *Wallet)
type LatencyPercentiles ¶ added in v1.20.5
type LatencyPercentiles struct {
P50 float64 `json:"p50"`
P75 float64 `json:"p75"`
P90 float64 `json:"p90"`
P95 float64 `json:"p95"`
P99 float64 `json:"p99"`
P999 float64 `json:"p999"`
Min float64 `json:"min"`
Max float64 `json:"max"`
Mean float64 `json:"mean"`
StdDev float64 `json:"stddev"`
Count int `json:"count"`
}
LatencyPercentiles holds various percentile measurements
type LatencyTracker ¶ added in v1.20.5
type LatencyTracker struct {
// contains filtered or unexported fields
}
LatencyTracker tracks latency samples for percentile calculation
func NewLatencyTracker ¶ added in v1.20.5
func NewLatencyTracker() *LatencyTracker
func (*LatencyTracker) Clear ¶ added in v1.20.5
func (lt *LatencyTracker) Clear()
func (*LatencyTracker) GetPercentiles ¶ added in v1.20.5
func (lt *LatencyTracker) GetPercentiles() LatencyPercentiles
func (*LatencyTracker) Record ¶ added in v1.20.5
func (lt *LatencyTracker) Record(latencyMS float64)
type Listener ¶
type Listener[T TxID] interface { // Listen for the final status of transactions and notify the tracker // Listen stops if the context is done, an error occurs, or if it received // all the transactions issued and the issuer no longer issues any. // Listen MUST return a nil error if the context is canceled. Listen(ctx context.Context) error // RegisterIssued informs the listener that a transaction was issued. RegisterIssued(txID T) // IssuingDone informs the listener that no more transactions will be issued. IssuingDone() }
type LoadConfig ¶ added in v1.20.5
type LoadConfig struct {
Pattern LoadPattern
MaxTPS float64
Duration time.Duration
WarmupPeriod time.Duration
}
LoadConfig defines configuration for load generation
type LoadGenerator ¶ added in v1.11.14
type LoadGenerator struct {
// contains filtered or unexported fields
}
func NewLoadGenerator ¶ added in v1.11.14
type LoadPattern ¶ added in v1.20.5
type LoadPattern interface {
// NextDelay returns the delay before the next transaction
NextDelay() time.Duration
// ShouldSend determines if a transaction should be sent now
ShouldSend() bool
// Reset resets the pattern state
Reset()
}
LoadPattern defines different load generation patterns
type LoadReport ¶ added in v1.20.5
type LoadReport struct {
StartTime time.Time
EndTime time.Time
Duration time.Duration
TotalTransactions uint64
SuccessfulTx uint64
FailedTx uint64
AverageTPS float64
PeakTPS float64
SuccessRate float64
LatencyPercentiles LatencyPercentiles
ErrorDistribution map[string]uint64
}
LoadReport contains load test results
func (LoadReport) String ¶ added in v1.20.5
func (r LoadReport) String() string
type MemoryTest ¶ added in v1.11.14
type MemoryTest struct {
Contract *contracts.EVMLoadSimulator
Count *big.Int
}
func (MemoryTest) Run ¶ added in v1.11.14
func (m MemoryTest) Run(tc tests.TestContext, wallet *Wallet)
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func (*Metrics) GetLatencyPercentiles ¶ added in v1.20.5
func (m *Metrics) GetLatencyPercentiles() LatencyPercentiles
func (*Metrics) IncIssuedTx ¶
func (m *Metrics) IncIssuedTx()
func (*Metrics) RecordConfirmedTx ¶
func (*Metrics) RecordFailedTx ¶
func (*Metrics) UpdateSuccessRate ¶ added in v1.20.5
type Orchestrator ¶
type Orchestrator[T TxID] struct { // contains filtered or unexported fields }
Orchestrator tests the network by continuously sending transactions at a given rate (currTargetTPS) and increasing that rate until it detects that the network can no longer make progress (i.e. the rate at the network accepts transactions is less than currTargetTPS).
func NewOrchestrator ¶
func NewOrchestrator[T TxID]( agents []Agent[T], tracker *Tracker[T], log log.Logger, config OrchestratorConfig, ) *Orchestrator[T]
func (*Orchestrator[_]) GetMaxObservedTPS ¶
func (o *Orchestrator[_]) GetMaxObservedTPS() int64
GetMaxObservedTPS returns the max TPS the orchestrator observed
type OrchestratorConfig ¶
type OrchestratorConfig struct {
// The maximum TPS the orchestrator should aim for.
//
// If set to -1, the orchestrator will behave in a burst fashion, instead
// sending MinTPS transactions at once and waiting sustainedTime seconds
// before checking if MinTPS transactions were confirmed as accepted.
MaxTPS int64
// The minimum TPS the orchestrator should start with.
MinTPS int64
// The step size to increase the TPS by.
Step int64
// The factor by which to pad the number of txs an issuer sends per second
// for example, if targetTPS = 1000 and numIssuers = 10, then each issuer
// will send (1000/10)*TxRateMultiplier transactions per second.
//
// Maintaining a multiplier above target provides a toggle to keep load
// persistently above instead of below target. This ensures load generation
// does not pause issuance at the target and persistently under-issue and
// fail to account for the time it takes to add more load.
TxRateMultiplier float64
// The time period which TPS is averaged over
// Similarly, the time period which the orchestrator will wait before
// computing the average TPS.
SustainedTime time.Duration
// The number of attempts to try achieving a given target TPS before giving up.
MaxAttempts uint64
// Whether the orchestrator should return if the maxTPS has been reached
Terminate bool
}
func NewOrchestratorConfig ¶
func NewOrchestratorConfig() OrchestratorConfig
NewOrchestratorConfig returns a default OrchestratorConfig with pre-set parameters for gradual load testing.
type PureComputeTest ¶ added in v1.11.14
type PureComputeTest struct {
Contract *contracts.EVMLoadSimulator
NumIterations *big.Int
}
func (PureComputeTest) Run ¶ added in v1.11.14
func (p PureComputeTest) Run(tc tests.TestContext, wallet *Wallet)
type RampPattern ¶ added in v1.20.5
type RampPattern struct {
// contains filtered or unexported fields
}
RampPattern gradually increases load
func NewRampPattern ¶ added in v1.20.5
func NewRampPattern(startTPS, endTPS float64, duration time.Duration) *RampPattern
func (*RampPattern) NextDelay ¶ added in v1.20.5
func (r *RampPattern) NextDelay() time.Duration
func (*RampPattern) Reset ¶ added in v1.20.5
func (r *RampPattern) Reset()
func (*RampPattern) ShouldSend ¶ added in v1.20.5
func (r *RampPattern) ShouldSend() bool
type RandomWeightedTest ¶ added in v1.11.14
type RandomWeightedTest struct {
// contains filtered or unexported fields
}
func NewRandomTest ¶ added in v1.11.14
func NewRandomTest( ctx context.Context, chainID *big.Int, worker *Worker, source rand.Source, ) (*RandomWeightedTest, error)
NewRandomTest creates a RandomWeightedTest containing a collection of EVM load testing scenarios.
This function handles the setup of the tests and also assigns each test an equal weight, making them equally likely to be selected during random test execution.
func NewRandomWeightedTest ¶ added in v1.11.14
func NewRandomWeightedTest( weightedTests []WeightedTest, source rand.Source, ) (*RandomWeightedTest, error)
func (*RandomWeightedTest) Run ¶ added in v1.11.14
func (r *RandomWeightedTest) Run(tc tests.TestContext, wallet *Wallet)
type ReadTest ¶ added in v1.11.14
type ReadTest struct {
Contract *contracts.EVMLoadSimulator
Count *big.Int
}
type StateModificationTest ¶ added in v1.11.14
type StateModificationTest struct {
Contract *contracts.EVMLoadSimulator
Count *big.Int
}
func (StateModificationTest) Run ¶ added in v1.11.14
func (s StateModificationTest) Run(tc tests.TestContext, wallet *Wallet)
type StepPattern ¶ added in v1.20.5
type StepPattern struct {
// contains filtered or unexported fields
}
StepPattern generates stepped load increases
func NewStepPattern ¶ added in v1.20.5
func NewStepPattern(steps []float64, stepDuration time.Duration) *StepPattern
func (*StepPattern) NextDelay ¶ added in v1.20.5
func (s *StepPattern) NextDelay() time.Duration
func (*StepPattern) Reset ¶ added in v1.20.5
func (s *StepPattern) Reset()
func (*StepPattern) ShouldSend ¶ added in v1.20.5
func (s *StepPattern) ShouldSend() bool
type TPSController ¶ added in v1.20.5
type TPSController struct {
// contains filtered or unexported fields
}
TPSController manages TPS targeting with feedback control
func NewTPSController ¶ added in v1.20.5
func NewTPSController(targetTPS float64) *TPSController
func (*TPSController) GetDelay ¶ added in v1.20.5
func (c *TPSController) GetDelay() time.Duration
func (*TPSController) GetStats ¶ added in v1.20.5
func (c *TPSController) GetStats() (targetTPS, actualTPS, adjustment float64)
func (*TPSController) SetTargetTPS ¶ added in v1.20.5
func (c *TPSController) SetTargetTPS(tps float64)
func (*TPSController) UpdateActualTPS ¶ added in v1.20.5
func (c *TPSController) UpdateActualTPS(count uint64)
type Test ¶ added in v1.11.14
type Test interface {
Run(tc tests.TestContext, wallet *Wallet)
}
type Tracker ¶
type Tracker[T TxID] struct { // contains filtered or unexported fields }
Tracker keeps track of the status of transactions. This is thread-safe and can be called in parallel by the issuer(s) or orchestrator.
func NewTracker ¶
NewTracker returns a new Tracker instance which records metrics for the number of transactions issued, confirmed, and failed. It also tracks the latency of transactions.
func (*Tracker[_]) GetObservedConfirmed ¶
GetObservedConfirmed returns the number of transactions that the tracker has confirmed were accepted.
func (*Tracker[_]) GetObservedFailed ¶
GetObservedFailed returns the number of transactions that the tracker has confirmed failed.
func (*Tracker[_]) GetObservedIssued ¶
GetObservedIssued returns the number of transactions that the tracker has confirmed were issued.
func (*Tracker[T]) Issue ¶
func (t *Tracker[T]) Issue(txID T)
Issue records a transaction that was submitted, but whose final status is not yet known.
func (*Tracker[T]) ObserveConfirmed ¶
func (t *Tracker[T]) ObserveConfirmed(txID T)
ObserveConfirmed records a transaction that was confirmed.
func (*Tracker[T]) ObserveFailed ¶
func (t *Tracker[T]) ObserveFailed(txID T)
ObserveFailed records a transaction that failed (e.g. expired)
type TransferTest ¶ added in v1.11.14
func (TransferTest) Run ¶ added in v1.11.14
func (t TransferTest) Run(tc tests.TestContext, wallet *Wallet)
type TrieStressTest ¶ added in v1.11.14
type TrieStressTest struct {
Contract *contracts.TrieStressTest
NumValues *big.Int
}
func (TrieStressTest) Run ¶ added in v1.11.14
func (t TrieStressTest) Run(tc tests.TestContext, wallet *Wallet)
type WavePattern ¶ added in v1.20.5
type WavePattern struct {
// contains filtered or unexported fields
}
WavePattern generates sinusoidal load pattern
func NewWavePattern ¶ added in v1.20.5
func NewWavePattern(minTPS, maxTPS float64, period time.Duration) *WavePattern
func (*WavePattern) NextDelay ¶ added in v1.20.5
func (w *WavePattern) NextDelay() time.Duration
func (*WavePattern) Reset ¶ added in v1.20.5
func (w *WavePattern) Reset()
func (*WavePattern) ShouldSend ¶ added in v1.20.5
func (w *WavePattern) ShouldSend() bool