github.com/osdi23p228/fabric@v0.0.0-20221218062954-77808885f5db/integration/ports.go (about) 1 /* 2 Copyright IBM Corp All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package integration 8 9 import ( 10 "fmt" 11 "os" 12 13 "github.com/onsi/ginkgo" 14 ) 15 16 // TestPortRange represents a port range 17 type TestPortRange int 18 19 const ( 20 basePort = 20000 21 portsPerNode = 50 22 portsPerSuite = 10 * portsPerNode 23 ) 24 25 const ( 26 ConfigBasePort TestPortRange = basePort + portsPerSuite*iota 27 DevModePort 28 DiscoveryBasePort 29 E2EBasePort 30 GossipBasePort 31 IdemixBasePort 32 LedgerPort 33 LifecyclePort 34 MSPPort 35 NWOBasePort 36 PKCS11Port 37 PluggableBasePort 38 PrivateDataBasePort 39 RaftBasePort 40 SBEBasePort 41 ) 42 43 // On linux, the default ephemeral port range is 32768-60999 and can be 44 // allocated by the system for the client side of TCP connections or when 45 // programs explicitly request one. Given linux is our default CI system, 46 // we want to try avoid ports in that range. 47 func (t TestPortRange) StartPortForNode() int { 48 const startEphemeral, endEphemeral = 32768, 60999 49 50 port := int(t) + portsPerNode*(ginkgo.GinkgoParallelNode()-1) 51 if port >= startEphemeral-portsPerNode && port <= endEphemeral-portsPerNode { 52 fmt.Fprintf(os.Stderr, "WARNING: port %d is part of the default ephemeral port range on linux", port) 53 } 54 return port 55 }