Browse Source

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
fanmin shi 9 years ago
parent
commit
8a63071463
1 changed files with 5 additions and 1 deletions
  1. 5 1
      tools/functional-tester/etcd-tester/member.go

+ 5 - 1
tools/functional-tester/etcd-tester/member.go

@@ -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)
 	}