Skip to content

Commit 2e64e34

Browse files
committed
Fix TSDBIndexingIT
1 parent 33b0a22 commit 2e64e34

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/TSDBIndexingIT.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
package org.elasticsearch.datastreams;
1010

11+
import org.elasticsearch.action.ActionFuture;
1112
import org.elasticsearch.action.DocWriteRequest;
1213
import org.elasticsearch.action.admin.indices.diskusage.AnalyzeIndexDiskUsageRequest;
1314
import org.elasticsearch.action.admin.indices.diskusage.TransportAnalyzeIndexDiskUsageAction;
@@ -31,6 +32,7 @@
3132
import org.elasticsearch.action.index.IndexRequest;
3233
import org.elasticsearch.action.search.SearchRequest;
3334
import org.elasticsearch.action.support.WriteRequest;
35+
import org.elasticsearch.action.support.master.AcknowledgedResponse;
3436
import org.elasticsearch.cluster.metadata.ComponentTemplate;
3537
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
3638
import org.elasticsearch.cluster.metadata.IndexMetadata;
@@ -709,17 +711,22 @@ public void testAddDimensionToMapping() throws Exception {
709711
]
710712
}
711713
""", XContentType.JSON);
712-
assertAcked(client().execute(TransportPutMappingAction.TYPE, putMappingRequest).actionGet());
714+
ActionFuture<AcknowledgedResponse> putMappingFuture = client().execute(TransportPutMappingAction.TYPE, putMappingRequest);
713715
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+
);
714720
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")
717723
);
724+
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_ROUTING_PATH), empty());
718725
} else {
726+
assertAcked(putMappingFuture);
719727
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_ROUTING_PATH), containsInAnyOrder("metricset"));
728+
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_DIMENSIONS), empty());
720729
}
721-
assertThat(getSetting(dataStreamName, IndexMetadata.INDEX_DIMENSIONS), empty());
722-
723730
indexWithPodNames(dataStreamName, Instant.now(), Map.of(), "dog", "cat");
724731
}
725732

modules/data-streams/src/main/java/org/elasticsearch/datastreams/DataStreamIndexSettingsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public void onUpdateMappings(IndexMetadata indexMetadata, DocumentMapper documen
173173
&& new HashSet<>(indexDimensions).equals(new HashSet<>(newIndexDimensions)) == false;
174174
if (matchesAllDimensions == false) {
175175
throw new IllegalArgumentException(
176-
"Cannot add dimension fields via dynamic templates or mappings for an index with "
176+
"Cannot add dynamic templates that define dimension fields on an existing index with "
177177
+ INDEX_DIMENSIONS.getKey()
178178
+ ". "
179179
+ "Please change the index template and roll over the data stream "

modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamIndexSettingsProviderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ public void testAddDynamicTemplate() throws Exception {
963963
assertThat(
964964
exception.getMessage(),
965965
equalTo(
966-
"Cannot add dimension fields via dynamic templates or mappings for an index with index.dimensions. "
966+
"Cannot add dynamic templates that define dimension fields on an existing index with index.dimensions. "
967967
+ "Please change the index template and roll over the data stream "
968968
+ "instead of modifying the mappings of the backing indices."
969969
)

0 commit comments

Comments
 (0)