Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions spec/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
- description: Input packages don't require to define fields.
type: enhancement
link: https://github.com/elastic/package-spec/pull/994
- description: Add support for script testing in data streams.
type: enhancement
link: https://github.com/elastic/package-spec/pull/985
- version: 3.5.0
changes:
- description: Add `duration` variable data type with `min_duration` and `max_duration` validation properties.
Expand Down
12 changes: 12 additions & 0 deletions spec/integration/data_stream/_dev/test/scripts/spec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
spec:
additionalContents: false
contents:
- description: >-
Script test definitions in txtar format, with semantics based on the
testscript package, but with extensions to make it possible to interact
with an Elastic stack. You can read more about the use of txtar and
testscript at https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript.
type: file
contentMediaType: "text/plain"
pattern: '^.+\.(txt|txtar)$'
required: false
5 changes: 5 additions & 0 deletions spec/integration/data_stream/_dev/test/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ spec:
name: policy
required: false
$ref: "./policy/spec.yml"
- description: Folder containing script tests
type: folder
name: scripts
required: false
$ref: "./scripts/spec.yml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[!exec:echo] skip 'Skipping test requiring absent echo command'

exec echo ${PKG}
stdout '^with_script$'

exec echo ${PKG_ROOT}
stdout 'github\.com/elastic/elastic-package/test/packages/other/with_script$'

exec echo ${DATA_STREAM}
stdout '^first$'

exec echo ${DATA_STREAM_ROOT}
stdout 'github\.com/elastic/elastic-package/test/packages/other/with_script/data_stream/first$'

exec echo ${CURRENT_VERSION}
stdout '^0\.0\.2$'

exec echo ${PREVIOUS_VERSION}
stdout '^0\.0\.1$'

exec echo ${FIELDS_QUERY}
cmp stdout want_query.text

-- want_query.text --
{
"fields": [
"*"
],
"runtime_mappings": {
"my_ignored": {
"type": "keyword",
"script": {
"source": "for (def v : params['_fields']._ignored.values) { emit(v); }"
}
}
},
"aggs": {
"all_ignored": {
"filter": {
"exists": {
"field": "_ignored"
}
},
"aggs": {
"ignored_fields": {
"terms": {
"size": 100,
"field": "my_ignored"
}
},
"ignored_docs": {
"top_hits": {
"size": 5
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is a noop test.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is a noop test.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- name: data_stream.type
type: constant_keyword
description: Data stream type.
- name: data_stream.dataset
type: constant_keyword
description: Data stream dataset.
- name: data_stream.namespace
type: constant_keyword
description: Data stream namespace.
- name: '@timestamp'
type: date
description: Event timestamp.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
- name: source
title: Source
group: 2
type: group
fields:
- name: geo.city_name
level: core
type: keyword
description: City name.
ignore_above: 1024
- name: geo.location
level: core
type: geo_point
description: Longitude and latitude.
- name: geo.region_iso_code
level: core
type: keyword
description: Region ISO code.
ignore_above: 1024
- name: geo.region_name
level: core
type: keyword
description: Region name.
ignore_above: 1024
- name: foobar
type: text
description: A field with a pattern defined
pattern: '^[a-zA-Z]$'
2 changes: 2 additions & 0 deletions test/packages/good_v3/data_stream/script_tests/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: Package with script tests
type: metrics