Skip to content

Commit 5ff61de

Browse files
chore: update tests to use unique ports (#2280)
1 parent 4cfa6a2 commit 5ff61de

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

internal/proxy/proxy_test.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -146,29 +146,29 @@ func TestClientInitialization(t *testing.T) {
146146
desc: "with instance address",
147147
in: &proxy.Config{
148148
Addr: "1.1.1.1", // bad address, binding shouldn't happen here.
149-
Port: 50000,
149+
Port: 50003,
150150
Instances: []proxy.InstanceConnConfig{
151151
{Addr: "0.0.0.0", Name: pg},
152152
},
153153
},
154-
wantTCPAddrs: []string{"0.0.0.0:50000"},
154+
wantTCPAddrs: []string{"0.0.0.0:50003"},
155155
},
156156
{
157157
desc: "IPv6 support",
158158
in: &proxy.Config{
159159
Addr: "::1",
160-
Port: 50000,
160+
Port: 50004,
161161
Instances: []proxy.InstanceConnConfig{
162162
{Name: pg},
163163
},
164164
},
165-
wantTCPAddrs: []string{"[::1]:50000"},
165+
wantTCPAddrs: []string{"[::1]:50004"},
166166
},
167167
{
168168
desc: "with instance port",
169169
in: &proxy.Config{
170170
Addr: "127.0.0.1",
171-
Port: 50000,
171+
Port: 50005,
172172
Instances: []proxy.InstanceConnConfig{
173173
{Name: pg, Port: 60000},
174174
},
@@ -179,17 +179,17 @@ func TestClientInitialization(t *testing.T) {
179179
desc: "with global port and instance port",
180180
in: &proxy.Config{
181181
Addr: "127.0.0.1",
182-
Port: 50000,
182+
Port: 50006,
183183
Instances: []proxy.InstanceConnConfig{
184184
{Name: pg},
185-
{Name: mysql, Port: 60000},
185+
{Name: mysql, Port: 60001},
186186
{Name: sqlserver},
187187
},
188188
},
189189
wantTCPAddrs: []string{
190-
"127.0.0.1:50000",
191-
"127.0.0.1:60000",
192-
"127.0.0.1:50001",
190+
"127.0.0.1:50006",
191+
"127.0.0.1:60001",
192+
"127.0.0.1:50007",
193193
},
194194
},
195195
{
@@ -230,7 +230,7 @@ func TestClientInitialization(t *testing.T) {
230230
desc: "with a global TCP host port and an instance Unix socket",
231231
in: &proxy.Config{
232232
Addr: "127.0.0.1",
233-
Port: 50000,
233+
Port: 50008,
234234
Instances: []proxy.InstanceConnConfig{
235235
{Name: mysql, UnixSocket: testDir},
236236
},
@@ -245,11 +245,11 @@ func TestClientInitialization(t *testing.T) {
245245
Addr: "127.0.0.1",
246246
UnixSocket: testDir,
247247
Instances: []proxy.InstanceConnConfig{
248-
{Name: pg, Port: 50000},
248+
{Name: pg, Port: 50009},
249249
},
250250
},
251251
wantTCPAddrs: []string{
252-
"127.0.0.1:50000",
252+
"127.0.0.1:50009",
253253
},
254254
},
255255
{
@@ -313,11 +313,11 @@ func TestClientInitialization(t *testing.T) {
313313
desc: "with TCP port for non functional instance",
314314
in: &proxy.Config{
315315
Instances: []proxy.InstanceConnConfig{
316-
{Name: "proj:region:fakeserver", Port: 50000},
316+
{Name: "proj:region:fakeserver", Port: 50010},
317317
},
318318
},
319319
wantTCPAddrs: []string{
320-
"127.0.0.1:50000",
320+
"127.0.0.1:50010",
321321
},
322322
},
323323
}
@@ -364,7 +364,7 @@ func TestClientLimitsMaxConnections(t *testing.T) {
364364
d := &fakeDialer{}
365365
in := &proxy.Config{
366366
Addr: "127.0.0.1",
367-
Port: 50000,
367+
Port: 50011,
368368
Instances: []proxy.InstanceConnConfig{
369369
{Name: "proj:region:pg"},
370370
},
@@ -377,13 +377,13 @@ func TestClientLimitsMaxConnections(t *testing.T) {
377377
defer c.Close()
378378
go c.Serve(context.Background(), func() {})
379379

380-
conn1, err1 := net.Dial("tcp", "127.0.0.1:50000")
380+
conn1, err1 := net.Dial("tcp", "127.0.0.1:50011")
381381
if err1 != nil {
382382
t.Fatalf("net.Dial error: %v", err1)
383383
}
384384
defer conn1.Close()
385385

386-
conn2, err2 := net.Dial("tcp", "127.0.0.1:50000")
386+
conn2, err2 := net.Dial("tcp", "127.0.0.1:50011")
387387
if err2 != nil {
388388
t.Fatalf("net.Dial error: %v", err1)
389389
}
@@ -436,7 +436,7 @@ func tryTCPDial(t *testing.T, addr string) net.Conn {
436436
func TestClientCloseWaitsForActiveConnections(t *testing.T) {
437437
in := &proxy.Config{
438438
Addr: "127.0.0.1",
439-
Port: 50000,
439+
Port: 50012,
440440
Instances: []proxy.InstanceConnConfig{
441441
{Name: "proj:region:pg"},
442442
},
@@ -448,7 +448,7 @@ func TestClientCloseWaitsForActiveConnections(t *testing.T) {
448448
}
449449
go c.Serve(context.Background(), func() {})
450450

451-
conn := tryTCPDial(t, "127.0.0.1:50000")
451+
conn := tryTCPDial(t, "127.0.0.1:50012")
452452
defer conn.Close()
453453

454454
if err := c.Close(); err == nil {
@@ -459,7 +459,7 @@ func TestClientCloseWaitsForActiveConnections(t *testing.T) {
459459
func TestClientClosesCleanly(t *testing.T) {
460460
in := &proxy.Config{
461461
Addr: "127.0.0.1",
462-
Port: 50000,
462+
Port: 50013,
463463
Instances: []proxy.InstanceConnConfig{
464464
{Name: "proj:reg:inst"},
465465
},
@@ -470,7 +470,7 @@ func TestClientClosesCleanly(t *testing.T) {
470470
}
471471
go c.Serve(context.Background(), func() {})
472472

473-
conn := tryTCPDial(t, "127.0.0.1:50000")
473+
conn := tryTCPDial(t, "127.0.0.1:50013")
474474
_ = conn.Close()
475475

476476
if err := c.Close(); err != nil {
@@ -481,7 +481,7 @@ func TestClientClosesCleanly(t *testing.T) {
481481
func TestClosesWithError(t *testing.T) {
482482
in := &proxy.Config{
483483
Addr: "127.0.0.1",
484-
Port: 50000,
484+
Port: 50014,
485485
Instances: []proxy.InstanceConnConfig{
486486
{Name: "proj:reg:inst"},
487487
},
@@ -492,7 +492,7 @@ func TestClosesWithError(t *testing.T) {
492492
}
493493
go c.Serve(context.Background(), func() {})
494494

495-
conn := tryTCPDial(t, "127.0.0.1:50000")
495+
conn := tryTCPDial(t, "127.0.0.1:50014")
496496
defer conn.Close()
497497

498498
if err = c.Close(); err == nil {
@@ -588,7 +588,7 @@ func TestClientNotifiesCallerOnServe(t *testing.T) {
588588
func TestClientConnCount(t *testing.T) {
589589
in := &proxy.Config{
590590
Addr: "127.0.0.1",
591-
Port: 50000,
591+
Port: 50015,
592592
Instances: []proxy.InstanceConnConfig{
593593
{Name: "proj:region:pg"},
594594
},
@@ -610,7 +610,7 @@ func TestClientConnCount(t *testing.T) {
610610
t.Fatalf("want 10 max connections, got = %v", gotMax)
611611
}
612612

613-
conn := tryTCPDial(t, "127.0.0.1:50000")
613+
conn := tryTCPDial(t, "127.0.0.1:50015")
614614
defer conn.Close()
615615

616616
verifyOpen := func(t *testing.T, want uint64) {
@@ -630,7 +630,7 @@ func TestClientConnCount(t *testing.T) {
630630
func TestCheckConnections(t *testing.T) {
631631
in := &proxy.Config{
632632
Addr: "127.0.0.1",
633-
Port: 50000,
633+
Port: 50016,
634634
Instances: []proxy.InstanceConnConfig{
635635
{Name: "proj:region:pg"},
636636
},
@@ -657,7 +657,7 @@ func TestCheckConnections(t *testing.T) {
657657

658658
in = &proxy.Config{
659659
Addr: "127.0.0.1",
660-
Port: 60000,
660+
Port: 60002,
661661
Instances: []proxy.InstanceConnConfig{
662662
{Name: "proj:region:pg1"},
663663
{Name: "proj:region:pg2"},
@@ -683,7 +683,7 @@ func TestCheckConnections(t *testing.T) {
683683
func TestRunConnectionCheck(t *testing.T) {
684684
in := &proxy.Config{
685685
Addr: "127.0.0.1",
686-
Port: 50002,
686+
Port: 50017,
687687
Instances: []proxy.InstanceConnConfig{
688688
{Name: "proj:region:pg"},
689689
},
@@ -792,8 +792,8 @@ func TestProxyMultiInstances(t *testing.T) {
792792
desc: "with two tcp socket instances and conflicting ports",
793793
in: &proxy.Config{
794794
Instances: []proxy.InstanceConnConfig{
795-
{Name: "proj:region:fakeserver", Port: 60000},
796-
{Name: mysql, Port: 60000},
795+
{Name: "proj:region:fakeserver", Port: 60003},
796+
{Name: mysql, Port: 60003},
797797
},
798798
},
799799
wantSuccess: false,

0 commit comments

Comments
 (0)