Skip to content

Commit

Permalink
Filebeat pytest improvements (elastic#30103) (elastic#30121)
Browse files Browse the repository at this point in the history
* Include the test_file as wait_until name
* Support TESTING_FILEBEAT_FILEPATTERN to test a single ingest file
* Include full event on "not documented" case

(cherry picked from commit 3ddf236)

Co-authored-by: Mat Schaffer <[email protected]>
  • Loading branch information
mergify[bot] and matschaffer authored Feb 1, 2022
1 parent a9b1f45 commit 7036c9e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
- Introduce `libbeat/beat.Beat.OutputConfigReloader` {pull}28048[28048]
- Update Go version to 1.17.1. {pull}27543[27543]
- Whitelist `GCP_*` environment variables in dev tools {pull}28364[28364]
- Add support for `credentials_json` in `gcp` module, all metricsets {pull}29584[29584]
- Add gcp firestore metricset. {pull}29918[29918]
- Added TESTING_FILEBEAT_FILEPATTERN option for filebeat module pytests {pull}30103[30103]

==== Deprecated

Expand Down
5 changes: 3 additions & 2 deletions filebeat/tests/system/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def load_fileset_test_cases():
continue

test_files = glob.glob(os.path.join(modules_dir, module,
fileset, "test", "*.log"))
fileset, "test", os.getenv("TESTING_FILEBEAT_FILEPATTERN", "*.log")))
for test_file in test_files:
test_cases.append([module, fileset, test_file])

Expand Down Expand Up @@ -216,7 +216,8 @@ def run_on_file(self, module, fileset, test_file, cfgfile):
error_line)

# Make sure index exists
self.wait_until(lambda: self.es.indices.exists(self.index_name))
self.wait_until(lambda: self.es.indices.exists(self.index_name),
name="indices present for {}".format(test_file))

self.es.indices.refresh(index=self.index_name)
# Loads the first 100 events to be checked
Expand Down
2 changes: 1 addition & 1 deletion libbeat/tests/system/beat/beat.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def is_documented(key, docs):
# Range keys as used in 'date_range' etc will not have docs of course
isRangeKey = key.split('.')[-1] in ['gte', 'gt', 'lte', 'lt']
if not(is_documented(key, expected_fields) or metaKey or isRangeKey):
raise Exception("Key '{}' found in event is not documented!".format(key))
raise Exception("Key '{}' found in event ({}) is not documented!".format(key, str(evt)))
if is_documented(key, aliases):
raise Exception("Key '{}' found in event is documented as an alias!".format(key))

Expand Down

0 comments on commit 7036c9e

Please sign in to comment.