@@ -28,7 +28,6 @@ import (
28
28
"go.etcd.io/etcd/tests/v3/robustness/client"
29
29
"go.etcd.io/etcd/tests/v3/robustness/identity"
30
30
"go.etcd.io/etcd/tests/v3/robustness/model"
31
- "go.etcd.io/etcd/tests/v3/robustness/random"
32
31
"go.etcd.io/etcd/tests/v3/robustness/report"
33
32
)
34
33
@@ -81,7 +80,7 @@ func SimulateTraffic(ctx context.Context, t *testing.T, lg *zap.Logger, clus *e2
81
80
defer wg .Done ()
82
81
defer c .Close ()
83
82
84
- traffic .Run (ctx , c , limiter , ids , lm , nonUniqueWriteLimiter , finish )
83
+ traffic .RunTrafficLoop (ctx , c , limiter , ids , lm , nonUniqueWriteLimiter , finish )
85
84
mux .Lock ()
86
85
reports = append (reports , c .Report ())
87
86
mux .Unlock ()
@@ -101,7 +100,8 @@ func SimulateTraffic(ctx context.Context, t *testing.T, lg *zap.Logger, clus *e2
101
100
if profile .CompactPeriod != time .Duration (0 ) {
102
101
compactionPeriod = profile .CompactPeriod
103
102
}
104
- RunCompactLoop (ctx , c , compactionPeriod , finish )
103
+
104
+ traffic .RunCompactLoop (ctx , c , compactionPeriod , finish )
105
105
mux .Lock ()
106
106
reports = append (reports , c .Report ())
107
107
mux .Unlock ()
@@ -195,35 +195,7 @@ func (p Profile) WithCompactionPeriod(cp time.Duration) Profile {
195
195
}
196
196
197
197
type Traffic interface {
198
- Run (ctx context.Context , c * client.RecordingClient , qpsLimiter * rate.Limiter , ids identity.Provider , lm identity.LeaseIDStorage , nonUniqueWriteLimiter ConcurrencyLimiter , finish <- chan struct {})
198
+ RunTrafficLoop (ctx context.Context , c * client.RecordingClient , qpsLimiter * rate.Limiter , ids identity.Provider , lm identity.LeaseIDStorage , nonUniqueWriteLimiter ConcurrencyLimiter , finish <- chan struct {})
199
+ RunCompactLoop (ctx context.Context , c * client.RecordingClient , period time.Duration , finish <- chan struct {})
199
200
ExpectUniqueRevision () bool
200
201
}
201
-
202
- func RunCompactLoop (ctx context.Context , c * client.RecordingClient , period time.Duration , finish <- chan struct {}) {
203
- var lastRev int64 = 2
204
- timer := time .NewTimer (period )
205
- for {
206
- timer .Reset (period )
207
- select {
208
- case <- ctx .Done ():
209
- return
210
- case <- finish :
211
- return
212
- case <- timer .C :
213
- }
214
- statusCtx , cancel := context .WithTimeout (ctx , RequestTimeout )
215
- resp , err := c .Status (statusCtx , c .Endpoints ()[0 ])
216
- cancel ()
217
- if err != nil {
218
- continue
219
- }
220
-
221
- // Range allows for both revision has been compacted and future revision errors
222
- compactRev := random .RandRange (lastRev , resp .Header .Revision + 5 )
223
- _ , err = c .Compact (ctx , compactRev )
224
- if err != nil {
225
- continue
226
- }
227
- lastRev = compactRev
228
- }
229
- }
0 commit comments