(t *testing.T)
| 704 | } |
| 705 | |
| 706 | func TestSQLDataWarmup(t *testing.T) { |
| 707 | tcs := []struct { |
| 708 | desc string |
| 709 | in *proxy.Config |
| 710 | want int |
| 711 | }{ |
| 712 | { |
| 713 | desc: "standard warmup", |
| 714 | in: &proxy.Config{ |
| 715 | Instances: []proxy.InstanceConnConfig{{Name: "proj:reg:inst", Port: 30104}}, |
| 716 | }, |
| 717 | want: 1, |
| 718 | }, |
| 719 | { |
| 720 | desc: "warmup skipped globally", |
| 721 | in: &proxy.Config{ |
| 722 | SQLDataEnabled: true, |
| 723 | Instances: []proxy.InstanceConnConfig{{Name: "proj:reg:inst", Port: 30105}}, |
| 724 | }, |
| 725 | want: 0, |
| 726 | }, |
| 727 | { |
| 728 | desc: "warmup skipped per-instance", |
| 729 | in: &proxy.Config{ |
| 730 | Instances: []proxy.InstanceConnConfig{{ |
| 731 | Name: "proj:reg:inst", |
| 732 | Port: 30106, |
| 733 | SQLDataEnabled: pointer(true), |
| 734 | }}, |
| 735 | }, |
| 736 | want: 0, |
| 737 | }, |
| 738 | } |
| 739 | |
| 740 | for _, tc := range tcs { |
| 741 | t.Run(tc.desc, func(t *testing.T) { |
| 742 | d := &fakeDialer{} |
| 743 | c, err := proxy.NewClient(context.Background(), d, testLogger, tc.in, nil) |
| 744 | if err != nil { |
| 745 | t.Fatalf("proxy.NewClient error: %v", err) |
| 746 | } |
| 747 | defer c.Close() |
| 748 | |
| 749 | var got int |
| 750 | for i := 0; i < 10; i++ { |
| 751 | got = d.engineVersionAttempts() |
| 752 | if got == tc.want { |
| 753 | return |
| 754 | } |
| 755 | time.Sleep(100 * time.Millisecond) |
| 756 | } |
| 757 | t.Fatalf("warmup attempts, want = %v, got = %v", tc.want, got) |
| 758 | }) |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | func TestCheckConnections(t *testing.T) { |
| 763 | in := &proxy.Config{ |
nothing calls this directly
no test coverage detected