|
12 | 12 | import org.elasticsearch.cluster.metadata.DataStreamTestHelper; |
13 | 13 | import org.elasticsearch.cluster.metadata.IndexMetadata; |
14 | 14 | import org.elasticsearch.cluster.metadata.ProjectMetadata; |
15 | | -import org.elasticsearch.cluster.routing.TimeSeriesDimensionsMetadataAccessor; |
16 | 15 | import org.elasticsearch.common.collect.ImmutableOpenMap; |
17 | 16 | import org.elasticsearch.common.compress.CompressedXContent; |
18 | 17 | import org.elasticsearch.common.settings.Settings; |
@@ -105,14 +104,11 @@ public void testGetAdditionalIndexSettings() throws Exception { |
105 | 104 | // The index.time_series.end_time setting requires index.mode to be set to time_series adding it here so that we read this setting: |
106 | 105 | // (in production the index.mode setting is usually provided in an index or component template) |
107 | 106 | result = builder().put(result).put("index.mode", "time_series").build(); |
108 | | - assertThat(result.size(), equalTo(3)); |
| 107 | + assertThat(result.size(), equalTo(4)); |
109 | 108 | assertThat(IndexSettings.MODE.get(result), equalTo(IndexMode.TIME_SERIES)); |
110 | 109 | assertThat(IndexSettings.TIME_SERIES_START_TIME.get(result), equalTo(now.minusMillis(DEFAULT_LOOK_BACK_TIME.getMillis()))); |
111 | 110 | assertThat(IndexSettings.TIME_SERIES_END_TIME.get(result), equalTo(now.plusMillis(DEFAULT_LOOK_AHEAD_TIME.getMillis()))); |
112 | | - assertThat( |
113 | | - TimeSeriesDimensionsMetadataAccessor.fromCustomMetadata(customMetadataBuilder.build()), |
114 | | - containsInAnyOrder("field3", "field4", "field5", "field6") |
115 | | - ); |
| 111 | + assertThat(IndexMetadata.INDEX_DIMENSIONS.get(result), containsInAnyOrder("field3", "field4", "field5", "field6")); |
116 | 112 | } |
117 | 113 |
|
118 | 114 | public void testGetAdditionalIndexSettingsIndexRoutingPathAlreadyDefined() throws Exception { |
@@ -234,14 +230,11 @@ public void testGetAdditionalIndexSettingsMappingsMerging() throws Exception { |
234 | 230 | // The index.time_series.end_time setting requires index.mode to be set to time_series adding it here so that we read this setting: |
235 | 231 | // (in production the index.mode setting is usually provided in an index or component template) |
236 | 232 | result = builder().put(result).put("index.mode", "time_series").build(); |
237 | | - assertThat(result.size(), equalTo(3)); |
| 233 | + assertThat(result.size(), equalTo(4)); |
238 | 234 | assertThat(IndexSettings.MODE.get(result), equalTo(IndexMode.TIME_SERIES)); |
239 | 235 | assertThat(IndexSettings.TIME_SERIES_START_TIME.get(result), equalTo(now.minusMillis(DEFAULT_LOOK_BACK_TIME.getMillis()))); |
240 | 236 | assertThat(IndexSettings.TIME_SERIES_END_TIME.get(result), equalTo(now.plusMillis(DEFAULT_LOOK_AHEAD_TIME.getMillis()))); |
241 | | - assertThat( |
242 | | - TimeSeriesDimensionsMetadataAccessor.fromCustomMetadata(customMetadataBuilder.build()), |
243 | | - containsInAnyOrder("field1", "field3") |
244 | | - ); |
| 237 | + assertThat(IndexMetadata.INDEX_DIMENSIONS.get(result), containsInAnyOrder("field1", "field3")); |
245 | 238 | } |
246 | 239 |
|
247 | 240 | public void testGetAdditionalIndexSettingsNoMappings() { |
@@ -536,14 +529,11 @@ public void testGenerateRoutingPathFromDynamicTemplate() throws Exception { |
536 | 529 | """; |
537 | 530 | ImmutableOpenMap.Builder<String, Map<String, String>> customMetadataBuilder = ImmutableOpenMap.builder(); |
538 | 531 | Settings result = generateTsdbSettings(mapping, now, customMetadataBuilder); |
539 | | - assertThat(result.size(), equalTo(3)); |
| 532 | + assertThat(result.size(), equalTo(4)); |
540 | 533 | assertThat(IndexSettings.MODE.get(result), equalTo(IndexMode.TIME_SERIES)); |
541 | 534 | assertThat(IndexSettings.TIME_SERIES_START_TIME.get(result), equalTo(now.minusMillis(DEFAULT_LOOK_BACK_TIME.getMillis()))); |
542 | 535 | assertThat(IndexSettings.TIME_SERIES_END_TIME.get(result), equalTo(now.plusMillis(DEFAULT_LOOK_AHEAD_TIME.getMillis()))); |
543 | | - assertThat( |
544 | | - TimeSeriesDimensionsMetadataAccessor.fromCustomMetadata(customMetadataBuilder.build()), |
545 | | - containsInAnyOrder("host.id", "prometheus.labels.*") |
546 | | - ); |
| 536 | + assertThat(IndexMetadata.INDEX_DIMENSIONS.get(result), containsInAnyOrder("host.id", "prometheus.labels.*")); |
547 | 537 | } |
548 | 538 |
|
549 | 539 | public void testGenerateRoutingPathFromDynamicTemplateWithMultiplePathMatchEntries() throws Exception { |
@@ -580,13 +570,14 @@ public void testGenerateRoutingPathFromDynamicTemplateWithMultiplePathMatchEntri |
580 | 570 | """; |
581 | 571 | ImmutableOpenMap.Builder<String, Map<String, String>> customMetadataBuilder = ImmutableOpenMap.builder(); |
582 | 572 | Settings result = generateTsdbSettings(mapping, now, customMetadataBuilder); |
583 | | - assertThat(result.size(), equalTo(3)); |
| 573 | + assertThat(result.size(), equalTo(4)); |
584 | 574 | assertThat(IndexSettings.MODE.get(result), equalTo(IndexMode.TIME_SERIES)); |
585 | 575 | assertThat(IndexSettings.TIME_SERIES_START_TIME.get(result), equalTo(now.minusMillis(DEFAULT_LOOK_BACK_TIME.getMillis()))); |
586 | 576 | assertThat(IndexSettings.TIME_SERIES_END_TIME.get(result), equalTo(now.plusMillis(DEFAULT_LOOK_AHEAD_TIME.getMillis()))); |
587 | | - List<String> routingPathList = TimeSeriesDimensionsMetadataAccessor.fromCustomMetadata(customMetadataBuilder.build()); |
588 | | - assertThat(routingPathList, containsInAnyOrder("host.id", "xprometheus.labels.*", "yprometheus.labels.*")); |
589 | | - assertEquals(3, routingPathList.size()); |
| 577 | + assertThat( |
| 578 | + IndexMetadata.INDEX_DIMENSIONS.get(result), |
| 579 | + containsInAnyOrder("host.id", "xprometheus.labels.*", "yprometheus.labels.*") |
| 580 | + ); |
590 | 581 | } |
591 | 582 |
|
592 | 583 | public void testGenerateRoutingPathFromDynamicTemplateWithMultiplePathMatchEntriesMultiFields() throws Exception { |
@@ -628,13 +619,14 @@ public void testGenerateRoutingPathFromDynamicTemplateWithMultiplePathMatchEntri |
628 | 619 | """; |
629 | 620 | ImmutableOpenMap.Builder<String, Map<String, String>> customMetadataBuilder = ImmutableOpenMap.builder(); |
630 | 621 | Settings result = generateTsdbSettings(mapping, now, customMetadataBuilder); |
631 | | - assertThat(result.size(), equalTo(3)); |
| 622 | + assertThat(result.size(), equalTo(4)); |
632 | 623 | assertThat(IndexSettings.MODE.get(result), equalTo(IndexMode.TIME_SERIES)); |
633 | 624 | assertThat(IndexSettings.TIME_SERIES_START_TIME.get(result), equalTo(now.minusMillis(DEFAULT_LOOK_BACK_TIME.getMillis()))); |
634 | 625 | assertThat(IndexSettings.TIME_SERIES_END_TIME.get(result), equalTo(now.plusMillis(DEFAULT_LOOK_AHEAD_TIME.getMillis()))); |
635 | | - List<String> dimensions = TimeSeriesDimensionsMetadataAccessor.fromCustomMetadata(customMetadataBuilder.build()); |
636 | | - assertThat(dimensions, containsInAnyOrder("host.id", "xprometheus.labels.*", "yprometheus.labels.*")); |
637 | | - assertEquals(3, dimensions.size()); |
| 626 | + assertThat( |
| 627 | + IndexMetadata.INDEX_DIMENSIONS.get(result), |
| 628 | + containsInAnyOrder("host.id", "xprometheus.labels.*", "yprometheus.labels.*") |
| 629 | + ); |
638 | 630 | } |
639 | 631 |
|
640 | 632 | public void testGenerateRoutingPathFromDynamicTemplate_templateWithNoPathMatch() throws Exception { |
@@ -680,14 +672,11 @@ public void testGenerateRoutingPathFromDynamicTemplate_templateWithNoPathMatch() |
680 | 672 | """; |
681 | 673 | ImmutableOpenMap.Builder<String, Map<String, String>> customMetadataBuilder = ImmutableOpenMap.builder(); |
682 | 674 | Settings result = generateTsdbSettings(mapping, now, customMetadataBuilder); |
683 | | - assertThat(result.size(), equalTo(3)); |
| 675 | + assertThat(result.size(), equalTo(4)); |
684 | 676 | assertThat(IndexSettings.MODE.get(result), equalTo(IndexMode.TIME_SERIES)); |
685 | 677 | assertThat(IndexSettings.TIME_SERIES_START_TIME.get(result), equalTo(now.minusMillis(DEFAULT_LOOK_BACK_TIME.getMillis()))); |
686 | 678 | assertThat(IndexSettings.TIME_SERIES_END_TIME.get(result), equalTo(now.plusMillis(DEFAULT_LOOK_AHEAD_TIME.getMillis()))); |
687 | | - assertThat( |
688 | | - TimeSeriesDimensionsMetadataAccessor.fromCustomMetadata(customMetadataBuilder.build()), |
689 | | - containsInAnyOrder("host.id", "prometheus.labels.*") |
690 | | - ); |
| 679 | + assertThat(IndexMetadata.INDEX_DIMENSIONS.get(result), containsInAnyOrder("host.id", "prometheus.labels.*")); |
691 | 680 | } |
692 | 681 |
|
693 | 682 | public void testGenerateRoutingPathFromDynamicTemplate_nonKeywordTemplate() throws Exception { |
@@ -735,9 +724,7 @@ public void testGenerateRoutingPathFromDynamicTemplate_nonKeywordTemplate() thro |
735 | 724 | Settings result = generateTsdbSettings(mapping, now, customMetadataBuilder); |
736 | 725 | assertThat(IndexSettings.TIME_SERIES_START_TIME.get(result), equalTo(now.minusMillis(DEFAULT_LOOK_BACK_TIME.getMillis()))); |
737 | 726 | assertThat(IndexSettings.TIME_SERIES_END_TIME.get(result), equalTo(now.plusMillis(DEFAULT_LOOK_AHEAD_TIME.getMillis()))); |
738 | | - List<String> dimensions = TimeSeriesDimensionsMetadataAccessor.fromCustomMetadata(customMetadataBuilder.build()); |
739 | | - assertThat(dimensions, containsInAnyOrder("host.id", "prometheus.labels.*")); |
740 | | - assertEquals(2, dimensions.size()); |
| 727 | + assertThat(IndexMetadata.INDEX_DIMENSIONS.get(result), containsInAnyOrder("host.id", "prometheus.labels.*")); |
741 | 728 | } |
742 | 729 |
|
743 | 730 | public void testGenerateRoutingPathFromPassThroughObject() throws Exception { |
@@ -769,11 +756,11 @@ public void testGenerateRoutingPathFromPassThroughObject() throws Exception { |
769 | 756 | """; |
770 | 757 | ImmutableOpenMap.Builder<String, Map<String, String>> customMetadataBuilder = ImmutableOpenMap.builder(); |
771 | 758 | Settings result = generateTsdbSettings(mapping, now, customMetadataBuilder); |
772 | | - assertThat(result.size(), equalTo(3)); |
| 759 | + assertThat(result.size(), equalTo(4)); |
773 | 760 | assertThat(IndexSettings.MODE.get(result), equalTo(IndexMode.TIME_SERIES)); |
774 | 761 | assertThat(IndexSettings.TIME_SERIES_START_TIME.get(result), equalTo(now.minusMillis(DEFAULT_LOOK_BACK_TIME.getMillis()))); |
775 | 762 | assertThat(IndexSettings.TIME_SERIES_END_TIME.get(result), equalTo(now.plusMillis(DEFAULT_LOOK_AHEAD_TIME.getMillis()))); |
776 | | - assertThat(TimeSeriesDimensionsMetadataAccessor.fromCustomMetadata(customMetadataBuilder.build()), containsInAnyOrder("labels.*")); |
| 763 | + assertThat(IndexMetadata.INDEX_DIMENSIONS.get(result), containsInAnyOrder("labels.*")); |
777 | 764 | } |
778 | 765 |
|
779 | 766 | private Settings generateTsdbSettings(String mapping, Instant now, ImmutableOpenMap.Builder<String, Map<String, String>> builder) |
|
0 commit comments