Skip to content

Commit 06f3ee9

Browse files
committed
Introduce ContinuousWatchCreation configuration for the robustness test
1 parent 88cd33b commit 06f3ee9

File tree

6 files changed

+67
-51
lines changed

6 files changed

+67
-51
lines changed

tests/antithesis/test-template/robustness/traffic/main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,12 @@ func runTraffic(ctx context.Context, lg *zap.Logger, tf traffic.Traffic, hosts [
121121
defer watchSet.Close()
122122
g.Go(func() error {
123123
err := client.CollectClusterWatchEvents(ctx, client.CollectClusterWatchEventsParam{
124-
Lg: lg,
125-
Endpoints: hosts,
126-
MaxRevisionChan: maxRevisionChan,
127-
Cfg: watchConfig,
128-
ClientSet: watchSet,
124+
Lg: lg,
125+
Endpoints: hosts,
126+
MaxRevisionChan: maxRevisionChan,
127+
Cfg: watchConfig,
128+
ClientSet: watchSet,
129+
ContinuousWatchCreation: 0,
129130
})
130131
return err
131132
})

tests/framework/e2e/cluster.go

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,13 @@ type EtcdProcessClusterConfig struct {
140140

141141
// Test config
142142

143-
KeepDataDir bool
144-
Logger *zap.Logger
145-
GoFailEnabled bool
146-
GoFailClientTimeout time.Duration
147-
LazyFSEnabled bool
148-
PeerProxy bool
143+
KeepDataDir bool
144+
Logger *zap.Logger
145+
GoFailEnabled bool
146+
GoFailClientTimeout time.Duration
147+
LazyFSEnabled bool
148+
PeerProxy bool
149+
ContinuousWatchCreation time.Duration
149150

150151
// Process config
151152

@@ -370,6 +371,12 @@ func WithPeerProxy(enabled bool) EPClusterOption {
370371
return func(c *EtcdProcessClusterConfig) { c.PeerProxy = enabled }
371372
}
372373

374+
func WithContinuousWatchCreation(interval time.Duration) EPClusterOption {
375+
return func(c *EtcdProcessClusterConfig) {
376+
c.ContinuousWatchCreation = interval
377+
}
378+
}
379+
373380
func WithClientHTTPSeparate(enabled bool) EPClusterOption {
374381
return func(c *EtcdProcessClusterConfig) { c.ClientHTTPSeparate = enabled }
375382
}
@@ -652,24 +659,25 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
652659
}
653660

654661
return &EtcdServerProcessConfig{
655-
lg: cfg.Logger,
656-
ExecPath: execPath,
657-
Args: args,
658-
EnvVars: envVars,
659-
TLSArgs: cfg.TLSArgs(),
660-
Client: cfg.Client,
661-
DataDirPath: dataDirPath,
662-
KeepDataDir: cfg.KeepDataDir,
663-
Name: name,
664-
PeerURL: peerAdvertiseURL,
665-
ClientURL: curl,
666-
ClientHTTPURL: clientHTTPURL,
667-
MetricsURL: murl,
668-
InitialToken: cfg.ServerConfig.InitialClusterToken,
669-
GoFailPort: gofailPort,
670-
GoFailClientTimeout: cfg.GoFailClientTimeout,
671-
Proxy: proxyCfg,
672-
LazyFSEnabled: cfg.LazyFSEnabled,
662+
lg: cfg.Logger,
663+
ExecPath: execPath,
664+
Args: args,
665+
EnvVars: envVars,
666+
TLSArgs: cfg.TLSArgs(),
667+
Client: cfg.Client,
668+
DataDirPath: dataDirPath,
669+
KeepDataDir: cfg.KeepDataDir,
670+
Name: name,
671+
PeerURL: peerAdvertiseURL,
672+
ClientURL: curl,
673+
ClientHTTPURL: clientHTTPURL,
674+
MetricsURL: murl,
675+
InitialToken: cfg.ServerConfig.InitialClusterToken,
676+
GoFailPort: gofailPort,
677+
GoFailClientTimeout: cfg.GoFailClientTimeout,
678+
Proxy: proxyCfg,
679+
LazyFSEnabled: cfg.LazyFSEnabled,
680+
ContinuousWatchCreation: cfg.ContinuousWatchCreation,
673681
}
674682
}
675683

tests/framework/e2e/etcd_process.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ type EtcdServerProcessConfig struct {
101101
GoFailPort int
102102
GoFailClientTimeout time.Duration
103103

104-
LazyFSEnabled bool
105-
Proxy *proxy.ServerConfig
104+
LazyFSEnabled bool
105+
Proxy *proxy.ServerConfig
106+
ContinuousWatchCreation time.Duration
106107
}
107108

108109
func NewEtcdServerProcess(tb testing.TB, cfg *EtcdServerProcessConfig) (*EtcdServerProcess, error) {

tests/robustness/client/watch.go

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ import (
2727
)
2828

2929
type CollectClusterWatchEventsParam struct {
30-
Lg *zap.Logger
31-
Endpoints []string
32-
MaxRevisionChan <-chan int64
33-
Cfg WatchConfig
34-
ClientSet *ClientSet
30+
Lg *zap.Logger
31+
Endpoints []string
32+
MaxRevisionChan <-chan int64
33+
Cfg WatchConfig
34+
ClientSet *ClientSet
35+
ContinuousWatchCreation time.Duration
3536
}
3637

3738
func CollectClusterWatchEvents(ctx context.Context, param CollectClusterWatchEventsParam) error {
@@ -62,16 +63,18 @@ func CollectClusterWatchEvents(ctx context.Context, param CollectClusterWatchEve
6263
return nil
6364
})
6465

65-
for _, endpoint := range endpoints {
66-
g.Go(func() error {
67-
c, err := clientSet.NewClient([]string{endpoint})
68-
if err != nil {
69-
return err
70-
}
71-
defer c.Close()
72-
period := 10 * time.Millisecond
73-
return openWatchPeriodically(ctx, &g, c, period, finish)
74-
})
66+
if param.ContinuousWatchCreation > 0 {
67+
for _, endpoint := range param.Endpoints {
68+
g.Go(func() error {
69+
c, err := param.ClientSet.NewClient([]string{endpoint})
70+
if err != nil {
71+
return err
72+
}
73+
defer c.Close()
74+
period := 10 * time.Millisecond
75+
return openWatchPeriodically(ctx, &g, c, period, finish)
76+
})
77+
}
7578
}
7679

7780
return g.Wait()
@@ -146,6 +149,7 @@ resetWatch:
146149
}
147150
}
148151

152+
// TODO: report created watches
149153
func openWatchPeriodically(ctx context.Context, g *errgroup.Group, c *RecordingClient, period time.Duration, finish <-chan struct{}) error {
150154
for {
151155
select {

tests/robustness/main_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,12 @@ func runScenario(ctx context.Context, t *testing.T, s scenarios.TestScenario, lg
168168
g.Go(func() error {
169169
endpoints := processEndpoints(clus)
170170
err := client.CollectClusterWatchEvents(ctx, client.CollectClusterWatchEventsParam{
171-
Lg: lg,
172-
Endpoints: endpoints,
173-
MaxRevisionChan: maxRevisionChan,
174-
Cfg: s.Watch,
175-
ClientSet: watchSet,
171+
Lg: lg,
172+
Endpoints: endpoints,
173+
MaxRevisionChan: maxRevisionChan,
174+
Cfg: s.Watch,
175+
ClientSet: watchSet,
176+
ContinuousWatchCreation: clus.Cfg.ContinuousWatchCreation,
176177
})
177178
return err
178179
})

tests/robustness/scenarios/scenarios.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ func Regression(t *testing.T) []TestScenario {
308308
e2e.WithGoFailEnabled(true),
309309
e2e.WithPeerProxy(true),
310310
e2e.WithIsPeerTLS(true),
311+
e2e.WithContinuousWatchCreation(1*time.Millisecond),
311312
),
312313
})
313314

0 commit comments

Comments
 (0)