diff --git a/nomad/rpc.go b/nomad/rpc.go index df4627eca..1b7e8bcca 100644 --- a/nomad/rpc.go +++ b/nomad/rpc.go @@ -87,6 +87,7 @@ func (s *Server) listen(ctx context.Context) { select { case <-ctx.Done(): return + default: } s.logger.Printf("[ERR] nomad.rpc: failed to accept RPC conn: %v", err) diff --git a/nomad/structs/config/tls.go b/nomad/structs/config/tls.go index 7cfd1fcd3..e309093e3 100644 --- a/nomad/structs/config/tls.go +++ b/nomad/structs/config/tls.go @@ -191,14 +191,6 @@ func (t *TLSConfig) Merge(b *TLSConfig) *TLSConfig { // NewConfig should never be nil- calling code is responsible for walways // passing a valid TLSConfig object func (t *TLSConfig) Equals(newConfig *TLSConfig) bool { - if t == nil { - return false - } - - if t == nil && newConfig != nil { - return false - } - return t.EnableRPC == newConfig.EnableRPC && t.CAFile == newConfig.CAFile && t.CertFile == newConfig.CertFile && diff --git a/nomad/structs/config/tls_test.go b/nomad/structs/config/tls_test.go index b76360ba8..e6dc36363 100644 --- a/nomad/structs/config/tls_test.go +++ b/nomad/structs/config/tls_test.go @@ -25,3 +25,39 @@ func TestTLSConfig_Merge(t *testing.T) { new := a.Merge(b) assert.Equal(b, new) } + +func TestTLS_Equals_TrueWhenEmpty(t *testing.T) { + assert := assert.New(t) + a := &TLSConfig{} + b := &TLSConfig{} + assert.True(a.Equals(b)) +} + +func TestTLS_Equals_FalseWhenUnequal(t *testing.T) { + assert := assert.New(t) + a := &TLSConfig{CAFile: "abc", CertFile: "def", KeyFile: "ghi"} + b := &TLSConfig{CAFile: "jkl", CertFile: "def", KeyFile: "ghi"} + assert.False(a.Equals(b)) +} + +func TestTLS_Equals_TrueWhenEqual(t *testing.T) { + assert := assert.New(t) + a := &TLSConfig{CAFile: "abc", CertFile: "def", KeyFile: "ghi"} + b := &TLSConfig{CAFile: "abc", CertFile: "def", KeyFile: "ghi"} + assert.True(a.Equals(b)) +} + +func TestTLS_Copy(t *testing.T) { + assert := assert.New(t) + a := &TLSConfig{CAFile: "abc", CertFile: "def", KeyFile: "ghi"} + aCopy := a.Copy() + assert.True(a.Equals(aCopy)) +} + +// GetKeyLoader should always return an initialized KeyLoader for a TLSConfig +// object +func TestTLS_GetKeyloader(t *testing.T) { + assert := assert.New(t) + a := &TLSConfig{} + assert.NotNil(a.GetKeyLoader()) +}