Skip to content

Commit c4815b3

Browse files
LogsDB host and timestamp mappings tests (#114001)
Here we are testing mappings of `host` and `timestamp` fields as they are used as default fields to sort on when using LogsDB. LogsDB uses a `host.name` field mapped as a `keyword` and a `@timestamp` field, required by data streams. Some mappings throw errors as a result of incompatibilities when trying to merge object fields. Such errors are expected.
1 parent d907181 commit c4815b3

File tree

2 files changed

+260
-0
lines changed

2 files changed

+260
-0
lines changed

x-pack/plugin/logsdb/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ base {
2323
archivesName = 'x-pack-logsdb'
2424
}
2525

26+
restResources {
27+
restApi {
28+
include 'bulk', 'search', '_common', 'indices', 'index', 'cluster', 'data_stream', 'ingest', 'cat', 'capabilities'
29+
}
30+
}
31+
2632
dependencies {
2733
compileOnly project(path: xpackModule('core'))
2834
testImplementation(testArtifact(project(xpackModule('core'))))
Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
---
2+
create logsdb data stream with host.name as keyword:
3+
- requires:
4+
cluster_features: [ "mapper.keyword_normalizer_synthetic_source" ]
5+
reason: support for normalizer on keyword fields
6+
7+
- do:
8+
cluster.put_component_template:
9+
name: "logsdb-mappings"
10+
body:
11+
template:
12+
settings:
13+
mode: "logsdb"
14+
mappings:
15+
properties:
16+
host.name:
17+
type: "keyword"
18+
19+
- do:
20+
indices.put_index_template:
21+
name: "logsdb-index-template"
22+
body:
23+
index_patterns: ["logsdb"]
24+
data_stream: {}
25+
composed_of: ["logsdb-mappings"]
26+
27+
- do:
28+
indices.create_data_stream:
29+
name: "logsdb"
30+
31+
- is_true: acknowledged
32+
33+
---
34+
create logsdb data stream with host.name as keyword and timestamp as date:
35+
- requires:
36+
cluster_features: [ "mapper.keyword_normalizer_synthetic_source" ]
37+
reason: support for normalizer on keyword fields
38+
39+
- do:
40+
cluster.put_component_template:
41+
name: "logsdb-mappings"
42+
body:
43+
template:
44+
settings:
45+
mode: "logsdb"
46+
mappings:
47+
properties:
48+
host.name:
49+
type: "keyword"
50+
"@timestamp":
51+
type: "date"
52+
53+
- do:
54+
indices.put_index_template:
55+
name: "logsdb-index-template"
56+
body:
57+
index_patterns: ["logsdb"]
58+
data_stream: {}
59+
composed_of: ["logsdb-mappings"]
60+
61+
- do:
62+
indices.create_data_stream:
63+
name: "logsdb"
64+
65+
- is_true: acknowledged
66+
67+
---
68+
create logsdb data stream with host as keyword:
69+
- requires:
70+
cluster_features: [ "mapper.keyword_normalizer_synthetic_source" ]
71+
reason: support for normalizer on keyword fields
72+
73+
- do:
74+
cluster.put_component_template:
75+
name: "logsdb-mappings"
76+
body:
77+
template:
78+
settings:
79+
mode: "logsdb"
80+
mappings:
81+
properties:
82+
host:
83+
type: "keyword"
84+
85+
- do:
86+
indices.put_index_template:
87+
name: "logsdb-index-template"
88+
body:
89+
index_patterns: ["logsdb"]
90+
data_stream: {}
91+
composed_of: ["logsdb-mappings"]
92+
93+
- do:
94+
catch: bad_request
95+
indices.create_data_stream:
96+
name: "logsdb"
97+
98+
- match: { error.type: "mapper_parsing_exception" }
99+
- match: { error.reason: "Failed to parse mapping: can't merge a non object mapping [host] with an object mapping" }
100+
101+
---
102+
create logsdb data stream with host as text and multi fields:
103+
- requires:
104+
cluster_features: [ "mapper.keyword_normalizer_synthetic_source" ]
105+
reason: support for normalizer on keyword fields
106+
107+
- do:
108+
cluster.put_component_template:
109+
name: "logsdb-mappings"
110+
body:
111+
template:
112+
settings:
113+
mode: "logsdb"
114+
mappings:
115+
properties:
116+
host:
117+
type: "text"
118+
fields:
119+
keyword:
120+
ignore_above: 256
121+
type: "keyword"
122+
"@timestamp":
123+
type: "date"
124+
format: "strict_date_optional_time"
125+
126+
- do:
127+
indices.put_index_template:
128+
name: "logsdb-index-template"
129+
body:
130+
index_patterns: ["logsdb"]
131+
data_stream: {}
132+
composed_of: ["logsdb-mappings"]
133+
134+
- do:
135+
catch: bad_request
136+
indices.create_data_stream:
137+
name: "logsdb"
138+
139+
- match: { error.type: "mapper_parsing_exception" }
140+
- match: { error.reason: "Failed to parse mapping: can't merge a non object mapping [host] with an object mapping" }
141+
142+
---
143+
create logsdb data stream with host as text:
144+
- requires:
145+
cluster_features: ["mapper.keyword_normalizer_synthetic_source"]
146+
reason: "Support for normalizer on keyword fields"
147+
148+
- do:
149+
cluster.put_component_template:
150+
name: "logsdb-mappings"
151+
body:
152+
template:
153+
settings:
154+
mode: "logsdb"
155+
mappings:
156+
properties:
157+
host:
158+
type: "text"
159+
"@timestamp":
160+
type: "date"
161+
format: "strict_date_optional_time"
162+
163+
- do:
164+
indices.put_index_template:
165+
name: "logsdb-index-template"
166+
body:
167+
index_patterns: ["logsdb"]
168+
data_stream: {}
169+
composed_of: ["logsdb-mappings"]
170+
171+
- do:
172+
catch: bad_request
173+
indices.create_data_stream:
174+
name: "logsdb"
175+
176+
- match: { error.type: "mapper_parsing_exception" }
177+
- match: { error.reason: "Failed to parse mapping: can't merge a non object mapping [host] with an object mapping" }
178+
179+
---
180+
create logsdb data stream with host as text and name as double:
181+
- requires:
182+
cluster_features: ["mapper.keyword_normalizer_synthetic_source"]
183+
reason: "Support for normalizer on keyword fields"
184+
185+
- do:
186+
cluster.put_component_template:
187+
name: "logsdb-mappings"
188+
body:
189+
template:
190+
settings:
191+
mode: "logsdb"
192+
mappings:
193+
properties:
194+
host:
195+
type: "text"
196+
fields:
197+
name:
198+
type: "double"
199+
"@timestamp":
200+
type: "date"
201+
format: "strict_date_optional_time"
202+
203+
- do:
204+
indices.put_index_template:
205+
name: "logsdb-index-template"
206+
body:
207+
index_patterns: ["logsdb"]
208+
data_stream: {}
209+
composed_of: ["logsdb-mappings"]
210+
211+
- do:
212+
catch: bad_request
213+
indices.create_data_stream:
214+
name: "logsdb"
215+
216+
- match: { error.type: "mapper_parsing_exception" }
217+
- match: { error.reason: "Failed to parse mapping: can't merge a non object mapping [host] with an object mapping" }
218+
219+
---
220+
create logsdb data stream with timestamp object mapping:
221+
- requires:
222+
cluster_features: ["mapper.keyword_normalizer_synthetic_source"]
223+
reason: "Support for normalizer on keyword fields"
224+
225+
- do:
226+
cluster.put_component_template:
227+
name: "logsdb-mappings"
228+
body:
229+
template:
230+
settings:
231+
mode: "logsdb"
232+
mappings:
233+
properties:
234+
host:
235+
properties:
236+
name:
237+
type: "keyword"
238+
"@timestamp":
239+
properties:
240+
date:
241+
type: "date"
242+
format: "strict_date_optional_time"
243+
244+
- do:
245+
catch: bad_request
246+
indices.put_index_template:
247+
name: "logsdb-index-template"
248+
body:
249+
index_patterns: ["logsdb"]
250+
data_stream: {}
251+
composed_of: ["logsdb-mappings"]
252+
253+
- match: { error.type: "illegal_argument_exception" }
254+
- match: { error.reason: "composable template [logsdb-index-template] template after composition with component templates [logsdb-mappings] is invalid" }

0 commit comments

Comments
 (0)