Skip to content

Commit

Permalink
Fixed an issue where the **modeling-rules test** command failed repor…
Browse files Browse the repository at this point in the history
…t and error when test data didn't exist.
  • Loading branch information
kobymeir committed Oct 31, 2023
1 parent ccab7d1 commit aed1c04
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog
## Unreleased
* Fixed an issue where **validate** falsely failed with error `PB101` and `PB123` due to condition names discrepancy
* Fixed an issue where the **modeling-rules test** command failed report and error when test data didn't exist.
* Updated the **prepare-content** to add contributor details to the `detaileddescription` field based on **supportlevelheader** key.
* Added a new validation (`IN162`) to ensure that each event collector under partner supported packs have the *xsoar* value for the **supportlevelheader** key in its yml.
* A rewrite for the **download** command, with many improvements and fixes, including:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ def validate_modeling_rule(
)
if delete_existing_dataset:
delete_existing_dataset_flow(xsiam_client, test_data, retrying_caller)
schema_test_case = TestCase(
test_data_test_case = TestCase(
"Validate Schema",
classname=f"Modeling Rule {get_relative_path_to_content(modeling_rule.schema_path)}",
)
Expand All @@ -1062,14 +1062,14 @@ def validate_modeling_rule(
f"[red]{err}[/red]",
extra={"markup": True},
)
schema_test_case.system_err = str(ex)
test_data_test_case.system_err = str(ex)
return add_result_to_test_case(
err, schema_test_case, modeling_rule_test_suite
err, test_data_test_case, modeling_rule_test_suite
)
else:
err = f"Schema file does not exist in path {get_relative_path_to_content(modeling_rule.schema_path)}"
return log_error_to_test_case(
err, schema_test_case, modeling_rule_test_suite
err, test_data_test_case, modeling_rule_test_suite
)
if (
Validations.SCHEMA_TYPES_ALIGNED_WITH_TEST_DATA.value
Expand All @@ -1084,23 +1084,23 @@ def validate_modeling_rule(
success, results = validate_schema_aligned_with_test_data(
test_data=test_data, schema=schema
)
schema_test_case.result += results
test_data_test_case.result += results
if not success:
err = (
f"The schema {get_relative_path_to_content(schema_path)} is not aligned with the test data file "
f"{get_relative_path_to_content(modeling_rule.testdata_path)}"
)
return log_error_to_test_case(
err, schema_test_case, modeling_rule_test_suite
err, test_data_test_case, modeling_rule_test_suite
)
else:
skipped = (
f"Skipping the validation to check that the schema {get_relative_path_to_content(schema_path)} "
"is aligned with TestData file."
)
logger.info(f"[green]{skipped}[/green]", extra={"markup": True})
schema_test_case.result += [Skipped(skipped)]
modeling_rule_test_suite.add_testcase(schema_test_case)
test_data_test_case.result += [Skipped(skipped)]
modeling_rule_test_suite.add_testcase(test_data_test_case)

if push:
event_id_exists_test_case = verify_event_id_does_not_exist_on_tenant(
Expand Down Expand Up @@ -1225,11 +1225,21 @@ def validate_modeling_rule(
extra={"markup": True},
)
else:
err = (
f"Please create a test data file for {get_relative_path_to_content(modeling_rule_directory)} "
f"and then rerun\n{executed_command}"
)
logger.error(
f"[red]Please create a test data file for "
f"{get_relative_path_to_content(modeling_rule_directory)} and then rerun\n{executed_command}[/red]",
f"[red]{err}[/red]",
extra={"markup": True},
)
test_data_test_case = TestCase(
"Test data file does not exist",
classname=f"Modeling Rule {get_relative_path_to_content(modeling_rule.schema_path)}",
)
test_data_test_case.result += [Error(err)]
modeling_rule_test_suite.add_testcase(test_data_test_case)
return False, modeling_rule_test_suite
return False, None


Expand Down

0 comments on commit aed1c04

Please sign in to comment.