Test: remove reference to the local node before comparing cluster states in ensureClusterStateConsistency
This commit is contained in:
parent
9828e955f3
commit
38be1e8a1a
|
@ -1142,20 +1142,26 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
|
|||
protected void ensureClusterStateConsistency() throws IOException {
|
||||
if (cluster() != null) {
|
||||
ClusterState masterClusterState = client().admin().cluster().prepareState().all().get().getState();
|
||||
byte[] masterClusterStateBytes = ClusterState.Builder.toBytes(masterClusterState);
|
||||
// remove local node reference
|
||||
masterClusterState = ClusterState.Builder.fromBytes(masterClusterStateBytes, null);
|
||||
Map<String, Object> masterStateMap = convertToMap(masterClusterState);
|
||||
int masterClusterStateSize = ClusterState.Builder.toBytes(masterClusterState).length;
|
||||
for (Client client : cluster()) {
|
||||
ClusterState localClusterState = client.admin().cluster().prepareState().all().setLocal(true).get().getState();
|
||||
byte[] localClusterStateBytes = ClusterState.Builder.toBytes(localClusterState);
|
||||
// remove local node reference
|
||||
localClusterState = ClusterState.Builder.fromBytes(localClusterStateBytes, null);
|
||||
Map<String, Object> localStateMap = convertToMap(localClusterState);
|
||||
int localClusterStateSize = localClusterStateBytes.length;
|
||||
if (masterClusterState.version() == localClusterState.version()) {
|
||||
try {
|
||||
assertThat(masterClusterState.uuid(), equalTo(localClusterState.uuid()));
|
||||
// We cannot compare serialization bytes since serialization order of maps is not guaranteed
|
||||
// but we can compare serialization sizes - they should be the same
|
||||
int localClusterStateSize = ClusterState.Builder.toBytes(localClusterState).length;
|
||||
assertThat(masterClusterStateSize, equalTo(localClusterStateSize));
|
||||
|
||||
// Compare JSON serialization
|
||||
assertThat(mapsEqualIgnoringArrayOrder(masterStateMap, convertToMap(localClusterState)), equalTo(true));
|
||||
assertThat(mapsEqualIgnoringArrayOrder(masterStateMap, localStateMap), equalTo(true));
|
||||
} catch (AssertionError error) {
|
||||
logger.error("Cluster state from master:\n{}\nLocal cluster state:\n{}", masterClusterState.toString(), localClusterState.toString());
|
||||
throw error;
|
||||
|
|
|
@ -295,7 +295,6 @@ public final class InternalTestCluster extends TestCluster {
|
|||
builder.put("http.port", BASE_PORT+101 + "-" + (BASE_PORT+200));
|
||||
builder.put("config.ignore_system_properties", true);
|
||||
builder.put("node.mode", NODE_MODE);
|
||||
builder.put("network.address.serialization.resolve", true); // this makes adresses in the clusterstate consistent
|
||||
builder.put("http.pipelining", enableHttpPipelining);
|
||||
builder.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, false);
|
||||
builder.put(NodeEnvironment.SETTING_CUSTOM_DATA_PATH_ENABLED, true);
|
||||
|
|
Loading…
Reference in New Issue