Skip to content

Commit 21ccde5

Browse files
authored
Add yaml test for transforms with synthetic mode (elastic#112054)
This provides coverage for transforms over logs, when we enable logsdb by default.
1 parent 649acc4 commit 21ccde5

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
simple:
2+
- skip:
3+
features: headers
4+
5+
- do:
6+
indices.create:
7+
index: airline-data
8+
body:
9+
mappings:
10+
_source:
11+
mode: synthetic
12+
properties:
13+
time:
14+
type: date
15+
airline:
16+
type: keyword
17+
responsetime:
18+
type: float
19+
event_rate:
20+
type: integer
21+
22+
- do:
23+
index:
24+
index: airline-data
25+
id: "1"
26+
body: '{ "time": "2017-02-18T00:00:00Z", "airline": "airline1", "responsetime": 1.0, "event_rate": 5 }'
27+
28+
- do:
29+
index:
30+
index: airline-data
31+
id: "2"
32+
body: '{ "time": "2017-02-18T00:30:00Z", "airline": "airline1", "responsetime": 2.0, "event_rate": 6 }'
33+
34+
- do:
35+
index:
36+
index: airline-data
37+
id: "3"
38+
body: '{ "time": "2017-02-18T01:00:00Z", "airline": "airline2", "responsetime": 11.0, "event_rate": 8 }'
39+
40+
- do:
41+
index:
42+
index: airline-data
43+
id: "4"
44+
body: '{ "time": "2017-02-18T01:01:00Z", "airline": "airline1", "responsetime": 22.0, "event_rate": 7 }'
45+
46+
- do:
47+
indices.refresh:
48+
index: airline-data
49+
50+
- do:
51+
transform.preview_transform:
52+
body: >
53+
{
54+
"source": { "index": "airline-data" },
55+
"pivot": {
56+
"group_by": {
57+
"airline": {"terms": {"field": "airline"}},
58+
"by-hour": {"date_histogram": {"fixed_interval": "1h", "field": "time"}}},
59+
"aggs": {
60+
"avg_response": {"avg": {"field": "responsetime"}},
61+
"time.max": {"max": {"field": "time"}},
62+
"time.min": {"min": {"field": "time"}}
63+
}
64+
}
65+
}
66+
- match: { preview.0.airline: airline1 }
67+
- match: { preview.0.by-hour: "2017-02-18T00:00:00.000Z" }
68+
- match: { preview.0.avg_response: 1.5 }
69+
- match: { preview.0.time.max: "2017-02-18T00:30:00.000Z" }
70+
- match: { preview.0.time.min: "2017-02-18T00:00:00.000Z" }
71+
- match: { preview.1.airline: airline1 }
72+
- match: { preview.1.by-hour: "2017-02-18T01:00:00.000Z" }
73+
- match: { preview.1.avg_response: 22.0 }
74+
- match: { preview.1.time.max: "2017-02-18T01:01:00.000Z" }
75+
- match: { preview.1.time.min: "2017-02-18T01:01:00.000Z" }
76+
- match: { preview.2.airline: airline2 }
77+
- match: { preview.2.by-hour: "2017-02-18T01:00:00.000Z" }
78+
- match: { preview.2.avg_response: 11.0 }
79+
- match: { preview.2.time.max: "2017-02-18T01:00:00.000Z" }
80+
- match: { preview.2.time.min: "2017-02-18T01:00:00.000Z" }
81+
- match: { generated_dest_index.mappings.properties.airline.type: "keyword" }
82+
- match: { generated_dest_index.mappings.properties.by-hour.type: "date" }
83+
- match: { generated_dest_index.mappings.properties.avg_response.type: "double" }
84+
- match: { generated_dest_index.mappings.properties.time\.max.type: "date" }
85+
- match: { generated_dest_index.mappings.properties.time\.min.type: "date" }
86+
87+
- do:
88+
transform.preview_transform:
89+
body: >
90+
{
91+
"source": { "index": "airline-data" },
92+
"latest": {
93+
"unique_key": ["airline"],
94+
"sort": "time"
95+
}
96+
}
97+
- length: { $body: 2 }
98+
- match: { preview.0.airline: airline1 }
99+
- match: { preview.0.time: "2017-02-18T01:01:00.000Z" }
100+
- match: { preview.0.responsetime: 22.0 }
101+
- match: { preview.1.airline: airline2 }
102+
- match: { preview.1.time: "2017-02-18T01:00:00.000Z" }
103+
- match: { preview.1.responsetime: 11.0 }

0 commit comments

Comments
 (0)