mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
[TEST] Add better assertion messages
This commit is contained in:
parent
42ad677127
commit
0bc5b35a59
@ -1177,17 +1177,17 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
|
|||||||
byte[] localClusterStateBytes = ClusterState.Builder.toBytes(localClusterState);
|
byte[] localClusterStateBytes = ClusterState.Builder.toBytes(localClusterState);
|
||||||
// remove local node reference
|
// remove local node reference
|
||||||
localClusterState = ClusterState.Builder.fromBytes(localClusterStateBytes, null);
|
localClusterState = ClusterState.Builder.fromBytes(localClusterStateBytes, null);
|
||||||
Map<String, Object> localStateMap = convertToMap(localClusterState);
|
final Map<String, Object> localStateMap = convertToMap(localClusterState);
|
||||||
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 that this node didn't disconnect from the master
|
||||||
if (masterClusterState.version() == localClusterState.version() && localClusterState.nodes().nodes().containsKey(masterId)) {
|
if (masterClusterState.version() == localClusterState.version() && localClusterState.nodes().nodes().containsKey(masterId)) {
|
||||||
try {
|
try {
|
||||||
assertThat(masterClusterState.uuid(), equalTo(localClusterState.uuid()));
|
assertEquals("clusterstate UUID does not match", masterClusterState.uuid(), localClusterState.uuid());
|
||||||
// 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
|
||||||
// but we can compare serialization sizes - they should be the same
|
// but we can compare serialization sizes - they should be the same
|
||||||
assertThat(masterClusterStateSize, equalTo(localClusterStateSize));
|
assertEquals("clusterstate size does not match", masterClusterStateSize, localClusterStateSize);
|
||||||
// Compare JSON serialization
|
// Compare JSON serialization
|
||||||
assertThat(mapsEqualIgnoringArrayOrder(masterStateMap, localStateMap), equalTo(true));
|
assertTrue("clusterstate JSON serialization does not match", mapsEqualIgnoringArrayOrder(masterStateMap, localStateMap));
|
||||||
} catch (AssertionError error) {
|
} catch (AssertionError error) {
|
||||||
logger.error("Cluster state from master:\n{}\nLocal cluster state:\n{}", masterClusterState.toString(), localClusterState.toString());
|
logger.error("Cluster state from master:\n{}\nLocal cluster state:\n{}", masterClusterState.toString(), localClusterState.toString());
|
||||||
throw error;
|
throw error;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user