diff --git a/.github/workflows/build-test-release.yml b/.github/workflows/build-test-release.yml index 7dcd4280c..0e372de37 100644 --- a/.github/workflows/build-test-release.yml +++ b/.github/workflows/build-test-release.yml @@ -129,6 +129,7 @@ jobs: path: | test-results-${{ matrix.splunk.version }} + test-splunk-matrix: needs: - meta @@ -149,7 +150,6 @@ jobs: "splunk_app_cim_broken", "splunk_fiction_indextime", "splunk_fiction_indextime_broken", - "splunk_fiction_indextime_wrong_hec_token", "splunk_setup_fixture", "splunk_app_req", "splunk_app_req_broken", diff --git a/pytest_splunk_addon/plugin.py b/pytest_splunk_addon/plugin.py index 5b136c27e..3926774d4 100644 --- a/pytest_splunk_addon/plugin.py +++ b/pytest_splunk_addon/plugin.py @@ -26,8 +26,6 @@ test_generator = None -EXC_MAP = [Exception] - def pytest_configure(config): """ @@ -122,7 +120,6 @@ def pytest_sessionstart(session): SampleXdistGenerator.tokenized_event_source = session.config.getoption( "tokenized_event_source" ).lower() - session.__exc_limits = EXC_MAP if ( SampleXdistGenerator.tokenized_event_source == "store_new" and session.config.getoption("ingest_events").lower() @@ -212,14 +209,3 @@ def init_pytest_splunk_addon_logger(): init_pytest_splunk_addon_logger() LOGGER = logging.getLogger("pytest-splunk-addon") - - -def pytest_exception_interact(node, call, report): - """ - Hook called when an exception is raised during a test. - If the number of occurrences for a specific exception exceeds the limit in session.__exc_limits, pytest exits - https://docs.pytest.org/en/stable/reference/reference.html#pytest.hookspec.pytest_exception_interact - """ - if call.excinfo.type in node.session.__exc_limits: - # pytest exits only for exceptions defined in EXC_MAP - pytest.exit(f"Exiting pytest due to: {call.excinfo.type}") diff --git a/pytest_splunk_addon/splunk.py b/pytest_splunk_addon/splunk.py index 1e77ad0ec..d81c03d3f 100644 --- a/pytest_splunk_addon/splunk.py +++ b/pytest_splunk_addon/splunk.py @@ -979,7 +979,7 @@ def is_responsive_hec(request, splunk): f'{request.config.getoption("splunk_hec_scheme")}://{splunk["forwarder_host"]}:{splunk["port_hec"]}/services/collector/health/1.0', verify=False, ) - LOGGER.debug("Status code: {}".format(response.status_code)) + LOGGER.debug("Status code: %d", response.status_code) if response.status_code in (200, 201): LOGGER.info("Splunk HEC is responsive.") return True @@ -1040,7 +1040,8 @@ def is_valid_hec(request, splunk): data={"event": "test_hec", "sourcetype": "hec_token_test"}, verify=False, ) - LOGGER.debug("Status code: {}".format(response.status_code)) + LOGGER.debug("Status code: %d", response.status_code) + if response.status_code == 200: LOGGER.info("Splunk HEC is valid.") else: diff --git a/tests/e2e/test_splunk_addon.py b/tests/e2e/test_splunk_addon.py index a95820419..006e329fd 100644 --- a/tests/e2e/test_splunk_addon.py +++ b/tests/e2e/test_splunk_addon.py @@ -169,8 +169,8 @@ def empty_method(): assert result.ret == 0 -@pytest.mark.docker @pytest.mark.splunk_fiction_indextime_wrong_hec_token +@pytest.mark.external def test_splunk_fiction_indextime_wrong_hec_token(testdir, request): """Make sure that pytest accepts our fixture.""" @@ -205,7 +205,11 @@ def empty_method(): # run pytest with the following cmd args result = testdir.runpytest( f"--splunk-version={request.config.getoption('splunk_version')}", - "--splunk-type=docker", + "--splunk-type=external", + "--splunk-host=splunk", + "--splunk-port=8089", + "--splunk-forwarder-host=splunk", + "--splunk-hec-token=8b741d03-43e9-4164-908b-e09102327d22", "-v", "--search-interval=0", "--search-retry=0", @@ -213,9 +217,8 @@ def empty_method(): "--search-index=*,_internal", ) - result.assert_outcomes(errors=1, passed=0, failed=0, xfailed=0) result.stdout.fnmatch_lines( - "!!!!!! _pytest.outcomes.Exit: Exiting pytest due to: !!!!!!!" + "*_pytest.outcomes.Exit: Exiting pytest due to invalid HEC token value." ) assert result.ret != 0