fix(tests/discovery): use host as -peers parameter instead of url

Or it cannot test the functionality correctly.
Moreover, add TestDiscoveryNoWithBackupPeers as the test for it.
This commit is contained in:
Yicheng Qin
2014-02-13 10:17:12 -08:00
parent 6f14467383
commit bd56b15b6e
4 changed files with 49 additions and 1 deletions

View File

@@ -94,6 +94,16 @@ func (r *Registry) clientURL(name string) (string, bool) {
return "", false
}
// Retrieves the host part of peer URL for a given node by name.
func (r *Registry) PeerHost(name string) (string, bool) {
rawurl, ok := r.PeerURL(name)
if ok {
u, _ := url.Parse(rawurl)
return u.Host, ok
}
return rawurl, ok
}
// Retrieves the peer URL for a given node by name.
func (r *Registry) PeerURL(name string) (string, bool) {
r.Lock()

View File

@@ -79,6 +79,11 @@ func (s *Server) URL() string {
return s.url
}
// Returns the host part of Peer URL for a given node name.
func (s *Server) PeerHost(name string) (string, bool) {
return s.registry.PeerHost(name)
}
// Retrives the Peer URL for a given node name.
func (s *Server) PeerURL(name string) (string, bool) {
return s.registry.PeerURL(name)