@@ -407,9 +407,6 @@ func InitEtcdProcessCluster(t testing.TB, cfg *EtcdProcessClusterConfig) (*EtcdP
407
407
if cfg .Logger == nil {
408
408
cfg .Logger = zaptest .NewLogger (t )
409
409
}
410
- if cfg .BasePort == 0 {
411
- cfg .BasePort = EtcdProcessBasePort
412
- }
413
410
if cfg .ServerConfig .SnapshotCount == 0 {
414
411
cfg .ServerConfig .SnapshotCount = etcdserver .DefaultSnapshotCount
415
412
}
@@ -518,6 +515,16 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
518
515
peer2Port := port + 3
519
516
clientHTTPPort := port + 4
520
517
518
+ var allocatedPorts []int
519
+ if cfg .BasePort == 0 {
520
+ clientPort = uniquePorts .Alloc ()
521
+ peerPort = uniquePorts .Alloc ()
522
+ metricsPort = uniquePorts .Alloc ()
523
+ peer2Port = uniquePorts .Alloc ()
524
+ clientHTTPPort = uniquePorts .Alloc ()
525
+ allocatedPorts = []int {clientPort , peerPort , metricsPort , peer2Port , clientHTTPPort }
526
+ }
527
+
521
528
if cfg .Client .ConnectionType == ClientTLSAndNonTLS {
522
529
curl = clientURL (cfg .ClientScheme (), clientPort , ClientNonTLS )
523
530
curls = []string {curl , clientURL (cfg .ClientScheme (), clientPort , ClientTLS )}
@@ -639,7 +646,8 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
639
646
}
640
647
var gofailPort int
641
648
if cfg .GoFailEnabled {
642
- gofailPort = (i + 1 )* 10000 + 2381
649
+ gofailPort = uniquePorts .Alloc ()
650
+ allocatedPorts = append (allocatedPorts , gofailPort )
643
651
envVars ["GOFAIL_HTTP" ] = fmt .Sprintf ("127.0.0.1:%d" , gofailPort )
644
652
}
645
653
@@ -662,6 +670,7 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in
662
670
GoFailClientTimeout : cfg .GoFailClientTimeout ,
663
671
Proxy : proxyCfg ,
664
672
LazyFSEnabled : cfg .LazyFSEnabled ,
673
+ AllocatedPorts : allocatedPorts ,
665
674
}
666
675
}
667
676
0 commit comments