@@ -149,13 +149,91 @@ func SimulateTraffic(ctx context.Context, t *testing.T, lg *zap.Logger, clus *e2
149
149
lg .Info ("Reporting traffic during failure injection" , zap .Int ("successes" , duringFailpointStats .Successes ), zap .Int ("failures" , duringFailpointStats .Failures ), zap .Float64 ("successRate" , duringFailpointStats .SuccessRate ()), zap .Duration ("period" , duringFailpointStats .Period ), zap .Float64 ("qps" , duringFailpointStats .QPS ()))
150
150
lg .Info ("Reporting traffic after failure injection" , zap .Int ("successes" , afterFailpointStats .Successes ), zap .Int ("failures" , afterFailpointStats .Failures ), zap .Float64 ("successRate" , afterFailpointStats .SuccessRate ()), zap .Duration ("period" , afterFailpointStats .Period ), zap .Float64 ("qps" , afterFailpointStats .QPS ()))
151
151
152
+ watchTotal := CalculateWatchStats (reports , startTime , endTime )
153
+ lg .Info ("Reporting complete watch" , zap .Int ("requests" , watchTotal .Requests ), zap .Int ("events" , watchTotal .Events ), zap .Float64 ("eventsQPS" , watchTotal .EventsQPS ()), zap .Int ("progressNotifies" , watchTotal .ProgressNotifies ), zap .Int ("immediateClosures" , watchTotal .ImmediateClosures ), zap .Duration ("period" , watchTotal .Period ), zap .Duration ("avgDuration" , watchTotal .AvgDuration ()))
154
+
152
155
if beforeFailpointStats .QPS () < profile .MinimalQPS {
153
156
t .Errorf ("Requiring minimal %f qps before failpoint injection for test results to be reliable, got %f qps" , profile .MinimalQPS , beforeFailpointStats .QPS ())
154
157
}
155
158
// TODO: Validate QPS post failpoint injection to ensure the that we sufficiently cover period when cluster recovers.
156
159
return reports
157
160
}
158
161
162
+ func CalculateWatchStats (reports []report.ClientReport , start , end time.Duration ) (ws watchStats ) {
163
+ ws .Period = end - start
164
+ if ws .Period <= 0 {
165
+ return ws
166
+ }
167
+
168
+ for _ , r := range reports {
169
+ for _ , w := range r .Watch {
170
+ var (
171
+ firstInWindow time.Duration
172
+ lastInWindow time.Duration
173
+ haveInWindow bool
174
+ noEventsYetInWindow = true
175
+ closedCounted = false
176
+ )
177
+
178
+ for _ , resp := range w .Responses {
179
+ if resp .Time < start || resp .Time > end {
180
+ continue
181
+ }
182
+ if ! haveInWindow {
183
+ firstInWindow = resp .Time
184
+ haveInWindow = true
185
+ }
186
+ lastInWindow = resp .Time
187
+ if resp .IsProgressNotify {
188
+ ws .ProgressNotifies ++
189
+ }
190
+ if len (resp .Events ) > 0 {
191
+ ws .Events += len (resp .Events )
192
+ noEventsYetInWindow = false
193
+ }
194
+ if resp .Error != "" && noEventsYetInWindow && ! closedCounted {
195
+ ws .ImmediateClosures ++
196
+ closedCounted = true
197
+ }
198
+ }
199
+
200
+ if haveInWindow {
201
+ ws .Requests ++
202
+ if lastInWindow > firstInWindow {
203
+ ws .SumDuration += lastInWindow - firstInWindow
204
+ ws .DurationsCount ++
205
+ }
206
+ }
207
+ }
208
+ }
209
+
210
+ return ws
211
+ }
212
+
213
+ type watchStats struct {
214
+ Period time.Duration
215
+ Requests int
216
+ Events int
217
+ ProgressNotifies int
218
+ ImmediateClosures int
219
+ SumDuration time.Duration
220
+ DurationsCount int
221
+ }
222
+
223
+ func (ws * watchStats ) AvgDuration () time.Duration {
224
+ if ws .DurationsCount == 0 {
225
+ return 0
226
+ }
227
+ return ws .SumDuration / time .Duration (ws .DurationsCount )
228
+ }
229
+
230
+ func (ws * watchStats ) EventsQPS () float64 {
231
+ if ws .Period <= 0 {
232
+ return 0
233
+ }
234
+ return float64 (ws .Events ) / ws .Period .Seconds ()
235
+ }
236
+
159
237
func CalculateStats (reports []report.ClientReport , start , end time.Duration ) (ts trafficStats ) {
160
238
ts .Period = end - start
161
239
0 commit comments