-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add yaml test for transforms with synthetic mode (#112054)
This provides coverage for transforms over logs, when we enable logsdb by default.
- Loading branch information
Showing
1 changed file
with
103 additions
and
0 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
...mlRestTest/resources/rest-api-spec/test/transform/preview_transforms_synthetic_source.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
simple: | ||
- skip: | ||
features: headers | ||
|
||
- do: | ||
indices.create: | ||
index: airline-data | ||
body: | ||
mappings: | ||
_source: | ||
mode: synthetic | ||
properties: | ||
time: | ||
type: date | ||
airline: | ||
type: keyword | ||
responsetime: | ||
type: float | ||
event_rate: | ||
type: integer | ||
|
||
- do: | ||
index: | ||
index: airline-data | ||
id: "1" | ||
body: '{ "time": "2017-02-18T00:00:00Z", "airline": "airline1", "responsetime": 1.0, "event_rate": 5 }' | ||
|
||
- do: | ||
index: | ||
index: airline-data | ||
id: "2" | ||
body: '{ "time": "2017-02-18T00:30:00Z", "airline": "airline1", "responsetime": 2.0, "event_rate": 6 }' | ||
|
||
- do: | ||
index: | ||
index: airline-data | ||
id: "3" | ||
body: '{ "time": "2017-02-18T01:00:00Z", "airline": "airline2", "responsetime": 11.0, "event_rate": 8 }' | ||
|
||
- do: | ||
index: | ||
index: airline-data | ||
id: "4" | ||
body: '{ "time": "2017-02-18T01:01:00Z", "airline": "airline1", "responsetime": 22.0, "event_rate": 7 }' | ||
|
||
- do: | ||
indices.refresh: | ||
index: airline-data | ||
|
||
- do: | ||
transform.preview_transform: | ||
body: > | ||
{ | ||
"source": { "index": "airline-data" }, | ||
"pivot": { | ||
"group_by": { | ||
"airline": {"terms": {"field": "airline"}}, | ||
"by-hour": {"date_histogram": {"fixed_interval": "1h", "field": "time"}}}, | ||
"aggs": { | ||
"avg_response": {"avg": {"field": "responsetime"}}, | ||
"time.max": {"max": {"field": "time"}}, | ||
"time.min": {"min": {"field": "time"}} | ||
} | ||
} | ||
} | ||
- match: { preview.0.airline: airline1 } | ||
- match: { preview.0.by-hour: "2017-02-18T00:00:00.000Z" } | ||
- match: { preview.0.avg_response: 1.5 } | ||
- match: { preview.0.time.max: "2017-02-18T00:30:00.000Z" } | ||
- match: { preview.0.time.min: "2017-02-18T00:00:00.000Z" } | ||
- match: { preview.1.airline: airline1 } | ||
- match: { preview.1.by-hour: "2017-02-18T01:00:00.000Z" } | ||
- match: { preview.1.avg_response: 22.0 } | ||
- match: { preview.1.time.max: "2017-02-18T01:01:00.000Z" } | ||
- match: { preview.1.time.min: "2017-02-18T01:01:00.000Z" } | ||
- match: { preview.2.airline: airline2 } | ||
- match: { preview.2.by-hour: "2017-02-18T01:00:00.000Z" } | ||
- match: { preview.2.avg_response: 11.0 } | ||
- match: { preview.2.time.max: "2017-02-18T01:00:00.000Z" } | ||
- match: { preview.2.time.min: "2017-02-18T01:00:00.000Z" } | ||
- match: { generated_dest_index.mappings.properties.airline.type: "keyword" } | ||
- match: { generated_dest_index.mappings.properties.by-hour.type: "date" } | ||
- match: { generated_dest_index.mappings.properties.avg_response.type: "double" } | ||
- match: { generated_dest_index.mappings.properties.time\.max.type: "date" } | ||
- match: { generated_dest_index.mappings.properties.time\.min.type: "date" } | ||
|
||
- do: | ||
transform.preview_transform: | ||
body: > | ||
{ | ||
"source": { "index": "airline-data" }, | ||
"latest": { | ||
"unique_key": ["airline"], | ||
"sort": "time" | ||
} | ||
} | ||
- length: { $body: 2 } | ||
- match: { preview.0.airline: airline1 } | ||
- match: { preview.0.time: "2017-02-18T01:01:00.000Z" } | ||
- match: { preview.0.responsetime: 22.0 } | ||
- match: { preview.1.airline: airline2 } | ||
- match: { preview.1.time: "2017-02-18T01:00:00.000Z" } | ||
- match: { preview.1.responsetime: 11.0 } |