From 89b65b03b5fc86ce48ec8f0cb2b4a46c492fdb28 Mon Sep 17 00:00:00 2001 From: Deblintrake09 Date: Fri, 1 Dec 2023 12:33:16 -0300 Subject: [PATCH 1/2] fix control_service error handling --- deps/wazuh_testing/wazuh_testing/tools/services.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/deps/wazuh_testing/wazuh_testing/tools/services.py b/deps/wazuh_testing/wazuh_testing/tools/services.py index 546a97ea1c..ab77731fd8 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/services.py +++ b/deps/wazuh_testing/wazuh_testing/tools/services.py @@ -89,14 +89,18 @@ def control_service(action, daemon=None, debug_mode=False): command = subprocess.run(["net", action, "WazuhSvc"], stderr=subprocess.PIPE) result = command.returncode if result != 0: - if action == 'stop' and 'The Wazuh service is not started.' in command.stderr.decode(): + error = command.stderr.decode() + if 'The service is starting or stopping' in error: + time.sleep(1) + continue + if action == 'stop' and 'The Wazuh service is not started.' in error: result = 0 break - if action == 'start' and 'The requested service has already been started.' \ - in command.stderr.decode(): + if action == 'start' and 'The requested service has already been started.' in error: result = 0 break - elif "System error 109 has occurred" not in command.stderr.decode(): + elif "System error 109 has occurred" not in error: + print(f"Unexpected error when control_service failed with the following error: {error}") break else: # Default Unix if daemon is None: From e8dedde25dc6530562170f06810e12f656d2ef09 Mon Sep 17 00:00:00 2001 From: Deblintrake09 Date: Fri, 1 Dec 2023 12:49:47 -0300 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a74d7bc03..e38782833a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ### Changed +- Enhance control_service error handling on windows agents. ([#4733](https://github.com/wazuh/wazuh-qa/pull/4733)) \- (Framework) - Add XFAIL mark to Cluster reliability logs test. ([#4706](https://github.com/wazuh/wazuh-qa/pull/4706)) \- (Tests) ## [4.7.0] - TBD