Skip to content

Commit 18a01d2

Browse files
committed
chore: Mark "breaker" as obsolete
1 parent 1eec65a commit 18a01d2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

pytest_splunk_addon/standard_lib/index_tests/test_generator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ def generate_line_breaker_tests(self, tokenized_events):
145145
] = self.get_sourcetype(event)
146146

147147
if not line_breaker_params[event.sample_name].get("expected_event_count"):
148+
LOGGER.warning("'expected_event_count' parameter is missing. "
149+
"Value will be calculated on a best effort basis.")
148150
if event.metadata.get("input_type") not in [
149151
"modinput",
150152
"windows_input",

pytest_splunk_addon/standard_lib/sample_generation/sample_stanza.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,15 @@ def tokenize(self, conf_name):
116116
if self.metadata.get("expected_event_count") is None:
117117
breaker = self.metadata.get("breaker")
118118
if breaker is not None:
119+
raise_warning("'breaker' parameter is obsolete; use 'expected_event_count' parameter instead.")
119120
expected_events = 0
120121
for each_event in bulk_event:
121122
expected_events += len(
122123
list(filter(lambda x: x, self.break_events(each_event.event)))
123124
)
124125
else:
125126
expected_events = len(bulk_event)
127+
raise_warning("'expected_event_count' parameter is missing.")
126128
self.metadata.update(expected_event_count=expected_events)
127129
for each in bulk_event:
128130
each.metadata.update(expected_event_count=expected_events)
@@ -202,7 +204,7 @@ def _parse_meta(self, psa_data_params):
202204
)
203205
metadata.update(timestamp_type="plugin")
204206
if metadata.get("timezone") not in ["local", "0000", None] and not re.match(
205-
TIMEZONE_REX, metadata.get("timezone")
207+
TIMEZONE_REX, metadata.get("timezone")
206208
):
207209
raise_warning(
208210
"Invalid value for timezone: '{}' using timezone = 0000.".format(
@@ -219,8 +221,8 @@ def _parse_meta(self, psa_data_params):
219221
)
220222
metadata.update(timestamp_type="plugin")
221223
if (
222-
metadata.get("sample_count")
223-
and not metadata.get("sample_count").isnumeric()
224+
metadata.get("sample_count")
225+
and not metadata.get("sample_count").isnumeric()
224226
):
225227
raise_warning(
226228
"Invalid value for sample_count: '{}' using sample_count = 1.".format(
@@ -229,8 +231,8 @@ def _parse_meta(self, psa_data_params):
229231
)
230232
metadata.update(sample_count="1")
231233
if (
232-
metadata.get("expected_event_count")
233-
and not metadata.get("expected_event_count").isnumeric()
234+
metadata.get("expected_event_count")
235+
and not metadata.get("expected_event_count").isnumeric()
234236
):
235237
raise_warning(
236238
"Invalid value for expected_event_count: '{}' using expected_event_count = 1.".format(
@@ -310,6 +312,8 @@ def _get_raw_sample(self):
310312
event, event_metadata, self.sample_name, requirement_test_data
311313
)
312314
elif self.metadata.get("breaker"):
315+
raise_warning("'breaker' variable is obsolete. "
316+
"Use of 'breaker' variable is discouraged since event-breaking shall be executed by add-on.")
313317
for each_event in self.break_events(sample_raw):
314318
if each_event:
315319
event_metadata = self.get_eventmetadata()
@@ -356,10 +360,10 @@ def break_events(self, sample_raw):
356360
match_obj = next(sample_match)
357361
event_list = list()
358362
if match_obj.start() != 0:
359-
event_list.append(sample_raw[pos : match_obj.start()].strip())
363+
event_list.append(sample_raw[pos: match_obj.start()].strip())
360364
pos = match_obj.start()
361365
for _, match in enumerate(sample_match):
362-
event_list.append(sample_raw[pos : match.start()].strip())
366+
event_list.append(sample_raw[pos: match.start()].strip())
363367
pos = match.start()
364368
event_list.append(sample_raw[pos:].strip())
365369
return event_list
@@ -413,7 +417,7 @@ def populate_requirement_test_data(event):
413417
missing_recommended_fields = cim.get("missing_recommended_fields") or []
414418
if missing_recommended_fields:
415419
missing_recommended_fields = (
416-
missing_recommended_fields.get("field") or []
420+
missing_recommended_fields.get("field") or []
417421
)
418422
if type(missing_recommended_fields) != list:
419423
missing_recommended_fields = [missing_recommended_fields]

0 commit comments

Comments
 (0)