From 2ab226ca6ee74e4067ee93b20ec563d7c316a0c7 Mon Sep 17 00:00:00 2001 From: Eno Compton Date: Wed, 21 Sep 2022 10:05:47 -0600 Subject: [PATCH] chore: increase wait time to ensure TCP connections (#127) This is port of https://github.com/GoogleCloudPlatform/cloudsql-proxy/pull/1293. --- internal/proxy/proxy_test.go | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/internal/proxy/proxy_test.go b/internal/proxy/proxy_test.go index 80d08a9ae1..f85d2ae60b 100644 --- a/internal/proxy/proxy_test.go +++ b/internal/proxy/proxy_test.go @@ -337,32 +337,17 @@ func TestClientCloseWaitsForActiveConnections(t *testing.T) { Instances: []proxy.InstanceConnConfig{ {Name: "proj:region:pg"}, }, + WaitOnClose: 5 * time.Second, } - c, err := proxy.NewClient(context.Background(), &fakeDialer{}, testLogger, in) if err != nil { t.Fatalf("proxy.NewClient error: %v", err) } go c.Serve(context.Background(), func() {}) - conn := tryTCPDial(t, "127.0.0.1:5000") - _ = conn.Close() - - if err := c.Close(); err != nil { - t.Fatalf("c.Close error: %v", err) - } - - in.WaitOnClose = time.Second - in.Port = 5001 - c, err = proxy.NewClient(context.Background(), &fakeDialer{}, testLogger, in) - if err != nil { - t.Fatalf("proxy.NewClient error: %v", err) - } - go c.Serve(context.Background(), func() {}) - var open []net.Conn for i := 0; i < 5; i++ { - conn = tryTCPDial(t, "127.0.0.1:5001") + conn := tryTCPDial(t, "127.0.0.1:5000") open = append(open, conn) } defer func() {