MCPcopy
hub / github.com/grpc/grpc-go / TestParseRetryPolicy

Method TestParseRetryPolicy

service_config_test.go:474–601  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

472}
473
474func (s) TestParseRetryPolicy(t *testing.T) {
475 runParseTests(t, []parseTestCase{
476 {
477 name: "valid",
478 scjs: `{
479 "methodConfig": [{
480 "name": [{"service": "foo"}],
481 "retryPolicy": {
482 "maxAttempts": 2,
483 "initialBackoff": "2s",
484 "maxBackoff": "10s",
485 "backoffMultiplier": 2,
486 "retryableStatusCodes": ["UNAVAILABLE"]
487 }
488 }]
489 }`,
490 wantSC: &ServiceConfig{
491 Methods: map[string]MethodConfig{
492 "/foo/": {
493 RetryPolicy: &internalserviceconfig.RetryPolicy{
494 MaxAttempts: 2,
495 InitialBackoff: 2 * time.Second,
496 MaxBackoff: 10 * time.Second,
497 BackoffMultiplier: 2,
498 RetryableStatusCodes: map[codes.Code]bool{codes.Unavailable: true},
499 },
500 },
501 },
502 lbConfig: lbConfigFor(t, "", nil),
503 },
504 },
505 {
506 name: "negative maxAttempts",
507 scjs: `{
508 "methodConfig": [{
509 "name": [{"service": "foo"}],
510 "retryPolicy": {
511 "maxAttempts": -1,
512 "initialBackoff": "2s",
513 "maxBackoff": "10s",
514 "backoffMultiplier": 2,
515 "retryableStatusCodes": ["UNAVAILABLE"]
516 }
517 }]
518 }`,
519 wantErr: true,
520 },
521 {
522 name: "missing maxAttempts",
523 scjs: `{
524 "methodConfig": [{
525 "name": [{"service": "foo"}],
526 "retryPolicy": {
527 "initialBackoff": "2s",
528 "maxBackoff": "10s",
529 "backoffMultiplier": 2,
530 "retryableStatusCodes": ["UNAVAILABLE"]
531 }

Callers

nothing calls this directly

Calls 2

runParseTestsFunction · 0.85
lbConfigForFunction · 0.85

Tested by

no test coverage detected