From 42ad6771277d7778a088db57fe512bb9ce885356 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Wed, 20 May 2015 12:05:04 +0200 Subject: [PATCH] Tests: Compare the length of cluster states serialized as a String, not the binary representation. Due to the fact that the binary representation uses some compression, we can't be sure that they will be equal even if they store the same content. --- .../org/elasticsearch/test/ElasticsearchIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java index f1fc137dfc8..608d90f148b 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java @@ -1170,7 +1170,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase // remove local node reference masterClusterState = ClusterState.Builder.fromBytes(masterClusterStateBytes, null); Map masterStateMap = convertToMap(masterClusterState); - int masterClusterStateSize = ClusterState.Builder.toBytes(masterClusterState).length; + int masterClusterStateSize = masterClusterState.toString().length(); String masterId = masterClusterState.nodes().masterNodeId(); for (Client client : cluster()) { ClusterState localClusterState = client.admin().cluster().prepareState().all().setLocal(true).get().getState(); @@ -1178,7 +1178,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase // remove local node reference localClusterState = ClusterState.Builder.fromBytes(localClusterStateBytes, null); Map localStateMap = convertToMap(localClusterState); - int localClusterStateSize = localClusterStateBytes.length; + 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)) { try {