Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix control_service error handling #4741

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:/wazuh/wazuh-qa/pull/4733)) \- (Framework)
- Add XFAIL mark to Cluster reliability logs test. ([#4706](https:/wazuh/wazuh-qa/pull/4706)) \- (Tests)

## [4.7.0] - TBD
Expand Down
12 changes: 8 additions & 4 deletions deps/wazuh_testing/wazuh_testing/tools/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
jnasselle marked this conversation as resolved.
Show resolved Hide resolved
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:
Expand Down
Loading