Skip to content

Commit 66db8c7

Browse files
authored
Test/107515 RestoreTemplateWithMatchOnlyTextMapperIT (#120392)
Update the way of comparing stateMaps for equality
1 parent 2fea593 commit 66db8c7

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

docs/changelog/120392.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 120392
2+
summary: Test/107515 restore template with match only text mapper it fail
3+
area: Search
4+
type: bug
5+
issues:
6+
- 107515

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,11 +1137,8 @@ public void testPartialRestoreSnapshotThatIncludesDataStream() {
11371137

11381138
/**
11391139
* This test is a copy of the {@link #testPartialRestoreSnapshotThatIncludesDataStream()} the only difference
1140-
* is that one include the global state and one doesn't. In general this shouldn't matter that's why it used to be
1141-
* a random parameter of the test, but because of #107515 it fails when we include the global state. Keep them
1142-
* separate until this is fixed.
1140+
* is that one include the global state and one doesn't.
11431141
*/
1144-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/107515")
11451142
public void testPartialRestoreSnapshotThatIncludesDataStreamWithGlobalState() {
11461143
final String snapshot = "test-snapshot";
11471144
final String indexWithoutDataStream = "test-idx-no-ds";
@@ -1307,11 +1304,8 @@ public void testExcludeDSFromSnapshotWhenExcludingAnyOfItsIndices() {
13071304

13081305
/**
13091306
* This test is a copy of the {@link #testExcludeDSFromSnapshotWhenExcludingAnyOfItsIndices()} ()} the only difference
1310-
* is that one include the global state and one doesn't. In general this shouldn't matter that's why it used to be
1311-
* a random parameter of the test, but because of #107515 it fails when we include the global state. Keep them
1312-
* separate until this is fixed.
1307+
* is that one include the global state and one doesn't.
13131308
*/
1314-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/107515")
13151309
public void testExcludeDSFromSnapshotWhenExcludingItsIndicesWithGlobalState() {
13161310
final String snapshot = "test-snapshot";
13171311
final String indexWithoutDataStream = "test-idx-no-ds";
@@ -1477,10 +1471,6 @@ public void testWarningHeaderAbsentOnRestoreWithTemplates() throws Exception {
14771471

14781472
}
14791473

1480-
/**
1481-
* This test is muted as it's awaiting the same fix as {@link #testPartialRestoreSnapshotThatIncludesDataStreamWithGlobalState()}
1482-
*/
1483-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/107515")
14841474
public void testWarningHeaderOnRestoreTemplateFromSnapshot() throws Exception {
14851475
String datastreamName = "ds";
14861476

test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,6 @@ protected final void doEnsureClusterStateConsistency(NamedWriteableRegistry name
12431243
namedWriteableRegistry
12441244
);
12451245
Map<String, Object> masterStateMap = convertToMap(masterClusterState);
1246-
int masterClusterStateSize = ClusterState.Builder.toBytes(masterClusterState).length;
12471246
String masterId = masterClusterState.nodes().getMasterNodeId();
12481247
for (SubscribableListener<ClusterStateResponse> localStateListener : localStates) {
12491248
localStateListener.andThenAccept(localClusterStateResponse -> {
@@ -1255,7 +1254,6 @@ protected final void doEnsureClusterStateConsistency(NamedWriteableRegistry name
12551254
namedWriteableRegistry
12561255
);
12571256
final Map<String, Object> localStateMap = convertToMap(localClusterState);
1258-
final int localClusterStateSize = ClusterState.Builder.toBytes(localClusterState).length;
12591257
// Check that the non-master node has the same version of the cluster state as the master and
12601258
// that the master node matches the master (otherwise there is no requirement for the cluster state to
12611259
// match)
@@ -1267,9 +1265,10 @@ protected final void doEnsureClusterStateConsistency(NamedWriteableRegistry name
12671265
masterClusterState.stateUUID(),
12681266
localClusterState.stateUUID()
12691267
);
1270-
// We cannot compare serialization bytes since serialization order of maps is not guaranteed
1271-
// but we can compare serialization sizes - they should be the same
1272-
assertEquals("cluster state size does not match", masterClusterStateSize, localClusterStateSize);
1268+
1269+
// Compare the stateMaps for equality.
1270+
assertNull(XContentTestUtils.differenceBetweenMapsIgnoringArrayOrder(masterStateMap, localStateMap));
1271+
12731272
// Compare JSON serialization
12741273
assertNull(
12751274
"cluster state JSON serialization does not match",

0 commit comments

Comments
 (0)