(t *testing.T)
| 607 | func (b backoffForever) Backoff(int) time.Duration { return time.Duration(math.MaxInt64) } |
| 608 | |
| 609 | func (s) TestResetConnectBackoff(t *testing.T) { |
| 610 | dials := make(chan struct{}) |
| 611 | defer func() { // If we fail, let the http2client break out of dialing. |
| 612 | select { |
| 613 | case <-dials: |
| 614 | default: |
| 615 | } |
| 616 | }() |
| 617 | dialer := func(string, time.Duration) (net.Conn, error) { |
| 618 | dials <- struct{}{} |
| 619 | return nil, errors.New("failed to fake dial") |
| 620 | } |
| 621 | cc, err := NewClient("passthrough:///", WithTransportCredentials(insecure.NewCredentials()), WithDialer(dialer), withBackoff(backoffForever{})) |
| 622 | if err != nil { |
| 623 | t.Fatalf("grpc.NewClient() failed with error: %v, want: nil", err) |
| 624 | } |
| 625 | defer cc.Close() |
| 626 | go stayConnected(cc) |
| 627 | select { |
| 628 | case <-dials: |
| 629 | case <-time.NewTimer(10 * time.Second).C: |
| 630 | t.Fatal("Failed to call dial within 10s") |
| 631 | } |
| 632 | |
| 633 | select { |
| 634 | case <-dials: |
| 635 | t.Fatal("Dial called unexpectedly before resetting backoff") |
| 636 | case <-time.NewTimer(100 * time.Millisecond).C: |
| 637 | } |
| 638 | |
| 639 | cc.ResetConnectBackoff() |
| 640 | |
| 641 | select { |
| 642 | case <-dials: |
| 643 | case <-time.NewTimer(10 * time.Second).C: |
| 644 | t.Fatal("Failed to call dial within 10s after resetting backoff") |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | func (s) TestBackoffCancel(t *testing.T) { |
| 649 | dialStrCh := make(chan string) |
nothing calls this directly
no test coverage detected