Skip to content
/ etcd Public
forked from etcd-io/etcd

Commit

Permalink
integration: use only digits in unix ports
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuho committed Jan 5, 2017
1 parent a42b399 commit 6825ffe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion integration/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ type bridge struct {

func newBridge(addr string) (*bridge, error) {
b := &bridge{
inaddr: addr + ".bridge",
// bridge "port" is ("%05d%05d0", port, pid) since go1.8 expects the port to be a number
inaddr: addr + "0",
outaddr: addr,
conns: make(map[*bridgeConn]struct{}),
stopc: make(chan struct{}, 1),
Expand Down
7 changes: 4 additions & 3 deletions integration/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (c *cluster) waitVersion() {
}

func (c *cluster) name(i int) string {
return fmt.Sprint("node", i)
return fmt.Sprint(i)
}

// isMembersEqual checks whether two members equal except ID field.
Expand All @@ -420,7 +420,8 @@ func isMembersEqual(membs []client.Member, wmembs []client.Member) bool {

func newLocalListener(t *testing.T) net.Listener {
c := atomic.AddInt64(&localListenCount, 1)
addr := fmt.Sprintf("127.0.0.1:%d.%d.sock", c+basePort, os.Getpid())
// Go 1.8+ allows only numbers in port
addr := fmt.Sprintf("127.0.0.1:%05d%05d", c+basePort, os.Getpid())
return NewListenerWithAddr(t, addr)
}

Expand Down Expand Up @@ -510,7 +511,7 @@ func mustNewMember(t *testing.T, mcfg memberConfig) *member {
// listenGRPC starts a grpc server over a unix domain socket on the member
func (m *member) listenGRPC() error {
// prefix with localhost so cert has right domain
m.grpcAddr = "localhost:" + m.Name + ".sock"
m.grpcAddr = "localhost:" + m.Name
l, err := transport.NewUnixListener(m.grpcAddr)
if err != nil {
return fmt.Errorf("listen failed on grpc socket %s (%v)", m.grpcAddr, err)
Expand Down
2 changes: 1 addition & 1 deletion integration/embed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestEmbedEtcd(t *testing.T) {

func newEmbedURLs(n int) (urls []url.URL) {
for i := 0; i < n; i++ {
u, _ := url.Parse(fmt.Sprintf("unix://localhost:%d.%d.sock", os.Getpid(), i))
u, _ := url.Parse(fmt.Sprintf("unix://localhost:%d%06d", os.Getpid(), i))
urls = append(urls, *u)
}
return
Expand Down

0 comments on commit 6825ffe

Please sign in to comment.