etcd-tester: fix peer-port parsing bug with localhost url

The following format "http://localhost:1234" causes existing port parser to fail. Add new logic to parse the host name first then extract port.

Fixes #6409
This commit is contained in:
fanmin shi
2016-09-12 13:29:52 -07:00
parent 840f4d48c8
commit 8a63071463

View File

@@ -168,7 +168,11 @@ func (m *member) grpcAddr() string {
}
func (m *member) peerPort() (port int) {
_, portStr, err := net.SplitHostPort(m.PeerURL)
u, err := url.Parse(m.PeerURL)
if err != nil {
panic(err)
}
_, portStr, err := net.SplitHostPort(u.Host)
if err != nil {
panic(err)
}