From d6f9fe96af8ca2b90379373adced4e375d15c7cd Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Tue, 15 Sep 2015 19:34:48 -0400 Subject: [PATCH] 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 --- .../test/java/org/elasticsearch/test/ESIntegTestCase.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java b/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java index 592f65e31b9..f561dd6df64 100644 --- a/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java @@ -1099,8 +1099,9 @@ public abstract class ESIntegTestCase extends ESTestCase { localClusterState = ClusterState.Builder.fromBytes(localClusterStateBytes, null); final Map localStateMap = convertToMap(localClusterState); 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 - if (masterClusterState.version() == localClusterState.version() && localClusterState.nodes().nodes().containsKey(masterId)) { + // Check that the non-master node has the same version of the cluster state as the master and + // 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 { assertEquals("clusterstate UUID does not match", masterClusterState.stateUUID(), localClusterState.stateUUID()); // We cannot compare serialization bytes since serialization order of maps is not guaranteed