Skip to content

Commit

Permalink
allow for similar error messages for closed connections
Browse files Browse the repository at this point in the history
  • Loading branch information
chelseakomlo committed Jan 17, 2018
1 parent 0805c41 commit 028ba9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion nomad/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ type Server struct {
leaderCh <-chan bool
raft *raft.Raft
raftLayer *RaftLayer

raftStore *raftboltdb.BoltStore
raftInmem *raft.InmemStore

Expand Down
9 changes: 7 additions & 2 deletions nomad/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net"
"os"
"path"
"strings"
"sync/atomic"
"testing"
"time"
Expand Down Expand Up @@ -280,6 +281,10 @@ func TestServer_Reload_Vault(t *testing.T) {
}
}

func connectionReset(msg string) bool {
return strings.Contains(msg, "EOF") || strings.Contains(msg, "connection reset by peer")
}

// Tests that the server will successfully reload its network connections,
// upgrading from plaintext to TLS if the server's TLS configuration changes.
func TestServer_Reload_TLSConnections_PlaintextToTLS(t *testing.T) {
Expand Down Expand Up @@ -326,7 +331,7 @@ func TestServer_Reload_TLSConnections_PlaintextToTLS(t *testing.T) {
var resp structs.GenericResponse
err = msgpackrpc.CallWithCodec(codec, "Node.Register", req, &resp)
assert.NotNil(err)
assert.Contains("rpc error: EOF", err.Error())
assert.True(connectionReset(err.Error()))
}

// Tests that the server will successfully reload its network connections,
Expand Down Expand Up @@ -487,7 +492,7 @@ func TestServer_Reload_TLSConnections_Raft(t *testing.T) {
var resp structs.JobRegisterResponse
err := msgpackrpc.CallWithCodec(codec, "Job.Register", req, &resp)
assert.NotNil(err)
assert.Contains("rpc error: EOF", err.Error())
assert.True(connectionReset(err.Error()))

// Check that the job was not persisted
state := s1.fsm.State()
Expand Down

0 comments on commit 028ba9f

Please sign in to comment.