consul: Adding LANMembers and WANMembers

This commit is contained in:
Armon Dadgar 2013-12-10 13:17:54 -08:00
parent 0ade6bb750
commit 29d0f901dc
2 changed files with 28 additions and 0 deletions

View File

@ -327,3 +327,13 @@ func (s *Server) JoinWAN(addr string) error {
_, err := s.serfWAN.Join([]string{addr}, false)
return err
}
// LANMembers is used to return the members of the LAN cluster
func (s *Server) LANMembers() []serf.Member {
return s.serfLAN.Members()
}
// WANMembers is used to return the members of the LAN cluster
func (s *Server) WANMembers() []serf.Member {
return s.serfWAN.Members()
}

View File

@ -82,6 +82,15 @@ func TestServer_JoinLAN(t *testing.T) {
if err := s2.JoinLAN(addr); err != nil {
t.Fatalf("err: %v", err)
}
// Check the members
if len(s1.LANMembers()) != 2 {
t.Fatalf("bad len")
}
if len(s2.LANMembers()) != 2 {
t.Fatalf("bad len")
}
}
func TestServer_JoinWAN(t *testing.T) {
@ -99,6 +108,15 @@ func TestServer_JoinWAN(t *testing.T) {
if err := s2.JoinWAN(addr); err != nil {
t.Fatalf("err: %v", err)
}
// Check the members
if len(s1.WANMembers()) != 2 {
t.Fatalf("bad len")
}
if len(s2.WANMembers()) != 2 {
t.Fatalf("bad len")
}
}
func TestServer_Leave(t *testing.T) {