Skip to content

Commit

Permalink
chore: Mark "breaker" as obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
wmazur-splunk committed Oct 28, 2022
1 parent 1eec65a commit 18a01d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
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

0 comments on commit 18a01d2

Please sign in to comment.