Condense some test logic and add a comment about renaming

This commit is contained in:
Kyle Havlovitz 2019-03-18 16:15:36 -07:00
parent 3aec844fd2
commit bb0839ea5b
2 changed files with 4 additions and 6 deletions

View File

@ -987,9 +987,7 @@ func TestLeader_ChangeNodeID(t *testing.T) {
failed++
}
}
if got, want := failed, 1; got != want {
r.Fatalf("got %d failed members want %d", got, want)
}
require.Equal(r, 1, failed)
})
// Bring up a new server with s3's name that will get a different ID
@ -1013,9 +1011,7 @@ func TestLeader_ChangeNodeID(t *testing.T) {
retry.Run(t, func(r *retry.R) {
for _, m := range s1.LANMembers() {
if m.Status != serf.StatusAlive {
r.Fatalf("bad status: %v", m)
}
require.Equal(r, serf.StatusAlive, m.Status)
}
})
}

View File

@ -376,6 +376,8 @@ func (s *Store) ensureNoNodeWithSimilarNameTxn(tx *memdb.Txn, node *structs.Node
return fmt.Errorf("Cannot get status of node %s: %s", enode.Node, err)
}
// Get the node health. If there's no Serf health check, we consider it safe to rename
// the node as it's likely an external node registration not managed by Consul.
var nodeHealthy bool
if enodeCheck != nil {
enodeSerfCheck, ok := enodeCheck.(*structs.HealthCheck)