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

chore: Mark "breaker" as obsolete #715

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ def generate_line_breaker_tests(self, tokenized_events):
] = self.get_sourcetype(event)

if not line_breaker_params[event.sample_name].get("expected_event_count"):
LOGGER.warning("'expected_event_count' parameter is missing. "
"Value will be calculated on a best effort basis.")
if event.metadata.get("input_type") not in [
"modinput",
"windows_input",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ def tokenize(self, conf_name):
if self.metadata.get("expected_event_count") is None:
breaker = self.metadata.get("breaker")
if breaker is not None:
raise_warning("'breaker' parameter is obsolete; use 'expected_event_count' parameter instead.")
expected_events = 0
for each_event in bulk_event:
expected_events += len(
list(filter(lambda x: x, self.break_events(each_event.event)))
)
else:
expected_events = len(bulk_event)
raise_warning("'expected_event_count' parameter is missing.")
self.metadata.update(expected_event_count=expected_events)
for each in bulk_event:
each.metadata.update(expected_event_count=expected_events)
Expand Down Expand Up @@ -202,7 +204,7 @@ def _parse_meta(self, psa_data_params):
)
metadata.update(timestamp_type="plugin")
if metadata.get("timezone") not in ["local", "0000", None] and not re.match(
TIMEZONE_REX, metadata.get("timezone")
TIMEZONE_REX, metadata.get("timezone")
):
raise_warning(
"Invalid value for timezone: '{}' using timezone = 0000.".format(
Expand All @@ -219,8 +221,8 @@ def _parse_meta(self, psa_data_params):
)
metadata.update(timestamp_type="plugin")
if (
metadata.get("sample_count")
and not metadata.get("sample_count").isnumeric()
metadata.get("sample_count")
and not metadata.get("sample_count").isnumeric()
):
raise_warning(
"Invalid value for sample_count: '{}' using sample_count = 1.".format(
Expand All @@ -229,8 +231,8 @@ def _parse_meta(self, psa_data_params):
)
metadata.update(sample_count="1")
if (
metadata.get("expected_event_count")
and not metadata.get("expected_event_count").isnumeric()
metadata.get("expected_event_count")
and not metadata.get("expected_event_count").isnumeric()
):
raise_warning(
"Invalid value for expected_event_count: '{}' using expected_event_count = 1.".format(
Expand Down Expand Up @@ -310,6 +312,8 @@ def _get_raw_sample(self):
event, event_metadata, self.sample_name, requirement_test_data
)
elif self.metadata.get("breaker"):
raise_warning("'breaker' variable is obsolete. "
"Use of 'breaker' variable is discouraged since event-breaking shall be executed by add-on.")
for each_event in self.break_events(sample_raw):
if each_event:
event_metadata = self.get_eventmetadata()
Expand Down Expand Up @@ -356,10 +360,10 @@ def break_events(self, sample_raw):
match_obj = next(sample_match)
event_list = list()
if match_obj.start() != 0:
event_list.append(sample_raw[pos : match_obj.start()].strip())
event_list.append(sample_raw[pos: match_obj.start()].strip())
pos = match_obj.start()
for _, match in enumerate(sample_match):
event_list.append(sample_raw[pos : match.start()].strip())
event_list.append(sample_raw[pos: match.start()].strip())
pos = match.start()
event_list.append(sample_raw[pos:].strip())
return event_list
Expand Down Expand Up @@ -413,7 +417,7 @@ def populate_requirement_test_data(event):
missing_recommended_fields = cim.get("missing_recommended_fields") or []
if missing_recommended_fields:
missing_recommended_fields = (
missing_recommended_fields.get("field") or []
missing_recommended_fields.get("field") or []
)
if type(missing_recommended_fields) != list:
missing_recommended_fields = [missing_recommended_fields]
Expand Down