Condense some test logic and add a comment about renaming

pull/5485/head
Kyle Havlovitz 2019-03-18 16:15:36 -07:00
parent 8ae6547934
commit aa4e26d102
2 changed files with 4 additions and 6 deletions

View File

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

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) 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 var nodeHealthy bool
if enodeCheck != nil { if enodeCheck != nil {
enodeSerfCheck, ok := enodeCheck.(*structs.HealthCheck) enodeSerfCheck, ok := enodeCheck.(*structs.HealthCheck)