@@ -145,17 +145,23 @@ class ThroughputProbingTest : public ServiceContextTest {
145
145
return !concurrencyIncreased () && !concurrencyDecreased ();
146
146
}
147
147
148
+ bool probeIncemented (std::string a) const {
149
+ return _stats[a].Long () > _prevStats[a].Long ();
150
+ }
151
+
148
152
std::string toString () const {
149
153
return str::stream () << " Stats: " << _stats << " , previous stats: " << _prevStats;
150
154
}
151
155
152
156
private:
153
157
BSONObj _stats =
154
158
BSON (" timesDecreased" << 0ll << " timesIncreased" << 0ll << " totalAmountDecreased" << 0ll
155
- << " totalAmountIncreased" << 0ll );
159
+ << " totalAmountIncreased" << 0ll << " timesProbedStable" << 0ll
160
+ << " timesProbedUp" << 0ll << " timesProbedDown" << 0ll );
156
161
BSONObj _prevStats =
157
162
BSON (" timesDecreased" << 0ll << " timesIncreased" << 0ll << " totalAmountDecreased" << 0ll
158
- << " totalAmountIncreased" << 0ll );
163
+ << " totalAmountIncreased" << 0ll << " timesProbedStable" << 0ll
164
+ << " timesProbedUp" << 0ll << " timesProbedDown" << 0ll );
159
165
} _statsTester;
160
166
};
161
167
@@ -208,6 +214,9 @@ TEST_F(ThroughputProbingTest, ProbeUpSucceeds) {
208
214
ASSERT_GT (_readTicketHolder.outof (), initialSize);
209
215
ASSERT_LT (_writeTicketHolder.outof (), size);
210
216
ASSERT_GT (_writeTicketHolder.outof (), initialSize);
217
+ ASSERT_TRUE (_statsTester.probeIncemented (" timesProbedUp" ));
218
+ ASSERT_FALSE (_statsTester.probeIncemented (" timesProbedDown" ));
219
+ ASSERT_FALSE (_statsTester.probeIncemented (" timesProbedStable" ));
211
220
ASSERT (_statsTester.concurrencyIncreased ()) << _statsTester.toString ();
212
221
}
213
222
@@ -231,6 +240,9 @@ TEST_F(ThroughputProbingTest, ProbeUpFails) {
231
240
_run ();
232
241
ASSERT_EQ (_readTicketHolder.outof (), size);
233
242
ASSERT_EQ (_writeTicketHolder.outof (), size);
243
+ ASSERT_TRUE (_statsTester.probeIncemented (" timesProbedUp" ));
244
+ ASSERT_FALSE (_statsTester.probeIncemented (" timesProbedDown" ));
245
+ ASSERT_FALSE (_statsTester.probeIncemented (" timesProbedStable" ));
234
246
ASSERT (_statsTester.concurrencyKept ()) << _statsTester.toString ();
235
247
}
236
248
@@ -259,6 +271,9 @@ TEST_F(ThroughputProbingTest, ProbeDownSucceeds) {
259
271
ASSERT_GT (_readTicketHolder.outof (), size);
260
272
ASSERT_LT (_writeTicketHolder.outof (), initialSize);
261
273
ASSERT_GT (_writeTicketHolder.outof (), size);
274
+ ASSERT_TRUE (_statsTester.probeIncemented (" timesProbedDown" ));
275
+ ASSERT_FALSE (_statsTester.probeIncemented (" timesProbedUp" ));
276
+ ASSERT_FALSE (_statsTester.probeIncemented (" timesProbedStable" ));
262
277
ASSERT (_statsTester.concurrencyDecreased ()) << _statsTester.toString ();
263
278
}
264
279
@@ -282,6 +297,9 @@ TEST_F(ThroughputProbingTest, ProbeDownFails) {
282
297
_run ();
283
298
ASSERT_EQ (_readTicketHolder.outof (), size);
284
299
ASSERT_EQ (_writeTicketHolder.outof (), size);
300
+ ASSERT_TRUE (_statsTester.probeIncemented (" timesProbedDown" ));
301
+ ASSERT_FALSE (_statsTester.probeIncemented (" timesProbedUp" ));
302
+ ASSERT_FALSE (_statsTester.probeIncemented (" timesProbedStable" ));
285
303
ASSERT (_statsTester.concurrencyKept ()) << _statsTester.toString ();
286
304
}
287
305
@@ -295,6 +313,8 @@ TEST_F(ThroughputProbingMaxConcurrencyTest, NoProbeUp) {
295
313
// Stable. Probe down since concurrency is already at its maximum allowed value, even though
296
314
// ticktes are exhausted.
297
315
_run ();
316
+ ASSERT_TRUE (_statsTester.probeIncemented (" timesProbedStable" ));
317
+ ASSERT_FALSE (_statsTester.probeIncemented (" timesProbedUp" ));
298
318
ASSERT_LT (_readTicketHolder.outof (), size);
299
319
ASSERT_LT (_writeTicketHolder.outof (), size);
300
320
}
@@ -309,6 +329,8 @@ TEST_F(ThroughputProbingMinConcurrencyTest, NoProbeDown) {
309
329
// Stable. Do not probe in either direction since tickets are not exhausted but concurrency is
310
330
// already at its minimum allowed value.
311
331
_run ();
332
+ ASSERT_TRUE (_statsTester.probeIncemented (" timesProbedStable" ));
333
+ ASSERT_FALSE (_statsTester.probeIncemented (" timesProbedDown" ));
312
334
ASSERT_EQ (_readTicketHolder.outof (), size);
313
335
ASSERT_EQ (_writeTicketHolder.outof (), size);
314
336
}
0 commit comments