Skip to content

Commit ce3de81

Browse files
committed
Review comments #2.
1 parent 6390e43 commit ce3de81

File tree

1 file changed

+17
-58
lines changed

1 file changed

+17
-58
lines changed

balancer/rls/internal/picker_test.go

Lines changed: 17 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -185,76 +185,65 @@ func TestPick(t *testing.T) {
185185
useChildPick bool
186186
// Request processing strategy as used by the picker.
187187
strategy rlspb.RouteLookupConfig_RequestProcessingStrategy
188-
// Expected pick result returned by the picker under test.
189-
wantResult balancer.PickResult
190188
// Expected error returned by the picker under test.
191189
wantErr error
192190
}{
193191
{
194-
desc: "cacheMiss_pending_defaultTargetOnError",
195-
pending: true,
196-
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
197-
wantResult: balancer.PickResult{},
198-
wantErr: balancer.ErrNoSubConnAvailable,
192+
desc: "cacheMiss_pending_defaultTargetOnError",
193+
pending: true,
194+
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
195+
wantErr: balancer.ErrNoSubConnAvailable,
199196
},
200197
{
201-
desc: "cacheMiss_pending_clientSeesError",
202-
pending: true,
203-
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
204-
wantResult: balancer.PickResult{},
205-
wantErr: balancer.ErrNoSubConnAvailable,
198+
desc: "cacheMiss_pending_clientSeesError",
199+
pending: true,
200+
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
201+
wantErr: balancer.ErrNoSubConnAvailable,
206202
},
207203
{
208204
desc: "cacheMiss_pending_defaultTargetOnMiss",
209205
pending: true,
210206
useDefaultPick: true,
211207
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
212-
wantResult: balancer.PickResult{},
213208
wantErr: nil,
214209
},
215210
{
216211
desc: "cacheMiss_noPending_notThrottled_defaultTargetOnError",
217212
newRLSRequest: true,
218213
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
219-
wantResult: balancer.PickResult{},
220214
wantErr: balancer.ErrNoSubConnAvailable,
221215
},
222216
{
223217
desc: "cacheMiss_noPending_notThrottled_clientSeesError",
224218
newRLSRequest: true,
225219
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
226-
wantResult: balancer.PickResult{},
227220
wantErr: balancer.ErrNoSubConnAvailable,
228221
},
229222
{
230223
desc: "cacheMiss_noPending_notThrottled_defaultTargetOnMiss",
231224
newRLSRequest: true,
232225
useDefaultPick: true,
233226
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
234-
wantResult: balancer.PickResult{},
235227
wantErr: nil,
236228
},
237229
{
238230
desc: "cacheMiss_noPending_throttled_defaultTargetOnError",
239231
throttle: true,
240232
useDefaultPick: true,
241233
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
242-
wantResult: balancer.PickResult{},
243234
wantErr: nil,
244235
},
245236
{
246-
desc: "cacheMiss_noPending_throttled_clientSeesError",
247-
throttle: true,
248-
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
249-
wantResult: balancer.PickResult{},
250-
wantErr: errRLSThrottled,
237+
desc: "cacheMiss_noPending_throttled_clientSeesError",
238+
throttle: true,
239+
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
240+
wantErr: errRLSThrottled,
251241
},
252242
{
253243
desc: "cacheMiss_noPending_throttled_defaultTargetOnMiss",
254244
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
255245
throttle: true,
256246
useDefaultPick: true,
257-
wantResult: balancer.PickResult{},
258247
wantErr: nil,
259248
},
260249
{
@@ -263,15 +252,13 @@ func TestPick(t *testing.T) {
263252
throttle: true,
264253
useDefaultPick: true,
265254
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
266-
wantResult: balancer.PickResult{},
267255
wantErr: nil,
268256
},
269257
{
270258
desc: "cacheHit_noPending_boExpired_dataExpired_throttled_clientSeesError",
271259
cacheEntry: &cache.Entry{}, // Everything is expired in this entry
272260
throttle: true,
273261
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
274-
wantResult: balancer.PickResult{},
275262
wantErr: errRLSThrottled,
276263
},
277264
{
@@ -280,7 +267,6 @@ func TestPick(t *testing.T) {
280267
throttle: true,
281268
useDefaultPick: true,
282269
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
283-
wantResult: balancer.PickResult{},
284270
wantErr: nil,
285271
},
286272
{
@@ -289,7 +275,6 @@ func TestPick(t *testing.T) {
289275
throttle: true, // Proactive refresh is throttled.
290276
useChildPick: true,
291277
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
292-
wantResult: balancer.PickResult{},
293278
wantErr: nil,
294279
},
295280
{
@@ -298,7 +283,6 @@ func TestPick(t *testing.T) {
298283
throttle: true, // Proactive refresh is throttled.
299284
useChildPick: true,
300285
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
301-
wantResult: balancer.PickResult{},
302286
wantErr: nil,
303287
},
304288
{
@@ -307,23 +291,20 @@ func TestPick(t *testing.T) {
307291
throttle: true, // Proactive refresh is throttled.
308292
useChildPick: true,
309293
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
310-
wantResult: balancer.PickResult{},
311294
wantErr: nil,
312295
},
313296
{
314297
desc: "cacheHit_noPending_boExpired_dataExpired_notThrottled_defaultTargetOnError",
315298
cacheEntry: &cache.Entry{}, // Everything is expired in this entry
316299
newRLSRequest: true,
317300
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
318-
wantResult: balancer.PickResult{},
319301
wantErr: balancer.ErrNoSubConnAvailable,
320302
},
321303
{
322304
desc: "cacheHit_noPending_boExpired_dataExpired_notThrottled_clientSeesError",
323305
cacheEntry: &cache.Entry{}, // Everything is expired in this entry
324306
newRLSRequest: true,
325307
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
326-
wantResult: balancer.PickResult{},
327308
wantErr: balancer.ErrNoSubConnAvailable,
328309
},
329310
{
@@ -332,7 +313,6 @@ func TestPick(t *testing.T) {
332313
newRLSRequest: true,
333314
useDefaultPick: true,
334315
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
335-
wantResult: balancer.PickResult{},
336316
wantErr: nil,
337317
},
338318
{
@@ -341,7 +321,6 @@ func TestPick(t *testing.T) {
341321
newRLSRequest: true, // Proactive refresh.
342322
useChildPick: true,
343323
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
344-
wantResult: balancer.PickResult{},
345324
wantErr: nil,
346325
},
347326
{
@@ -350,7 +329,6 @@ func TestPick(t *testing.T) {
350329
newRLSRequest: true, // Proactive refresh.
351330
useChildPick: true,
352331
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
353-
wantResult: balancer.PickResult{},
354332
wantErr: nil,
355333
},
356334
{
@@ -359,23 +337,20 @@ func TestPick(t *testing.T) {
359337
newRLSRequest: true, // Proactive refresh.
360338
useChildPick: true,
361339
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
362-
wantResult: balancer.PickResult{},
363340
wantErr: nil,
364341
},
365342
{
366343
desc: "cacheHit_noPending_stale_boNotExpired_dataExpired_defaultTargetOnError",
367344
cacheEntry: &cache.Entry{BackoffTime: time.Now().Add(maxAge)},
368345
useDefaultPick: true,
369346
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
370-
wantResult: balancer.PickResult{},
371347
wantErr: nil,
372348
},
373349
{
374350
desc: "cacheHit_noPending_stale_boNotExpired_dataExpired_defaultTargetOnMiss",
375351
cacheEntry: &cache.Entry{BackoffTime: time.Now().Add(maxAge)},
376352
useDefaultPick: true,
377353
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
378-
wantResult: balancer.PickResult{},
379354
wantErr: nil,
380355
},
381356
{
@@ -384,9 +359,8 @@ func TestPick(t *testing.T) {
384359
BackoffTime: time.Now().Add(maxAge),
385360
CallStatus: rlsLastErr,
386361
},
387-
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
388-
wantResult: balancer.PickResult{},
389-
wantErr: rlsLastErr,
362+
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
363+
wantErr: rlsLastErr,
390364
},
391365
{
392366
desc: "cacheHit_noPending_stale_boNotExpired_dataNotExpired_defaultTargetOnError",
@@ -397,7 +371,6 @@ func TestPick(t *testing.T) {
397371
},
398372
useChildPick: true,
399373
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
400-
wantResult: balancer.PickResult{},
401374
wantErr: nil,
402375
},
403376
{
@@ -409,7 +382,6 @@ func TestPick(t *testing.T) {
409382
},
410383
useChildPick: true,
411384
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
412-
wantResult: balancer.PickResult{},
413385
wantErr: nil,
414386
},
415387
{
@@ -421,7 +393,6 @@ func TestPick(t *testing.T) {
421393
},
422394
useChildPick: true,
423395
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
424-
wantResult: balancer.PickResult{},
425396
wantErr: nil,
426397
},
427398
{
@@ -432,7 +403,6 @@ func TestPick(t *testing.T) {
432403
},
433404
useChildPick: true,
434405
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
435-
wantResult: balancer.PickResult{},
436406
wantErr: nil,
437407
},
438408
{
@@ -443,7 +413,6 @@ func TestPick(t *testing.T) {
443413
},
444414
useChildPick: true,
445415
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
446-
wantResult: balancer.PickResult{},
447416
wantErr: nil,
448417
},
449418
{
@@ -454,14 +423,12 @@ func TestPick(t *testing.T) {
454423
},
455424
useChildPick: true,
456425
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
457-
wantResult: balancer.PickResult{},
458426
wantErr: nil,
459427
},
460428
{
461429
desc: "cacheHit_pending_dataExpired_boExpired_defaultTargetOnError",
462430
cacheEntry: &cache.Entry{},
463431
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
464-
wantResult: balancer.PickResult{},
465432
wantErr: balancer.ErrNoSubConnAvailable,
466433
},
467434
{
@@ -470,15 +437,13 @@ func TestPick(t *testing.T) {
470437
pending: true,
471438
useDefaultPick: true,
472439
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
473-
wantResult: balancer.PickResult{},
474440
wantErr: nil,
475441
},
476442
{
477443
desc: "cacheHit_pending_dataExpired_boExpired_clientSeesError",
478444
cacheEntry: &cache.Entry{},
479445
pending: true,
480446
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
481-
wantResult: balancer.PickResult{},
482447
wantErr: balancer.ErrNoSubConnAvailable,
483448
},
484449
{
@@ -489,7 +454,6 @@ func TestPick(t *testing.T) {
489454
},
490455
useDefaultPick: true,
491456
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
492-
wantResult: balancer.PickResult{},
493457
wantErr: nil,
494458
},
495459
{
@@ -501,7 +465,6 @@ func TestPick(t *testing.T) {
501465
pending: true,
502466
useDefaultPick: true,
503467
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
504-
wantResult: balancer.PickResult{},
505468
wantErr: nil,
506469
},
507470
{
@@ -510,18 +473,16 @@ func TestPick(t *testing.T) {
510473
BackoffTime: time.Now().Add(maxAge),
511474
CallStatus: rlsLastErr,
512475
},
513-
pending: true,
514-
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
515-
wantResult: balancer.PickResult{},
516-
wantErr: rlsLastErr,
476+
pending: true,
477+
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
478+
wantErr: rlsLastErr,
517479
},
518480
{
519481
desc: "cacheHit_pending_dataNotExpired_defaultTargetOnError",
520482
cacheEntry: &cache.Entry{ExpiryTime: time.Now().Add(maxAge)},
521483
pending: true,
522484
useChildPick: true,
523485
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR,
524-
wantResult: balancer.PickResult{},
525486
wantErr: nil,
526487
},
527488
{
@@ -530,7 +491,6 @@ func TestPick(t *testing.T) {
530491
pending: true,
531492
useChildPick: true,
532493
strategy: rlspb.RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS,
533-
wantResult: balancer.PickResult{},
534494
wantErr: nil,
535495
},
536496
{
@@ -539,7 +499,6 @@ func TestPick(t *testing.T) {
539499
pending: true,
540500
useChildPick: true,
541501
strategy: rlspb.RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR,
542-
wantResult: balancer.PickResult{},
543502
wantErr: nil,
544503
},
545504
}

0 commit comments

Comments
 (0)