Skip to content

Commit a4eca73

Browse files
committed
fixed compile error after merging in elastic#59076
(a change got in after I merged in master into this pr, but didn't notice it until I merged this pr)
1 parent 1a2c9ed commit a4eca73

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ public void testUnreferencedDataStreamsWhenAddingTemplate() throws Exception {
10781078
state = ClusterState.builder(state)
10791079
.metadata(Metadata.builder(state.metadata())
10801080
.put(new DataStream("unreferenced",
1081-
new DataStream.TimestampField("@timestamp", Collections.singletonMap("type", "date")),
1081+
new DataStream.TimestampField("@timestamp"),
10821082
Collections.singletonList(new Index(".ds-unreferenced-000001", "uuid2"))))
10831083
.put(IndexMetadata.builder(".ds-unreferenced-000001")
10841084
.settings(Settings.builder()
@@ -1090,15 +1090,23 @@ public void testUnreferencedDataStreamsWhenAddingTemplate() throws Exception {
10901090
.build())
10911091
.build();
10921092

1093-
ComposableIndexTemplate template = new ComposableIndexTemplate(Collections.singletonList("logs-*-*"), null, null,
1094-
100L, null, null, new ComposableIndexTemplate.DataStreamTemplate("@timestamp"));
1093+
String mapping = "{\n" +
1094+
" \"properties\": {\n" +
1095+
" \"@timestamp\": {\n" +
1096+
" \"type\": \"date\"\n" +
1097+
" }\n" +
1098+
" }\n" +
1099+
" }";
1100+
Template mappingTemplate = new Template(null, new CompressedXContent(mapping), null);
1101+
ComposableIndexTemplate template = new ComposableIndexTemplate(Collections.singletonList("logs-*-*"),
1102+
mappingTemplate, null, 100L, null, null, new ComposableIndexTemplate.DataStreamTemplate("@timestamp"));
10951103

10961104
state = service.addIndexTemplateV2(state, false, "logs", template);
10971105

10981106
ClusterState stateWithDS = ClusterState.builder(state)
10991107
.metadata(Metadata.builder(state.metadata())
11001108
.put(new DataStream("logs-mysql-default",
1101-
new DataStream.TimestampField("@timestamp", Collections.singletonMap("type", "date")),
1109+
new DataStream.TimestampField("@timestamp"),
11021110
Collections.singletonList(new Index(".ds-logs-mysql-default-000001", "uuid"))))
11031111
.put(IndexMetadata.builder(".ds-logs-mysql-default-000001")
11041112
.settings(Settings.builder()
@@ -1134,8 +1142,8 @@ public void testUnreferencedDataStreamsWhenAddingTemplate() throws Exception {
11341142

11351143
// Change the pattern to one that doesn't match the data stream
11361144
e = expectThrows(IllegalArgumentException.class, () -> {
1137-
ComposableIndexTemplate newTemplate = new ComposableIndexTemplate(Collections.singletonList("logs-postgres-*"), null, null,
1138-
100L, null, null, new ComposableIndexTemplate.DataStreamTemplate("@timestamp"));
1145+
ComposableIndexTemplate newTemplate = new ComposableIndexTemplate(Collections.singletonList("logs-postgres-*"), mappingTemplate,
1146+
null, 100L, null, null, new ComposableIndexTemplate.DataStreamTemplate("@timestamp"));
11391147
service.addIndexTemplateV2(stateWithDS, false, "logs", newTemplate);
11401148
});
11411149

@@ -1144,8 +1152,8 @@ public void testUnreferencedDataStreamsWhenAddingTemplate() throws Exception {
11441152
"cause data streams [unreferenced, logs-mysql-default] to no longer match a data stream template"));
11451153

11461154
// Add an additional template that matches our data stream at a lower priority
1147-
ComposableIndexTemplate mysqlTemplate = new ComposableIndexTemplate(Collections.singletonList("logs-mysql-*"), null, null,
1148-
50L, null, null, new ComposableIndexTemplate.DataStreamTemplate("@timestamp"));
1155+
ComposableIndexTemplate mysqlTemplate = new ComposableIndexTemplate(Collections.singletonList("logs-mysql-*"), mappingTemplate,
1156+
null, 50L, null, null, new ComposableIndexTemplate.DataStreamTemplate("@timestamp"));
11491157
ClusterState stateWithDSAndTemplate = service.addIndexTemplateV2(stateWithDS, false, "logs-mysql", mysqlTemplate);
11501158

11511159
// We should be able to replace the "logs" template, because we have the "logs-mysql" template that can handle the data stream

0 commit comments

Comments
 (0)