@@ -92,3 +92,111 @@ setup:
9292 index : my-data-stream-1
9393 - match : { .$oldIndexName.mappings.properties.name: null }
9494 - match : { .$newIndexName.mappings.properties.name.type: "keyword" }
95+
96+ ---
97+ " Test mappings component templates only " :
98+ - requires :
99+ cluster_features : [ "logs_stream" ]
100+ reason : requires setting 'logs_stream' to get or set data stream settings
101+
102+ - do :
103+ cluster.put_component_template :
104+ name : mappings-template
105+ body :
106+ template :
107+ mappings :
108+ properties :
109+ field1 :
110+ type : keyword
111+ field2 :
112+ type : keyword
113+
114+ - do :
115+ allowed_warnings :
116+ - " index template [my-component-only-template] has index patterns [my-component-only-data-stream-*] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-component-only-template] will take precedence during new index creation"
117+ indices.put_index_template :
118+ name : my-component-only-template
119+ body :
120+ index_patterns : [ my-component-only-data-stream-* ]
121+ data_stream : { }
122+ composed_of :
123+ - mappings-template
124+
125+ - do :
126+ indices.create_data_stream :
127+ name : my-component-only-data-stream-1
128+
129+ - do :
130+ cluster.health :
131+ index : " my-component-only-data-stream-1"
132+ wait_for_status : green
133+
134+ - do :
135+ indices.get_data_stream :
136+ name : my-component-only-data-stream-1
137+ - match : { data_streams.0.name: my-component-only-data-stream-1 }
138+ - match : { data_streams.0.mappings: {} }
139+ - match : { data_streams.0.effective_mappings: null }
140+
141+ - do :
142+ indices.put_data_stream_mappings :
143+ name : my-component-only-data-stream-1
144+ body :
145+ properties :
146+ field1 :
147+ type : text
148+ field3 :
149+ type : text
150+ - match : { data_streams.0.name: my-component-only-data-stream-1 }
151+ - match : { data_streams.0.applied_to_data_stream: true }
152+ - match : { data_streams.0.mappings.properties.field1.type: "text" }
153+ - match : { data_streams.0.mappings.properties.field2: null }
154+ - match : { data_streams.0.mappings.properties.field3.type: "text" }
155+ - match : { data_streams.0.effective_mappings.properties.field1.type: "text" }
156+ - match : { data_streams.0.effective_mappings.properties.field2: null }
157+ - match : { data_streams.0.effective_mappings.properties.field3.type: "text" }
158+
159+ - do :
160+ indices.rollover :
161+ alias : " my-component-only-data-stream-1"
162+
163+ - do :
164+ cluster.health :
165+ index : " my-component-only-data-stream-1"
166+ wait_for_status : green
167+
168+ - do :
169+ indices.get_data_stream_mappings :
170+ name : my-component-only-data-stream-1
171+ - match : { data_streams.0.name: my-component-only-data-stream-1 }
172+ - length : { data_streams.0.effective_mappings.properties: 2 }
173+ - match : { data_streams.0.mappings.properties.field1.type: "text" }
174+ - match : { data_streams.0.effective_mappings.properties.field3.type: "text" }
175+
176+ - do :
177+ indices.get_data_stream :
178+ name : my-component-only-data-stream-1
179+ - match : { data_streams.0.name: my-component-only-data-stream-1 }
180+ - match : { data_streams.0.mappings.properties.field1.type: "text" }
181+ - match : { data_streams.0.effective_mappings: null }
182+ - set : { data_streams.0.indices.0.index_name: oldIndexName }
183+ - set : { data_streams.0.indices.1.index_name: newIndexName }
184+
185+ - do :
186+ indices.get_mapping :
187+ index : my-component-only-data-stream-1
188+ - match : { .$oldIndexName.mappings.properties.field1.type: "keyword" }
189+ - match : { .$oldIndexName.mappings.properties.field2.type: "keyword" }
190+ - match : { .$oldIndexName.mappings.properties.field3: null }
191+ - match : { .$newIndexName.mappings.properties.field1.type: "text" }
192+ - match : { .$newIndexName.mappings.properties.field2.type: "keyword" }
193+ - match : { .$newIndexName.mappings.properties.field3.type: "text" }
194+
195+ - do :
196+ indices.put_data_stream_mappings :
197+ name : my-component-only-data-stream-1
198+ body : {}
199+ - match : { data_streams.0.name: my-component-only-data-stream-1 }
200+ - match : { data_streams.0.applied_to_data_stream: true }
201+ - match : { data_streams.0.mappings null }
202+ - match : { data_streams.0.effective_mappings: null }
0 commit comments