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

Fix ILMHistoryItemTests.testTruncateLongError #125814

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,6 @@ tests:
- class: org.elasticsearch.index.engine.ThreadPoolMergeSchedulerTests
method: testSchedulerCloseWaitsForRunningMerge
issue: https://github.com/elastic/elasticsearch/issues/125236
- class: org.elasticsearch.xpack.ilm.history.ILMHistoryItemTests
method: testTruncateLongError
issue: https://github.com/elastic/elasticsearch/issues/125216
- class: org.elasticsearch.index.shard.StoreRecoveryTests
method: testAddIndices
issue: https://github.com/elastic/elasticsearch/issues/124104
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import java.util.Map;

import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.matchesPattern;
import static org.hamcrest.Matchers.startsWith;

public class ILMHistoryItemTests extends ESTestCase {
Expand Down Expand Up @@ -135,15 +137,15 @@ public void testTruncateLongError() throws IOException {
try (XContentParser p = XContentFactory.xContent(XContentType.JSON).createParser(XContentParserConfiguration.EMPTY, json)) {
Map<String, Object> item = p.map();
assertThat(
item.get("error_details"),
equalTo(
(String) item.get("error_details"),
containsString(
"{\"type\":\"illegal_argument_exception\",\"reason\":\""
// We subtract a number of characters here due to the truncation being based
// on the length of the whole string, not just the "reason" part.
+ longError.substring(0, LifecycleExecutionState.MAXIMUM_STEP_INFO_STRING_LENGTH - 47)
+ "... (5126 chars truncated)\"}"
)
);
assertThat((String) item.get("error_details"), matchesPattern(".*\\.\\.\\. \\(\\d+ chars truncated\\).*"));
}
}
}
Expand Down