Skip to content

Commit 33e46ab

Browse files
committed
Fix LogsdbSortConfigIT
1 parent cfb6905 commit 33e46ab

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

x-pack/plugin/logsdb/src/internalClusterTest/java/org/elasticsearch/xpack/logsdb/LogsdbSortConfigIT.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.util.Collection;
4545
import java.util.List;
4646
import java.util.function.Consumer;
47+
import java.util.function.UnaryOperator;
4748

4849
import static org.hamcrest.Matchers.equalTo;
4950
import static org.hamcrest.Matchers.hasSize;
@@ -130,7 +131,7 @@ public void testHostnameMessageTimestampSortConfig() throws IOException {
130131
doc("{\"@timestamp\":\"2025-01-01T12:00:00\",\"test_id\": \"%id%\"}"),
131132
doc("{\"@timestamp\":\"2025-01-01T11:00:00\",\"test_id\": \"%id%\"}") };
132133

133-
createDataStream(dataStreamName, mapping);
134+
createDataStream(dataStreamName, mapping, b -> b.put("index.logsdb.default_sort_on_message_template", true));
134135

135136
List<DocWithId> shuffledDocs = shuffledList(Arrays.asList(orderedDocs));
136137
indexDocuments(dataStreamName, shuffledDocs);
@@ -264,11 +265,21 @@ public void testTimestampOnlySortConfig() throws IOException {
264265
}
265266

266267
private void createDataStream(String dataStreamName, String mapping) throws IOException {
268+
createDataStream(dataStreamName, mapping, UnaryOperator.identity());
269+
}
270+
271+
private void createDataStream(String dataStreamName, String mapping, UnaryOperator<Settings.Builder> settings) throws IOException {
267272
var putTemplateRequest = new TransportPutComposableIndexTemplateAction.Request("id");
268273
putTemplateRequest.indexTemplate(
269274
ComposableIndexTemplate.builder()
270275
.indexPatterns(List.of(dataStreamName + "*"))
271-
.template(new Template(indexSettings(1, 0).put("index.mode", "logsdb").build(), new CompressedXContent(mapping), null))
276+
.template(
277+
new Template(
278+
settings.apply(indexSettings(1, 0)).put("index.mode", "logsdb").build(),
279+
new CompressedXContent(mapping),
280+
null
281+
)
282+
)
272283
.dataStreamTemplate(new ComposableIndexTemplate.DataStreamTemplate(false, false))
273284
.build()
274285
);

0 commit comments

Comments
 (0)