Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the assertion for fileset modules #16493

Merged
merged 1 commit into from
Feb 24, 2020
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
22 changes: 10 additions & 12 deletions filebeat/tests/system/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import json
import logging
from parameterized import parameterized
from deepdiff import DeepDiff


def load_fileset_test_cases():
Expand Down Expand Up @@ -197,21 +198,18 @@ def _test_expected_events(self, test_file, objects):
assert len(expected) == len(objects), "expected {} events to compare but got {}".format(
len(expected), len(objects))

for ev in expected:
clean_keys(ev)
found = False
for obj in objects:
for idx in range(len(expected)):
ev = expected[idx]
obj = objects[idx]

# Flatten objects for easier comparing
obj = self.flatten_object(obj, {}, "")
clean_keys(obj)
# Flatten objects for easier comparing
obj = self.flatten_object(obj, {}, "")
clean_keys(obj)
clean_keys(ev)

if ev == obj:
found = True
break
d = DeepDiff(ev, obj, ignore_order=True)

assert found, "The following expected object was not found:\n {}\nSearched in: \n{}".format(
pretty_json(ev), pretty_json(objects))
assert len(d) == 0, "The following expected object doesn't match:\n Diff:\n{}, full object: \n{}".format(d, obj)


def clean_keys(obj):
Expand Down
1 change: 1 addition & 0 deletions libbeat/tests/system/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ parameterized==0.7.0
jsondiff==1.1.2
semver==2.8.1
stomp.py==4.1.22
deepdiff==4.2.0