Filebeat pytest improvements#30103
Conversation
This surfaces which file the test was waiting to see documents from. Otherwise you just get a numeric test failure with no clear idea of which file isn't ingesting as expected.
For example: ``` INTEGRATION_TESTS=1 BEAT_STRICT_PERMS=false TESTING_FILEBEAT_MODULES=elasticsearch TESTING_FILEBEAT_FILESETS=slowlog TESTING_FILEBEAT_FILEPATTERN=es_indexing_slowlog.800.log ES_PASS=changeme pytest tests/system/test_modules.py -v --full-trace ```
By seeing the event, we can more easily identify which log file it's coming from.
|
Pinging @elastic/integrations (Team:Integrations) |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. 🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
|
|
||
| test_files = glob.glob(os.path.join(modules_dir, module, | ||
| fileset, "test", "*.log")) | ||
| fileset, "test", os.getenv("TESTING_FILEBEAT_FILEPATTERN", "*.log"))) |
There was a problem hiding this comment.
Agree
I think we should rethink how and why we introduce variables in the first place. The problem today is there are multiple ways to run tests that support or require different side effects.
I strongly think the test cli should give me all the required information for options without looking in the documentation.
There was a problem hiding this comment.
Definitely agreed.
Not sure if pytest offers something like this directly. mage pythonIntegTest has inline help, but does a lot of extra work (15min for my laptop).
I guess maybe one option would be a lighter mage target with these options covered in the inline help.
In working on the tests I also noticed some similarity with metricbeat testdata integration tests. For example:
If we did these filebeat module tests as regular golang test cases, stuff like TESTING_FILEBEAT_FILEPATTERN would just be go test -run (pattern)
There was a problem hiding this comment.
Having quicker mage task is an option.
I would like to remove all python integration tests and use a single language.
* 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)
What does this PR do?
Provides a few improvements to the filebeat ingest pytests.
Why is it important?
Makes it easier to write and maintain filebeat pytests
Checklist
I have commented my code, particularly in hard-to-understand areasI have made corresponding change to the default configuration filesI have added tests that prove my fix is effective or that my feature worksCHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.How to test this PR locally
Related issues
I ended up writing these as part of #30018 but didn't want to mix them into that PR.