|
8 | 8 | */ |
9 | 9 | package org.elasticsearch.datastreams; |
10 | 10 |
|
| 11 | +import org.elasticsearch.action.ActionFuture; |
11 | 12 | import org.elasticsearch.action.DocWriteRequest; |
12 | 13 | import org.elasticsearch.action.admin.indices.diskusage.AnalyzeIndexDiskUsageRequest; |
13 | 14 | import org.elasticsearch.action.admin.indices.diskusage.TransportAnalyzeIndexDiskUsageAction; |
|
31 | 32 | import org.elasticsearch.action.index.IndexRequest; |
32 | 33 | import org.elasticsearch.action.search.SearchRequest; |
33 | 34 | import org.elasticsearch.action.support.WriteRequest; |
| 35 | +import org.elasticsearch.action.support.master.AcknowledgedResponse; |
34 | 36 | import org.elasticsearch.cluster.metadata.ComponentTemplate; |
35 | 37 | import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; |
36 | 38 | import org.elasticsearch.cluster.metadata.IndexMetadata; |
@@ -709,17 +711,22 @@ public void testAddDimensionToMapping() throws Exception { |
709 | 711 | ] |
710 | 712 | } |
711 | 713 | """, XContentType.JSON); |
712 | | - assertAcked(client().execute(TransportPutMappingAction.TYPE, putMappingRequest).actionGet()); |
| 714 | + ActionFuture<AcknowledgedResponse> putMappingFuture = client().execute(TransportPutMappingAction.TYPE, putMappingRequest); |
713 | 715 | if (INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG) { |
| 716 | + IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, putMappingFuture::actionGet); |
| 717 | + assertThat(exception.getMessage(), containsString( |
| 718 | + "Cannot add dynamic templates that define dimension fields on an existing index with index.dimensions") |
| 719 | + ); |
714 | 720 | assertThat( |
715 | | - getSetting(dataStreamName, IndexMetadata.INDEX_ROUTING_PATH), |
716 | | - containsInAnyOrder("metricset", "labels.*", "k8s.pod.name") |
| 721 | + getSetting(dataStreamName, IndexMetadata.INDEX_DIMENSIONS), |
| 722 | + containsInAnyOrder("metricset", "k8s.pod.name") |
717 | 723 | ); |
| 724 | + assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_ROUTING_PATH), empty()); |
718 | 725 | } else { |
| 726 | + assertAcked(putMappingFuture); |
719 | 727 | assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_ROUTING_PATH), containsInAnyOrder("metricset")); |
| 728 | + assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_DIMENSIONS), empty()); |
720 | 729 | } |
721 | | - assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_DIMENSIONS), empty()); |
722 | | - |
723 | 730 | indexWithPodNames(dataStreamName, Instant.now(), Map.of(), "dog", "cat"); |
724 | 731 | } |
725 | 732 |
|
|
0 commit comments