Skip to content

Commit

Permalink
fix call auto_rule_corpus_tester with config tuple instead of str (#527)
Browse files Browse the repository at this point in the history
Co-authored-by: dtrai2 <[email protected]>
  • Loading branch information
ekneg54 and dtrai2 authored Feb 15, 2024
1 parent 5565a57 commit d153378
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
### Improvements

### Bugfix
* fix loading of configuration inside the `AutoRuleCorpusTester` for `logprep test integration`

## v10.0.2
### Bugfix
* fix versioneer import
* fix logprep does not complain about missing PROMETHEUS_MULTIPROC_DIR
* fix logprep does not complain about missing PROMETHEUS_MULTIPROC_DIR

## v10.0.1
### Bugfix
Expand Down Expand Up @@ -46,7 +47,7 @@
* make store_custom in s3, opensearch and elasticsearch connector not call `batch_finished_callback` to prevent data loss that could be caused by partially processed events
* remove the `schema_and_rule_checker` module
* rewrite Logprep Configuration object see documentation for more details
* rewrite Runner
* rewrite Runner
* delete MultiProcessingPipeline class to simplify multiprocesing
* add FDA to the quickstart setup
* bump versions for `fastapi` and `aiohttp` to address CVEs
Expand Down
8 changes: 4 additions & 4 deletions logprep/util/auto_rule_tester/auto_rule_corpus_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class RuleCorpusTester:
_tmp_dir: str
""" Temporary directory where test files will be saved temporarily """

_original_config_path: str
_original_config_paths: tuple[str]
""" Path to the original configuration that should be tested """

_input_test_data_path: str
Expand All @@ -149,8 +149,8 @@ class TestCase:
report: List = Factory(list)
warnings: str = field(default="")

def __init__(self, config_path, input_test_data_path):
self._original_config_path = config_path
def __init__(self, config_paths: tuple[str], input_test_data_path: str):
self._original_config_paths = config_paths
self._input_test_data_path = input_test_data_path
self.log_capture_string = None

Expand Down Expand Up @@ -193,7 +193,7 @@ def _pipeline(self):
patched_config.input = {
"patched_input": {"type": "json_input", "documents_path": str(merged_input_file_path)}
}
config = Configuration.from_sources([self._original_config_path])
config = Configuration.from_sources(self._original_config_paths)
input_config = config.input
connector_name = list(input_config.keys())[0]
if "preprocessing" in input_config[connector_name]:
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/util/test_auto_rule_corpus_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@pytest.fixture(name="corpus_tester")
def fixture_auto_rule_corpus_tester():
config_path = "tests/testdata/config/config.yml"
config_path = ("tests/testdata/config/config.yml",)
data_dir = "will be overwritten in test cases"
corpus_tester = RuleCorpusTester(config_path, data_dir)
return corpus_tester
Expand Down Expand Up @@ -385,7 +385,7 @@ def test_run_with_two_processors_that_have_different_extra_outputs(
)
test_config_path = tmp_path / "test_config.yml"
test_config_path.write_text(json.dumps(config), encoding="utf8")
corpus_tester = RuleCorpusTester(str(test_config_path), "")
corpus_tester = RuleCorpusTester([str(test_config_path)], "")
test_data = {
"input": {
"message": "A B",
Expand Down Expand Up @@ -450,7 +450,7 @@ def test_corpus_tests_dont_share_cache_between_runs_by_resetting_processors(
# the cache realizes it as an existing pseudonym already.
write_test_case_data_tmp_files(test_data_dir, "test_case_one", test_case_data)
write_test_case_data_tmp_files(test_data_dir, "test_case_two", test_case_data)
config_path = "tests/testdata/config/config.yml"
config_path = ["tests/testdata/config/config.yml"]
corpus_tester = RuleCorpusTester(config_path, test_data_dir)
corpus_tester.run()
console_output, console_error = capsys.readouterr()
Expand Down Expand Up @@ -482,7 +482,7 @@ def test_warnings_are_printed_inside_the_detailed_reports(self, mock_exit, tmp_p
test_data_dir = tmp_path / "test_data"
os.makedirs(test_data_dir, exist_ok=True)
write_test_case_data_tmp_files(test_data_dir, "test_case_one", test_case_data)
config_path = "tests/testdata/config/config.yml"
config_path = ["tests/testdata/config/config.yml"]
corpus_tester = RuleCorpusTester(config_path, test_data_dir)
corpus_tester.run()
console_output, console_error = capsys.readouterr()
Expand Down

0 comments on commit d153378

Please sign in to comment.