@@ -38,10 +38,7 @@ import (
3838 "google.golang.org/grpc/metadata"
3939)
4040
41- const (
42- defaultTestTimeout = 1 * time .Second
43- maxAge = 5 * time .Second
44- )
41+ const defaultTestMaxAge = 5 * time .Second
4542
4643func initKeyBuilderMap () (keys.BuilderMap , error ) {
4744 kb1 := & rlspb.GrpcKeyBuilder {
@@ -124,8 +121,8 @@ func TestPickKeyBuilder(t *testing.T) {
124121
125122 now := time .Now ()
126123 return & cache.Entry {
127- ExpiryTime : now .Add (maxAge ),
128- StaleTime : now .Add (maxAge ),
124+ ExpiryTime : now .Add (defaultTestMaxAge ),
125+ StaleTime : now .Add (defaultTestMaxAge ),
129126 // Cache entry is configured with a child policy whose
130127 // picker always returns an empty PickResult and nil
131128 // error.
@@ -271,23 +268,23 @@ func TestPick(t *testing.T) {
271268 },
272269 {
273270 desc : "cacheHit_noPending_stale_boExpired_dataNotExpired_throttled_defaultTargetOnMiss" ,
274- cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (maxAge )},
271+ cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (defaultTestMaxAge )},
275272 throttle : true , // Proactive refresh is throttled.
276273 useChildPick : true ,
277274 strategy : rlspb .RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS ,
278275 wantErr : nil ,
279276 },
280277 {
281278 desc : "cacheHit_noPending_stale_boExpired_dataNotExpired_throttled_clientSeesError" ,
282- cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (maxAge )},
279+ cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (defaultTestMaxAge )},
283280 throttle : true , // Proactive refresh is throttled.
284281 useChildPick : true ,
285282 strategy : rlspb .RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR ,
286283 wantErr : nil ,
287284 },
288285 {
289286 desc : "cacheHit_noPending_stale_boExpired_dataNotExpired_throttled_defaultTargetOnError" ,
290- cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (maxAge )},
287+ cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (defaultTestMaxAge )},
291288 throttle : true , // Proactive refresh is throttled.
292289 useChildPick : true ,
293290 strategy : rlspb .RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR ,
@@ -317,46 +314,46 @@ func TestPick(t *testing.T) {
317314 },
318315 {
319316 desc : "cacheHit_noPending_stale_boExpired_dataNotExpired_notThrottled_defaultTargetOnMiss" ,
320- cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (maxAge )},
317+ cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (defaultTestMaxAge )},
321318 newRLSRequest : true , // Proactive refresh.
322319 useChildPick : true ,
323320 strategy : rlspb .RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS ,
324321 wantErr : nil ,
325322 },
326323 {
327324 desc : "cacheHit_noPending_stale_boExpired_dataNotExpired_notThrottled_clientSeesError" ,
328- cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (maxAge )},
325+ cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (defaultTestMaxAge )},
329326 newRLSRequest : true , // Proactive refresh.
330327 useChildPick : true ,
331328 strategy : rlspb .RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR ,
332329 wantErr : nil ,
333330 },
334331 {
335332 desc : "cacheHit_noPending_stale_boExpired_dataNotExpired_notThrottled_defaultTargetOnError" ,
336- cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (maxAge )},
333+ cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (defaultTestMaxAge )},
337334 newRLSRequest : true , // Proactive refresh.
338335 useChildPick : true ,
339336 strategy : rlspb .RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR ,
340337 wantErr : nil ,
341338 },
342339 {
343340 desc : "cacheHit_noPending_stale_boNotExpired_dataExpired_defaultTargetOnError" ,
344- cacheEntry : & cache.Entry {BackoffTime : time .Now ().Add (maxAge )},
341+ cacheEntry : & cache.Entry {BackoffTime : time .Now ().Add (defaultTestMaxAge )},
345342 useDefaultPick : true ,
346343 strategy : rlspb .RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR ,
347344 wantErr : nil ,
348345 },
349346 {
350347 desc : "cacheHit_noPending_stale_boNotExpired_dataExpired_defaultTargetOnMiss" ,
351- cacheEntry : & cache.Entry {BackoffTime : time .Now ().Add (maxAge )},
348+ cacheEntry : & cache.Entry {BackoffTime : time .Now ().Add (defaultTestMaxAge )},
352349 useDefaultPick : true ,
353350 strategy : rlspb .RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS ,
354351 wantErr : nil ,
355352 },
356353 {
357354 desc : "cacheHit_noPending_stale_boNotExpired_dataExpired_clientSeesError" ,
358355 cacheEntry : & cache.Entry {
359- BackoffTime : time .Now ().Add (maxAge ),
356+ BackoffTime : time .Now ().Add (defaultTestMaxAge ),
360357 CallStatus : rlsLastErr ,
361358 },
362359 strategy : rlspb .RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR ,
@@ -365,8 +362,8 @@ func TestPick(t *testing.T) {
365362 {
366363 desc : "cacheHit_noPending_stale_boNotExpired_dataNotExpired_defaultTargetOnError" ,
367364 cacheEntry : & cache.Entry {
368- ExpiryTime : time .Now ().Add (maxAge ),
369- BackoffTime : time .Now ().Add (maxAge ),
365+ ExpiryTime : time .Now ().Add (defaultTestMaxAge ),
366+ BackoffTime : time .Now ().Add (defaultTestMaxAge ),
370367 CallStatus : rlsLastErr ,
371368 },
372369 useChildPick : true ,
@@ -376,8 +373,8 @@ func TestPick(t *testing.T) {
376373 {
377374 desc : "cacheHit_noPending_stale_boNotExpired_dataNotExpired_defaultTargetOnMiss" ,
378375 cacheEntry : & cache.Entry {
379- ExpiryTime : time .Now ().Add (maxAge ),
380- BackoffTime : time .Now ().Add (maxAge ),
376+ ExpiryTime : time .Now ().Add (defaultTestMaxAge ),
377+ BackoffTime : time .Now ().Add (defaultTestMaxAge ),
381378 CallStatus : rlsLastErr ,
382379 },
383380 useChildPick : true ,
@@ -387,8 +384,8 @@ func TestPick(t *testing.T) {
387384 {
388385 desc : "cacheHit_noPending_stale_boNotExpired_dataNotExpired_clientSeesError" ,
389386 cacheEntry : & cache.Entry {
390- ExpiryTime : time .Now ().Add (maxAge ),
391- BackoffTime : time .Now ().Add (maxAge ),
387+ ExpiryTime : time .Now ().Add (defaultTestMaxAge ),
388+ BackoffTime : time .Now ().Add (defaultTestMaxAge ),
392389 CallStatus : rlsLastErr ,
393390 },
394391 useChildPick : true ,
@@ -398,8 +395,8 @@ func TestPick(t *testing.T) {
398395 {
399396 desc : "cacheHit_noPending_notStale_dataNotExpired_defaultTargetOnError" ,
400397 cacheEntry : & cache.Entry {
401- ExpiryTime : time .Now ().Add (maxAge ),
402- StaleTime : time .Now ().Add (maxAge ),
398+ ExpiryTime : time .Now ().Add (defaultTestMaxAge ),
399+ StaleTime : time .Now ().Add (defaultTestMaxAge ),
403400 },
404401 useChildPick : true ,
405402 strategy : rlspb .RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR ,
@@ -408,8 +405,8 @@ func TestPick(t *testing.T) {
408405 {
409406 desc : "cacheHit_noPending_notStale_dataNotExpired_defaultTargetOnMiss" ,
410407 cacheEntry : & cache.Entry {
411- ExpiryTime : time .Now ().Add (maxAge ),
412- StaleTime : time .Now ().Add (maxAge ),
408+ ExpiryTime : time .Now ().Add (defaultTestMaxAge ),
409+ StaleTime : time .Now ().Add (defaultTestMaxAge ),
413410 },
414411 useChildPick : true ,
415412 strategy : rlspb .RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS ,
@@ -418,8 +415,8 @@ func TestPick(t *testing.T) {
418415 {
419416 desc : "cacheHit_noPending_notStale_dataNotExpired_clientSeesError" ,
420417 cacheEntry : & cache.Entry {
421- ExpiryTime : time .Now ().Add (maxAge ),
422- StaleTime : time .Now ().Add (maxAge ),
418+ ExpiryTime : time .Now ().Add (defaultTestMaxAge ),
419+ StaleTime : time .Now ().Add (defaultTestMaxAge ),
423420 },
424421 useChildPick : true ,
425422 strategy : rlspb .RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR ,
@@ -449,7 +446,7 @@ func TestPick(t *testing.T) {
449446 {
450447 desc : "cacheHit_pending_dataExpired_boNotExpired_defaultTargetOnError" ,
451448 cacheEntry : & cache.Entry {
452- BackoffTime : time .Now ().Add (maxAge ),
449+ BackoffTime : time .Now ().Add (defaultTestMaxAge ),
453450 CallStatus : rlsLastErr ,
454451 },
455452 useDefaultPick : true ,
@@ -459,7 +456,7 @@ func TestPick(t *testing.T) {
459456 {
460457 desc : "cacheHit_pending_dataExpired_boNotExpired_defaultTargetOnMiss" ,
461458 cacheEntry : & cache.Entry {
462- BackoffTime : time .Now ().Add (maxAge ),
459+ BackoffTime : time .Now ().Add (defaultTestMaxAge ),
463460 CallStatus : rlsLastErr ,
464461 },
465462 pending : true ,
@@ -470,7 +467,7 @@ func TestPick(t *testing.T) {
470467 {
471468 desc : "cacheHit_pending_dataExpired_boNotExpired_clientSeesError" ,
472469 cacheEntry : & cache.Entry {
473- BackoffTime : time .Now ().Add (maxAge ),
470+ BackoffTime : time .Now ().Add (defaultTestMaxAge ),
474471 CallStatus : rlsLastErr ,
475472 },
476473 pending : true ,
@@ -479,23 +476,23 @@ func TestPick(t *testing.T) {
479476 },
480477 {
481478 desc : "cacheHit_pending_dataNotExpired_defaultTargetOnError" ,
482- cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (maxAge )},
479+ cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (defaultTestMaxAge )},
483480 pending : true ,
484481 useChildPick : true ,
485482 strategy : rlspb .RouteLookupConfig_SYNC_LOOKUP_DEFAULT_TARGET_ON_ERROR ,
486483 wantErr : nil ,
487484 },
488485 {
489486 desc : "cacheHit_pending_dataNotExpired_defaultTargetOnMiss" ,
490- cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (maxAge )},
487+ cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (defaultTestMaxAge )},
491488 pending : true ,
492489 useChildPick : true ,
493490 strategy : rlspb .RouteLookupConfig_ASYNC_LOOKUP_DEFAULT_TARGET_ON_MISS ,
494491 wantErr : nil ,
495492 },
496493 {
497494 desc : "cacheHit_pending_dataNotExpired_clientSeesError" ,
498- cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (maxAge )},
495+ cacheEntry : & cache.Entry {ExpiryTime : time .Now ().Add (defaultTestMaxAge )},
499496 pending : true ,
500497 useChildPick : true ,
501498 strategy : rlspb .RouteLookupConfig_SYNC_LOOKUP_CLIENT_SEES_ERROR ,
0 commit comments