From 48db5e82815aca1c481ce4bbc55b5d3007d35c56 Mon Sep 17 00:00:00 2001 From: Harshil Gajera Date: Thu, 11 Jul 2024 15:19:46 +0530 Subject: [PATCH 1/8] updating test --- pytest_splunk_addon/cim_tests/test_generator.py | 4 +++- tests/e2e/addons/TA_req_broken/samples/sample_modinput.xml | 1 + tests/e2e/test_splunk_addon.py | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pytest_splunk_addon/cim_tests/test_generator.py b/pytest_splunk_addon/cim_tests/test_generator.py index b61cbf398..d2f15d0fa 100644 --- a/pytest_splunk_addon/cim_tests/test_generator.py +++ b/pytest_splunk_addon/cim_tests/test_generator.py @@ -270,7 +270,9 @@ def generate_recommended_fields_tests(self): model = model.replace(" ", "_") if datasets: datasets = [dataset.replace(" ", "_") for dataset in datasets] - + common_fields= list(set(event.requirement_test_data["cim_fields"].keys()) & set(event.requirement_test_data["missing_recommended_fields"])) + if common_fields: + LOGGER.warning(f"List of common fields found in both cim_fields and missing_recommended_fields = {common_fields}") fields = ( list(event.requirement_test_data["cim_fields"].keys()) + event.requirement_test_data["missing_recommended_fields"] diff --git a/tests/e2e/addons/TA_req_broken/samples/sample_modinput.xml b/tests/e2e/addons/TA_req_broken/samples/sample_modinput.xml index ccd341d48..0698d76fe 100644 --- a/tests/e2e/addons/TA_req_broken/samples/sample_modinput.xml +++ b/tests/e2e/addons/TA_req_broken/samples/sample_modinput.xml @@ -25,6 +25,7 @@ src_user + dest diff --git a/tests/e2e/test_splunk_addon.py b/tests/e2e/test_splunk_addon.py index a95820419..f000cdaed 100644 --- a/tests/e2e/test_splunk_addon.py +++ b/tests/e2e/test_splunk_addon.py @@ -644,6 +644,8 @@ def empty_method(): failed=len(constants.TA_REQ_BROKEN_FAILED), skipped=len(constants.TA_REQ_BROKEN_SKIPPED), ) + assert "List of common fields found in both cim_fields and missing_recommended_fields = ['dest']" in result.outlines + # make sure that we get a non '0' exit code for the testsuite as it contains failure assert result.ret != 0 From 63cbac358514feace00a23e9697866e77532e3d9 Mon Sep 17 00:00:00 2001 From: Harshil Gajera Date: Thu, 11 Jul 2024 15:35:27 +0530 Subject: [PATCH 2/8] ci: lint changes --- pytest_splunk_addon/cim_tests/test_generator.py | 9 +++++++-- tests/e2e/test_splunk_addon.py | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pytest_splunk_addon/cim_tests/test_generator.py b/pytest_splunk_addon/cim_tests/test_generator.py index d2f15d0fa..804caf5c2 100644 --- a/pytest_splunk_addon/cim_tests/test_generator.py +++ b/pytest_splunk_addon/cim_tests/test_generator.py @@ -270,9 +270,14 @@ def generate_recommended_fields_tests(self): model = model.replace(" ", "_") if datasets: datasets = [dataset.replace(" ", "_") for dataset in datasets] - common_fields= list(set(event.requirement_test_data["cim_fields"].keys()) & set(event.requirement_test_data["missing_recommended_fields"])) + common_fields = list( + set(event.requirement_test_data["cim_fields"].keys()) + & set(event.requirement_test_data["missing_recommended_fields"]) + ) if common_fields: - LOGGER.warning(f"List of common fields found in both cim_fields and missing_recommended_fields = {common_fields}") + LOGGER.warning( + f"List of common fields found in both cim_fields and missing_recommended_fields = {common_fields}" + ) fields = ( list(event.requirement_test_data["cim_fields"].keys()) + event.requirement_test_data["missing_recommended_fields"] diff --git a/tests/e2e/test_splunk_addon.py b/tests/e2e/test_splunk_addon.py index f000cdaed..903f88509 100644 --- a/tests/e2e/test_splunk_addon.py +++ b/tests/e2e/test_splunk_addon.py @@ -644,8 +644,10 @@ def empty_method(): failed=len(constants.TA_REQ_BROKEN_FAILED), skipped=len(constants.TA_REQ_BROKEN_SKIPPED), ) - assert "List of common fields found in both cim_fields and missing_recommended_fields = ['dest']" in result.outlines - + assert ( + "List of common fields found in both cim_fields and missing_recommended_fields = ['dest']" + in result.outlines + ) # make sure that we get a non '0' exit code for the testsuite as it contains failure assert result.ret != 0 From e22193e6599ec80cd64cd7a7d9cc00679a56d02d Mon Sep 17 00:00:00 2001 From: Harshil Gajera Date: Thu, 11 Jul 2024 15:50:43 +0530 Subject: [PATCH 3/8] ci: updating constants --- tests/e2e/constants.py | 3 +++ tests/e2e/test_splunk_addon.py | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/e2e/constants.py b/tests/e2e/constants.py index 0fd69aebd..394de1ce3 100644 --- a/tests/e2e/constants.py +++ b/tests/e2e/constants.py @@ -903,6 +903,9 @@ "*test_splunk_app_req_broken.py::Test_App::test_eventtype[eventtype::test_auth* PASSED*", ] +TA_REQ_BROKEN_WARNING = [ + '*List of common fields found in both cim_fields and missing_recommended_fields = ['dest']*' + ] """ Define the TA_broken add-on failed test case list. """ diff --git a/tests/e2e/test_splunk_addon.py b/tests/e2e/test_splunk_addon.py index 903f88509..45dd4f4ec 100644 --- a/tests/e2e/test_splunk_addon.py +++ b/tests/e2e/test_splunk_addon.py @@ -635,6 +635,7 @@ def empty_method(): logger.info(result.outlines) result.stdout.fnmatch_lines_random( + constants.TA_REQ_BROKEN_WARNING constants.TA_REQ_BROKEN_PASSED + constants.TA_REQ_BROKEN_FAILED + constants.TA_REQ_BROKEN_SKIPPED @@ -644,10 +645,10 @@ def empty_method(): failed=len(constants.TA_REQ_BROKEN_FAILED), skipped=len(constants.TA_REQ_BROKEN_SKIPPED), ) - assert ( - "List of common fields found in both cim_fields and missing_recommended_fields = ['dest']" - in result.outlines - ) + # assert ( + # "List of common fields found in both cim_fields and missing_recommended_fields = ['dest']" + # in result.outlines + # ) # make sure that we get a non '0' exit code for the testsuite as it contains failure assert result.ret != 0 From 9a1cbd8cc37ac7a64d8e0dc94dcd7235008c4e57 Mon Sep 17 00:00:00 2001 From: Harshil Gajera Date: Thu, 11 Jul 2024 15:59:39 +0530 Subject: [PATCH 4/8] ci: updating constants --- tests/e2e/test_splunk_addon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/test_splunk_addon.py b/tests/e2e/test_splunk_addon.py index 45dd4f4ec..a444b968e 100644 --- a/tests/e2e/test_splunk_addon.py +++ b/tests/e2e/test_splunk_addon.py @@ -635,7 +635,7 @@ def empty_method(): logger.info(result.outlines) result.stdout.fnmatch_lines_random( - constants.TA_REQ_BROKEN_WARNING + constants.TA_REQ_BROKEN_WARNING, constants.TA_REQ_BROKEN_PASSED + constants.TA_REQ_BROKEN_FAILED + constants.TA_REQ_BROKEN_SKIPPED From dc18ac4247c7338f0fdbfc96018266ae02358fa7 Mon Sep 17 00:00:00 2001 From: Harshil Gajera Date: Thu, 11 Jul 2024 16:09:05 +0530 Subject: [PATCH 5/8] ci: updating constants --- tests/e2e/constants.py | 4 ++-- tests/e2e/test_splunk_addon.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/e2e/constants.py b/tests/e2e/constants.py index 394de1ce3..346a44cae 100644 --- a/tests/e2e/constants.py +++ b/tests/e2e/constants.py @@ -904,8 +904,8 @@ ] TA_REQ_BROKEN_WARNING = [ - '*List of common fields found in both cim_fields and missing_recommended_fields = ['dest']*' - ] + "*List of common fields found in both cim_fields and missing_recommended_fields = ['dest']*" +] """ Define the TA_broken add-on failed test case list. """ diff --git a/tests/e2e/test_splunk_addon.py b/tests/e2e/test_splunk_addon.py index a444b968e..6f2deea64 100644 --- a/tests/e2e/test_splunk_addon.py +++ b/tests/e2e/test_splunk_addon.py @@ -635,10 +635,10 @@ def empty_method(): logger.info(result.outlines) result.stdout.fnmatch_lines_random( - constants.TA_REQ_BROKEN_WARNING, - constants.TA_REQ_BROKEN_PASSED + constants.TA_REQ_BROKEN_WARNING + + constants.TA_REQ_BROKEN_PASSED + constants.TA_REQ_BROKEN_FAILED - + constants.TA_REQ_BROKEN_SKIPPED + + constants.TA_REQ_BROKEN_SKIPPED, ) result.assert_outcomes( passed=len(constants.TA_REQ_BROKEN_PASSED), From 021b92e1dd997f5a32fef1dbe99f3750ae4987b8 Mon Sep 17 00:00:00 2001 From: Harshil Gajera Date: Thu, 11 Jul 2024 18:11:18 +0530 Subject: [PATCH 6/8] ci: updating test --- tests/e2e/constants.py | 3 --- tests/e2e/test_splunk_addon.py | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/e2e/constants.py b/tests/e2e/constants.py index 346a44cae..0fd69aebd 100644 --- a/tests/e2e/constants.py +++ b/tests/e2e/constants.py @@ -903,9 +903,6 @@ "*test_splunk_app_req_broken.py::Test_App::test_eventtype[eventtype::test_auth* PASSED*", ] -TA_REQ_BROKEN_WARNING = [ - "*List of common fields found in both cim_fields and missing_recommended_fields = ['dest']*" -] """ Define the TA_broken add-on failed test case list. """ diff --git a/tests/e2e/test_splunk_addon.py b/tests/e2e/test_splunk_addon.py index 6f2deea64..58d4d9059 100644 --- a/tests/e2e/test_splunk_addon.py +++ b/tests/e2e/test_splunk_addon.py @@ -704,6 +704,8 @@ def empty_method(): failed=len(constants.TA_REQ_TRANSITION_FAILED), skipped=len(constants.TA_REQ_TRANSITION_SKIPPED), ) + # checking warning for same field provided in cim_field and missing_recommended_fields + assert result.parseoutcomes().get("warnings") == 2 # make sure that we get a non '0' exit code for the testsuite as it contains failure assert result.ret == 0, "result not equal to 0" From fb44a2a4a81138e3d864057bcc6fc642b24c95ef Mon Sep 17 00:00:00 2001 From: Harshil Gajera Date: Thu, 11 Jul 2024 18:12:19 +0530 Subject: [PATCH 7/8] ci: updating test --- tests/e2e/test_splunk_addon.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/e2e/test_splunk_addon.py b/tests/e2e/test_splunk_addon.py index 58d4d9059..5b29ede2b 100644 --- a/tests/e2e/test_splunk_addon.py +++ b/tests/e2e/test_splunk_addon.py @@ -635,8 +635,7 @@ def empty_method(): logger.info(result.outlines) result.stdout.fnmatch_lines_random( - constants.TA_REQ_BROKEN_WARNING - + constants.TA_REQ_BROKEN_PASSED + constants.TA_REQ_BROKEN_PASSED + constants.TA_REQ_BROKEN_FAILED + constants.TA_REQ_BROKEN_SKIPPED, ) @@ -645,10 +644,9 @@ def empty_method(): failed=len(constants.TA_REQ_BROKEN_FAILED), skipped=len(constants.TA_REQ_BROKEN_SKIPPED), ) - # assert ( - # "List of common fields found in both cim_fields and missing_recommended_fields = ['dest']" - # in result.outlines - # ) + + # checking warning for same field provided in cim_field and missing_recommended_fields + assert result.parseoutcomes().get("warnings") == 2 # make sure that we get a non '0' exit code for the testsuite as it contains failure assert result.ret != 0 @@ -704,8 +702,6 @@ def empty_method(): failed=len(constants.TA_REQ_TRANSITION_FAILED), skipped=len(constants.TA_REQ_TRANSITION_SKIPPED), ) - # checking warning for same field provided in cim_field and missing_recommended_fields - assert result.parseoutcomes().get("warnings") == 2 # make sure that we get a non '0' exit code for the testsuite as it contains failure assert result.ret == 0, "result not equal to 0" From 0bc8cf1e9da8262f6934d8ec17f9cb732b542784 Mon Sep 17 00:00:00 2001 From: Harshil Gajera Date: Fri, 12 Jul 2024 11:09:38 +0530 Subject: [PATCH 8/8] ci: updating warning --- pytest_splunk_addon/cim_tests/test_generator.py | 2 +- tests/e2e/test_splunk_addon.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pytest_splunk_addon/cim_tests/test_generator.py b/pytest_splunk_addon/cim_tests/test_generator.py index 804caf5c2..442d54be1 100644 --- a/pytest_splunk_addon/cim_tests/test_generator.py +++ b/pytest_splunk_addon/cim_tests/test_generator.py @@ -276,7 +276,7 @@ def generate_recommended_fields_tests(self): ) if common_fields: LOGGER.warning( - f"List of common fields found in both cim_fields and missing_recommended_fields = {common_fields}" + f"Common fields found in both cim_fields and missing_recommended_fields for {event.sample_name} sample = {common_fields}" ) fields = ( list(event.requirement_test_data["cim_fields"].keys()) diff --git a/tests/e2e/test_splunk_addon.py b/tests/e2e/test_splunk_addon.py index 5b29ede2b..a035ce451 100644 --- a/tests/e2e/test_splunk_addon.py +++ b/tests/e2e/test_splunk_addon.py @@ -637,7 +637,7 @@ def empty_method(): result.stdout.fnmatch_lines_random( constants.TA_REQ_BROKEN_PASSED + constants.TA_REQ_BROKEN_FAILED - + constants.TA_REQ_BROKEN_SKIPPED, + + constants.TA_REQ_BROKEN_SKIPPED ) result.assert_outcomes( passed=len(constants.TA_REQ_BROKEN_PASSED),