diff --git a/consul/client.go b/consul/client.go index b6e9497cc..78643a34e 100644 --- a/consul/client.go +++ b/consul/client.go @@ -118,7 +118,7 @@ func NewClient(config *Config) (*Client, error) { shutdownCh: make(chan struct{}), } - c.serverMgr = server_manager.NewServerManager(c.logger, c.shutdownCh, c.serf) + c.serverMgr = server_manager.New(c.logger, c.shutdownCh, c.serf) // Start consulServers maintenance go c.serverMgr.Start() diff --git a/consul/server_manager/server_manager.go b/consul/server_manager/server_manager.go index a8be34bb8..e3342a923 100644 --- a/consul/server_manager/server_manager.go +++ b/consul/server_manager/server_manager.go @@ -176,9 +176,8 @@ func (sm *ServerManager) getServerConfig() serverConfig { return sm.serverConfigValue.Load().(serverConfig) } -// NewServerManager is the only way to safely create a new ServerManager -// struct. -func NewServerManager(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ConsulClusterInfo) (sm *ServerManager) { +// New is the only way to safely create a new ServerManager struct. +func New(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ConsulClusterInfo) (sm *ServerManager) { // NOTE(sean@): Can't pass *consul.Client due to an import cycle sm = new(ServerManager) sm.logger = logger diff --git a/consul/server_manager/server_manager_internal_test.go b/consul/server_manager/server_manager_internal_test.go index 1a9610419..74277c922 100644 --- a/consul/server_manager/server_manager_internal_test.go +++ b/consul/server_manager/server_manager_internal_test.go @@ -32,7 +32,7 @@ func (s *fauxSerf) NumNodes() int { func testServerManager() (sm *ServerManager) { logger := GetBufferedLogger() shutdownCh := make(chan struct{}) - sm = NewServerManager(logger, shutdownCh, &fauxSerf{}) + sm = New(logger, shutdownCh, &fauxSerf{}) return sm } @@ -101,8 +101,8 @@ func TestServerManagerInternal_getServerConfig(t *testing.T) { } } -// func NewServerManager(logger *log.Logger, shutdownCh chan struct{}) (sm *ServerManager) { -func TestServerManagerInternal_NewServerManager(t *testing.T) { +// func New(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ConsulClusterInfo) (sm *ServerManager) { +func TestServerManagerInternal_New(t *testing.T) { sm := testServerManager() if sm == nil { t.Fatalf("ServerManager nil") diff --git a/consul/server_manager/server_manager_test.go b/consul/server_manager/server_manager_test.go index a19df17df..b5285d505 100644 --- a/consul/server_manager/server_manager_test.go +++ b/consul/server_manager/server_manager_test.go @@ -23,16 +23,19 @@ func GetBufferedLogger() *log.Logger { return localLogger } -func makeMockServerManager() (sm *server_manager.ServerManager) { - logger, shutdownCh := mockServerManager() - sm = server_manager.NewServerManager(logger, shutdownCh, nil) - return sm +type fauxSerf struct { } -func mockServerManager() (logger *log.Logger, shutdownCh chan struct{}) { - logger = GetBufferedLogger() - shutdownCh = make(chan struct{}) - return logger, shutdownCh +func (s *fauxSerf) NumNodes() int { + return 16384 +} + +func testServerManager() (sm *server_manager.ServerManager) { + logger := GetBufferedLogger() + logger = log.New(os.Stderr, "", log.LstdFlags) + shutdownCh := make(chan struct{}) + sm = server_manager.New(logger, shutdownCh, &fauxSerf{}) + return sm } // func (sm *ServerManager) AddServer(server *server_details.ServerDetails) {