Skip to content

Commit

Permalink
tests: make compaction period a configurable attribute.
Browse files Browse the repository at this point in the history
Keep the default value to 200ms while using shorter value for regression tests that require frequent compaction.

Signed-off-by: Jiayin Mao <[email protected]>
  • Loading branch information
jmao-dd committed Jan 15, 2025
1 parent 3e4923e commit 165edf0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/robustness/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var testRunner = framework.E2eTestRunner

var (
WaitBeforeFailpoint = time.Second
WaitJitter = traffic.CompactionPeriod
WaitJitter = traffic.DefaultCompactionPeriod
WaitAfterFailpoint = time.Second
)

Expand Down
2 changes: 1 addition & 1 deletion tests/robustness/scenarios/scenarios.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func Regression(t *testing.T) []TestScenario {
})
scenarios = append(scenarios, TestScenario{
Name: "Issue18089",
Profile: traffic.LowTraffic,
Profile: traffic.LowTraffic.WithCompactionPeriod(100 * time.Millisecond), // Use frequent compaction for high reproduce rate
Failpoint: failpoint.SleepBeforeSendWatchResponse,
Traffic: traffic.EtcdDelete,
Cluster: *e2e.NewConfig(
Expand Down
22 changes: 16 additions & 6 deletions tests/robustness/traffic/traffic.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ import (
)

var (
DefaultLeaseTTL int64 = 7200
RequestTimeout = 200 * time.Millisecond
WatchTimeout = time.Second
MultiOpTxnOpCount = 4
CompactionPeriod = 100 * time.Millisecond
DefaultLeaseTTL int64 = 7200
RequestTimeout = 200 * time.Millisecond
WatchTimeout = time.Second
MultiOpTxnOpCount = 4
DefaultCompactionPeriod = 200 * time.Millisecond

LowTraffic = Profile{
MinimalQPS: 100,
Expand Down Expand Up @@ -96,7 +96,11 @@ func SimulateTraffic(ctx context.Context, t *testing.T, lg *zap.Logger, clus *e2
defer wg.Done()
defer c.Close()

RunCompactLoop(ctx, c, CompactionPeriod, finish)
compactionPeriod := DefaultCompactionPeriod
if profile.CompactPeriod != time.Duration(0) {
compactionPeriod = profile.CompactPeriod
}
RunCompactLoop(ctx, c, compactionPeriod, finish)
mux.Lock()
reports = append(reports, c.Report())
mux.Unlock()
Expand Down Expand Up @@ -176,13 +180,19 @@ type Profile struct {
MaxNonUniqueRequestConcurrency int
ClientCount int
ForbidCompaction bool
CompactPeriod time.Duration
}

func (p Profile) WithoutCompaction() Profile {
p.ForbidCompaction = true
return p
}

func (p Profile) WithCompactionPeriod(cp time.Duration) Profile {
p.CompactPeriod = cp
return p
}

type Traffic interface {
Run(ctx context.Context, c *client.RecordingClient, qpsLimiter *rate.Limiter, ids identity.Provider, lm identity.LeaseIDStorage, nonUniqueWriteLimiter ConcurrencyLimiter, finish <-chan struct{})
ExpectUniqueRevision() bool
Expand Down

0 comments on commit 165edf0

Please sign in to comment.