jertel / elastalert2

ElastAlert 2 is a continuation of the original yelp/elastalert project. Pull requests are appreciated!
https://elastalert2.readthedocs.org
Apache License 2.0
902 stars 284 forks source link

Remove hardcoded file loader from test_rule.py #1100

Closed akusei closed 1 year ago

akusei commented 1 year ago

Description

This PR is to remove the hardcoded file rule loader when testing with either elastalert-test-rule or using elastalert.test_rule. Currently the test will only use a file loader regardless of what you have configured for the rules_loader setting. This prevents proper testing when a custom rule loader is required for a valid rule to be loaded.

Based on the original commit message, the changes done in that commit don't line up with the message.

Added ability for test rule to override loader to use file loader

When it actually just hardcodes it to 'file'.

I also renamed the overwrites parameter in config.py for the load_conf method to overrides. If this isn't desired, I don't mind dropping this change, it was just a bit of odd wording. The overwrites parameter is not being used by the existing code-base so nothing else here needs to change. This will be a breaking change for anyone who is calling load_conf and providing the overwrites as a named parameter. It will need to be renamed to overrides. I'm okay if this change is denied.

I had to modify the Makefile to account for the newer docker compose command while maintaining existing functionality with the older docker-compose command.

In removing the hardcoded value I noticed there were no unit tests for loading configurations with defaults and overrides so I added them. The tests initially failed as the original for loop on overrides used iteritems() rather than the iter() method like the defaults for loop.

Checklist

Questions or Comments