Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import java.time.Instant;
import java.util.List;
import java.util.Locale;
import java.util.function.Supplier;

import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
Expand All @@ -31,8 +32,9 @@ public class DownsampleIT extends DownsamplingIntegTestCase {
public void testDownsamplingPassthroughDimensions() throws Exception {
String dataStreamName = "metrics-foo";
// Set up template
putTSDBIndexTemplate("my-template", List.of("metrics-foo"), null, """
putTSDBIndexTemplate("my-template", List.of("metrics-foo"), null, String.format(Locale.ROOT, """
{
%s
"properties": {
"attributes": {
"type": "passthrough",
Expand All @@ -45,7 +47,7 @@ public void testDownsamplingPassthroughDimensions() throws Exception {
}
}
}
""", null, null);
""", generateForceMergeMetadata()), null, null);

// Create data stream by indexing documents
final Instant now = Instant.now();
Expand Down Expand Up @@ -96,4 +98,14 @@ public void testDownsamplingPassthroughDimensions() throws Exception {

assertDownsampleIndexFieldsAndDimensions(sourceIndex, targetIndex, downsampleConfig);
}

private String generateForceMergeMetadata() {
return switch (randomIntBetween(0, 4)) {
case 0 -> "\"_meta\": { \"downsample.forcemerge.enabled\": false},";
case 1 -> "\"_meta\": { \"downsample.forcemerge.enabled\": true},";
case 2 -> "\"_meta\": { \"downsample.forcemerge.enabled\": 4},";
case 3 -> "\"_meta\": { \"downsample.forcemerge.enabled\": null},";
default -> "";
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ void assertDownsampleIndexFieldsAndDimensions(String sourceIndex, String downsam
final CompressedXContent sourceIndexCompressedXContent = new CompressedXContent(sourceIndexMappings);
mapperService.merge(MapperService.SINGLE_MAPPING_NAME, sourceIndexCompressedXContent, MapperService.MergeReason.INDEX_TEMPLATE);

assertThat(downsampleIndexMappings.get("_meta"), equalTo(sourceIndexMappings.get("_meta")));

// Collect expected mappings for fields and dimensions
Map<String, TimeSeriesParams.MetricType> metricFields = new HashMap<>();
Map<String, String> dimensionFields = new HashMap<>();
Expand Down
Loading