mirror of https://github.com/status-im/consul.git
consul: Adding LANMembers and WANMembers
This commit is contained in:
parent
0ade6bb750
commit
29d0f901dc
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue