Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/107515 RestoreTemplateWithMatchOnlyTextMapperIT #120392

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9d9b6af
unmute tests
drempapis Jan 3, 2025
02ddf82
revert
drempapis Jan 3, 2025
bf79ef3
Merge remote-tracking branch 'upstream/main'
drempapis Jan 3, 2025
f1c91bd
Merge remote-tracking branch 'upstream/main'
drempapis Jan 7, 2025
ba67bff
Merge remote-tracking branch 'upstream/main'
drempapis Jan 7, 2025
2c3654a
Merge remote-tracking branch 'upstream/main'
drempapis Jan 8, 2025
58d4762
Merge remote-tracking branch 'upstream/main'
drempapis Jan 8, 2025
bc38090
Merge remote-tracking branch 'upstream/main'
drempapis Jan 9, 2025
ef0447b
Merge remote-tracking branch 'upstream/main'
drempapis Jan 9, 2025
fe009d7
Merge remote-tracking branch 'upstream/main'
drempapis Jan 10, 2025
a747a40
Merge remote-tracking branch 'upstream/main'
drempapis Jan 10, 2025
f3e47ae
Merge remote-tracking branch 'upstream/main'
drempapis Jan 10, 2025
2bc0107
Merge remote-tracking branch 'upstream/main'
drempapis Jan 13, 2025
f3b3d00
Merge remote-tracking branch 'upstream/main'
drempapis Jan 13, 2025
f52789e
Merge remote-tracking branch 'upstream/main'
drempapis Jan 14, 2025
ec243b7
Merge remote-tracking branch 'upstream/main'
drempapis Jan 14, 2025
f93eb9b
Merge remote-tracking branch 'upstream/main'
drempapis Jan 16, 2025
2777916
Merge remote-tracking branch 'upstream/main'
drempapis Jan 16, 2025
623bd7b
Merge remote-tracking branch 'upstream/main'
drempapis Jan 16, 2025
3fee6af
Merge remote-tracking branch 'upstream/main'
drempapis Jan 16, 2025
af3fff9
Merge remote-tracking branch 'upstream/main'
drempapis Jan 17, 2025
a41bbad
Merge remote-tracking branch 'upstream/main'
drempapis Jan 17, 2025
936e623
add PoC test
drempapis Jan 17, 2025
d7070bc
update
drempapis Jan 17, 2025
b3532c1
Address test failure
drempapis Jan 17, 2025
52d483e
Update pr
drempapis Jan 17, 2025
691a341
Merge branch 'main' into test/107515_RestoreTemplateWithMatchOnlyText…
drempapis Jan 17, 2025
6714b42
Update docs/changelog/120392.yaml
drempapis Jan 17, 2025
ff6291f
[CI] Auto commit changes from spotless
elasticsearchmachine Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/120392.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 120392
summary: Test/107515 restore template with match only text mapper it fail
area: Search
type: bug
issues:
- 107515
Original file line number Diff line number Diff line change
Expand Up @@ -1095,11 +1095,8 @@ public void testPartialRestoreSnapshotThatIncludesDataStream() {

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

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

}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
Expand Down Expand Up @@ -1243,7 +1244,6 @@ protected final void doEnsureClusterStateConsistency(NamedWriteableRegistry name
namedWriteableRegistry
);
Map<String, Object> masterStateMap = convertToMap(masterClusterState);
int masterClusterStateSize = ClusterState.Builder.toBytes(masterClusterState).length;
String masterId = masterClusterState.nodes().getMasterNodeId();
for (SubscribableListener<ClusterStateResponse> localStateListener : localStates) {
localStateListener.andThenAccept(localClusterStateResponse -> {
Expand All @@ -1255,7 +1255,6 @@ protected final void doEnsureClusterStateConsistency(NamedWriteableRegistry name
namedWriteableRegistry
);
final Map<String, Object> localStateMap = convertToMap(localClusterState);
final int localClusterStateSize = ClusterState.Builder.toBytes(localClusterState).length;
// 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)
Expand All @@ -1268,8 +1267,12 @@ protected final void doEnsureClusterStateConsistency(NamedWriteableRegistry name
localClusterState.stateUUID()
);
// We cannot compare serialization bytes since serialization order of maps is not guaranteed
// but we can compare serialization sizes - they should be the same
assertEquals("cluster state size does not match", masterClusterStateSize, localClusterStateSize);
// but we can compare if the Strings are identical by "counting" the characters
assertTrue(
"cluster states must be equal",
equal(masterClusterState.toString(), localClusterState.toString())
);

// Compare JSON serialization
assertNull(
"cluster state JSON serialization does not match",
Expand All @@ -1291,6 +1294,22 @@ protected final void doEnsureClusterStateConsistency(NamedWriteableRegistry name
safeGet(future);
}

private static boolean equal(String str1, String str2) {
if (str1.length() != str2.length()) return false;

Map<Character, Integer> charCount = new HashMap<>();
str1.chars().mapToObj(c -> (char) c).forEach(c -> charCount.put(c, charCount.getOrDefault(c, 0) + 1));

str2.chars().mapToObj(c -> (char) c).forEach(c -> {
charCount.put(c, charCount.getOrDefault(c, 0) - 1);
if (charCount.get(c) == 0) {
charCount.remove(c);
}
});

return charCount.isEmpty();
}

protected void ensureClusterStateCanBeReadByNodeTool() throws IOException {
if (cluster() != null && cluster().size() > 0) {
final Client masterClient = client();
Expand Down