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

[Filebeat][nosetests] Printing error message when test_modules.py returns an error message from ES #20460

Merged
merged 2 commits into from
Aug 6, 2020

Conversation

P1llus
Copy link
Member

@P1llus P1llus commented Aug 6, 2020

What does this PR do?

When working a lot with pipelines and continously run nosetests, if one of the test logs for a module returns an error it only prints the whole JSON. In large documents trying to find the error message over and over again can be tedious.

This PR adds a second line, printing only the error message as well.

Is this something we could add in? Would it break any sort of other tests that might expect a specific amount of lines back?

Why is it important?

Quality of life addition.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
    - [ ] I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Example output with the changes:

FAIL: test_fileset_file_8_zoom (test_xpack_modules.XPackTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/marius/go/src/github.com/P1llus/beats/x-pack/filebeat/venv/lib/python3.8/site-packages/parameterized/parameterized.py", line 531, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/marius/go/src/github.com/P1llus/beats/x-pack/filebeat/tests/system/../../../../filebeat/tests/system/test_modules.py", line 95, in test_fileset_file
    self.run_on_file(
  File "/home/marius/go/src/github.com/P1llus/beats/x-pack/filebeat/tests/system/../../../../filebeat/tests/system/test_modules.py", line 164, in run_on_file
    assert "error" not in obj, "not error expected but got: {}.\n The related error message is: {}".format(
AssertionError: not error expected but got: {'agent': {'name': 'Hades', 'id': '30daf028-e321-4a1c-82e2-8d43a59b5e50', 'type': 'filebeat', 'ephemeral_id': '833dbed7-c419-490c-a222-f2ac88622acc', 'version': '8.0.0'}, 'log': {'file': {'path': '/home/marius/go/src/github.com/P1llus/beats/x-pack/filebeat/module/zoom/webhook/test/meeting.ndjson.log'}, 'offset': 0}, 'zoom': {'meeting': {'duration': 60, 'start_time': '2019-07-16T17:14:39Z', 'timezone': 'America/Los_Angeles', 'topic': 'My Meeting', 'id': '6962400003', 'type': 2, 'uuid': '4118UHIiRCAAAtBlDkcVyw==', 'issues': 'Unstable audio quality', 'host_id': 'z8yCxTTTTSiw02QgCAp8uQ'}}, 'fileset': {'name': 'webhook'}, 'error': {'message': 'Cannot cast java.lang.Integer to java.lang.String'}, 'tags': ['zoom-webhook', 'forwarded'], 'input': {'type': 'log'}, 'observer': {'product': 'Webhook', 'vendor': 'Zoom'}, '@timestamp': '2020-08-05T23:56:03.503Z', 'ecs': {'version': '1.5.0'}, 'related': {'user': ['z8yCxTTTTSiw02QgCAp8uQ']}, 'service': {'type': 'zoom'}, 'event': {'ingested': '2020-08-05T23:56:04.613450Z', 'timezone': '-02:00', 'kind': ['event'], 'module': 'zoom', 'action': 'meeting.alert', 'type': ['error'], 'dataset': 'zoom.webhook'}}.
 The related error message is: Cannot cast java.lang.Integer to java.lang.String

@P1llus P1llus added enhancement Filebeat Filebeat review Team:Integrations Label for the Integrations team Team:SIEM labels Aug 6, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/siem (Team:SIEM)

@P1llus P1llus requested a review from jsoriano August 6, 2020 00:17
@elasticmachine
Copy link
Collaborator

elasticmachine commented Aug 6, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #20460 updated]

  • Start Time: 2020-08-06T10:22:22.810+0000

  • Duration: 53 min 6 sec

Test stats 🧪

Test Results
Failed 0
Passed 3078
Skipped 443
Total 3521

Copy link
Member

@ChrsMark ChrsMark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just one minor suggestion.

@P1llus
Copy link
Member Author

P1llus commented Aug 6, 2020

Should be good now. It is at least something that would make it easier in the short term to handle errors. Would someone be so kind to help me merge/port it if possible @ChrsMark @jsoriano ?

@jsoriano jsoriano merged commit f3fe010 into elastic:master Aug 6, 2020
jsoriano pushed a commit to jsoriano/beats that referenced this pull request Aug 6, 2020
…urns an error message from ES (elastic#20460)

(cherry picked from commit f3fe010)
@P1llus P1llus deleted the filebeat_test_add_errormessage branch August 6, 2020 12:44
jsoriano added a commit that referenced this pull request Aug 6, 2020
…urns an error message from ES (#20460) (#20472)

(cherry picked from commit f3fe010)

Co-authored-by: Marius Iversen <[email protected]>
melchiormoulin pushed a commit to melchiormoulin/beats that referenced this pull request Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants