|
13 | 13 | import org.elasticsearch.common.settings.Settings; |
14 | 14 | import org.elasticsearch.index.IndexSettings; |
15 | 15 | import org.elasticsearch.index.IndexVersion; |
| 16 | +import org.elasticsearch.index.mapper.TimeSeriesParams; |
16 | 17 | import org.elasticsearch.test.ESTestCase; |
17 | 18 | import org.elasticsearch.xpack.core.ilm.LifecycleSettings; |
18 | 19 |
|
19 | 20 | import java.util.List; |
| 21 | +import java.util.Map; |
20 | 22 | import java.util.UUID; |
21 | 23 |
|
| 24 | +import static org.hamcrest.Matchers.is; |
| 25 | + |
22 | 26 | public class TransportDownsampleActionTests extends ESTestCase { |
23 | 27 | public void testCopyIndexMetadata() { |
24 | 28 | // GIVEN |
@@ -107,4 +111,25 @@ private static void assertTargetSettings(final IndexMetadata indexMetadata, fina |
107 | 111 | settings.get(IndexMetadata.SETTING_CREATION_DATE) |
108 | 112 | ); |
109 | 113 | } |
| 114 | + |
| 115 | + public void testGetSupportedMetrics() { |
| 116 | + TimeSeriesParams.MetricType metricType = TimeSeriesParams.MetricType.GAUGE; |
| 117 | + Map<String, Object> fieldProperties = Map.of( |
| 118 | + "type", |
| 119 | + "aggregate_metric_double", |
| 120 | + "metrics", |
| 121 | + List.of("max", "sum"), |
| 122 | + "default_metric", |
| 123 | + "sum" |
| 124 | + ); |
| 125 | + |
| 126 | + var supported = TransportDownsampleAction.getSupportedMetrics(metricType, fieldProperties); |
| 127 | + assertThat(supported.defaultMetric(), is("sum")); |
| 128 | + assertThat(supported.supportedMetrics(), is(List.of("max", "sum"))); |
| 129 | + |
| 130 | + fieldProperties = Map.of("type", "integer"); |
| 131 | + supported = TransportDownsampleAction.getSupportedMetrics(metricType, fieldProperties); |
| 132 | + assertThat(supported.defaultMetric(), is("max")); |
| 133 | + assertThat(supported.supportedMetrics(), is(List.of(metricType.supportedAggs()))); |
| 134 | + } |
110 | 135 | } |
0 commit comments