consul: test rpc errors returned from remote datacenters

This commit is contained in:
Ryan Uber 2014-09-30 14:19:25 -07:00
parent 9b8e753b15
commit 61b0908e3a
2 changed files with 29 additions and 1 deletions

View File

@ -325,6 +325,11 @@ func (s *Server) keyringRPC(
args *structs.KeyringRequest,
replies *structs.KeyringResponses) error {
rlen := len(s.remoteConsuls) - 1
if rlen == 0 {
return nil
}
errorCh := make(chan error)
respCh := make(chan *structs.KeyringResponses)
@ -335,7 +340,6 @@ func (s *Server) keyringRPC(
go s.forwardKeyringRPC(method, dc, args, errorCh, respCh)
}
rlen := len(s.remoteConsuls) - 1
done := 0
for {
select {

View File

@ -1,6 +1,8 @@
package consul
import (
"fmt"
"os"
"testing"
)
@ -19,3 +21,25 @@ func TestUserEventNames(t *testing.T) {
t.Fatalf("bad: %v", raw)
}
}
func TestKeyringRPCError(t *testing.T) {
dir1, s1 := testServerDC(t, "dc1")
defer os.RemoveAll(dir1)
defer s1.Shutdown()
dir2, s2 := testServerDC(t, "dc2")
defer os.RemoveAll(dir2)
defer s2.Shutdown()
// Try to join
addr := fmt.Sprintf("127.0.0.1:%d",
s1.config.SerfWANConfig.MemberlistConfig.BindPort)
if _, err := s2.JoinWAN([]string{addr}); err != nil {
t.Fatalf("err: %v", err)
}
// RPC error from remote datacenter is returned
if err := s1.keyringRPC("Bad.Method", nil, nil); err == nil {
t.Fatalf("bad")
}
}