From a6e13e2972cb59a6f128fa908e5870fb5309376f Mon Sep 17 00:00:00 2001 From: kdoroszko-splunk <147069837+kdoroszko-splunk@users.noreply.github.com> Date: Tue, 12 Dec 2023 18:23:19 +0100 Subject: [PATCH] fix: reducing index removal while using --splunk-cleanup to be done by only one worker (#805) Reducing index removal while using --splunk-cleanup to be done by only one worker. --- pytest_splunk_addon/splunk.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pytest_splunk_addon/splunk.py b/pytest_splunk_addon/splunk.py index 724381c41..3778f8dba 100644 --- a/pytest_splunk_addon/splunk.py +++ b/pytest_splunk_addon/splunk.py @@ -771,8 +771,12 @@ def splunk_events_cleanup(request, splunk_search_util): """ if request.config.getoption("splunk_cleanup"): - LOGGER.info("Running the old events cleanup") - splunk_search_util.deleteEventsFromIndex() + if ( + "PYTEST_XDIST_WORKER" not in os.environ + or os.environ.get("PYTEST_XDIST_WORKER") == "gw0" + ): + LOGGER.info("Running the old events cleanup") + splunk_search_util.deleteEventsFromIndex() else: LOGGER.info("Events cleanup was disabled.")