Tests: Make sure that the cluster state came from the same master before checking for discrepancies

If nodes don't agree on the master, the cluster state doesn't have to match even if they have the same version
This commit is contained in:
Igor Motov 2015-09-15 19:34:48 -04:00
parent bfa984e1c2
commit d6f9fe96af
1 changed files with 3 additions and 2 deletions

View File

@ -1099,8 +1099,9 @@ public abstract class ESIntegTestCase extends ESTestCase {
localClusterState = ClusterState.Builder.fromBytes(localClusterStateBytes, null); localClusterState = ClusterState.Builder.fromBytes(localClusterStateBytes, null);
final Map<String, Object> localStateMap = convertToMap(localClusterState); final Map<String, Object> localStateMap = convertToMap(localClusterState);
final int localClusterStateSize = localClusterState.toString().length(); final int localClusterStateSize = localClusterState.toString().length();
// Check that the non-master node has the same version of the cluster state as the master and that this node didn't disconnect from the master // Check that the non-master node has the same version of the cluster state as the master and
if (masterClusterState.version() == localClusterState.version() && localClusterState.nodes().nodes().containsKey(masterId)) { // that the master node matches the master (otherwise there is no requirement for the cluster state to match)
if (masterClusterState.version() == localClusterState.version() && masterId.equals(localClusterState.nodes().masterNodeId())) {
try { try {
assertEquals("clusterstate UUID does not match", masterClusterState.stateUUID(), localClusterState.stateUUID()); assertEquals("clusterstate UUID does not match", masterClusterState.stateUUID(), localClusterState.stateUUID());
// We cannot compare serialization bytes since serialization order of maps is not guaranteed // We cannot compare serialization bytes since serialization order of maps is not guaranteed