Skip to content

Commit e29e0f7

Browse files
fix: terminate tests for improper props conf (#901)
props.conf had invalid syntax using line breakers (issue reported here: https://splunk.atlassian.net/browse/ADDON-72549 ). The incorrect format is causing warnings in the splunkd log, which could be easily prevented by correcting the props conf file like in this [example](https://github.com/splunk/splunk-add-on-for-microsoft-cloud-services/pull/1196/files). Related Jira: https://splunk.atlassian.net/browse/ADDON-77954 Example local run: <img width="1707" alt="image" src="https://github.com/user-attachments/assets/33e5247b-0f93-494c-9685-a48ddfb43a67" />
1 parent 68f5330 commit e29e0f7

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

pytest_splunk_addon/addon_parser/transforms_parser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import re
2424
import os
2525
import csv
26+
import sys
2627

2728
import addonfactory_splunk_conf_parser_lib as conf_parser
2829

@@ -114,6 +115,9 @@ def get_transform_fields(self, transforms_stanza: str) -> Optional[Generator]:
114115
LOGGER.error(
115116
f"The stanza {transforms_stanza} does not exists in transforms.conf."
116117
)
118+
sys.exit(
119+
f"The stanza {transforms_stanza} does not exists in transforms.conf."
120+
)
117121

118122
def get_lookup_csv_fields(self, lookup_stanza: str) -> Optional[Generator]:
119123
"""

tests/e2e/addons/TA_broken/default/props.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ LOOKUP-PASS_test_lookup_not_found = broken-NaN_lookup FAIL_component FAIL_broken
5858
REPORT-broken-FAIL_tsc-delim-fields = broken-tsc-delim-fields
5959
REPORT-broken-PASS_tsc-sk-regex-format = broken-tsc-sk-regex-format
6060
REPORT-broken-FAIL_tsc-sk-delim-format = broken-contact_mode_extract
61-
# If a non_existing stanza is present then no testcases are generated for it.
62-
REPORT-broken-FAIL_tsc-regex-format = broken-tsc-regex-format, broken-non_existing_transforms_stanza
61+
REPORT-broken-FAIL_tsc-regex-format = broken-tsc-regex-format
6362

6463
# Component tested: FIELDALIAS
6564
# Scenario: Plugin searches for the original field and one or more alias field names.

tests/unit/tests_standard_lib/test_addon_parser/test_transforms_parser.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ def test_no_transforms_config_file():
6161
assert transforms_parser.transforms is None
6262

6363

64-
def test_stanza_does_not_exist_in_transforms(caplog):
64+
def test_stanza_does_not_exist_in_transforms():
6565
transforms_conf_path = os.path.join(os.path.dirname(__file__), "testdata")
6666
transforms_parser = TransformsParser(transforms_conf_path)
67-
for result in transforms_parser.get_transform_fields("dummy_stanza"):
68-
assert result is None
69-
assert (
70-
"The stanza dummy_stanza does not exists in transforms.conf." in caplog.messages
67+
with pytest.raises(SystemExit) as excinfo:
68+
for result in transforms_parser.get_transform_fields("dummy_stanza"):
69+
assert result is None
70+
assert "The stanza dummy_stanza does not exists in transforms.conf." == str(
71+
excinfo.value
7172
)
7273

7374

0 commit comments

Comments
 (0)