Skip to content

Commit

Permalink
add: Added stopping and restarting analysisd daemon implementation #1850
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando committed Dec 21, 2021
1 parent 1f7657c commit b1623e0
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import subprocess

from wazuh_testing.tools import WAZUH_PATH
from wazuh_testing.tools.services import control_service, check_daemon_status



# Marks
Expand All @@ -15,11 +17,21 @@
command_exec = f'{analysisd_path} -t'



def test_queue_socket_status():

This comment has been minimized.

Copy link
@mauromalara

mauromalara Dec 21, 2021

Contributor

Change it with a more descriptive name


# Check if analysisd daemon is running
check_daemon_status(running_condition=True, target_daemon='wazuh-analysisd')

This comment has been minimized.

Copy link
@mauromalara

mauromalara Dec 21, 2021

Contributor

@fernandolojano You must start it if not running. Because the lines after this can throw an error if analysisd is stopped.


current_inode_file = os.stat(ANALYSISD_SOCKET).st_ino
current_status_time = os.path.getmtime(ANALYSISD_SOCKET)

# Stop analysisd daemon
control_service('stop', daemon='wazuh-analysisd')
check_daemon_status(running_condition=False, target_daemon='wazuh-analysisd')

control_service('start', daemon='wazuh-analysisd')


# Updating Analysisd
run = subprocess.Popen(['/bin/bash', '-c', command_exec])
run.communicate()
Expand Down

1 comment on commit b1623e0

@mauromalara
Copy link
Contributor

@mauromalara mauromalara commented on b1623e0 Dec 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fernandolojano check the lines 40 and 45. You can simply do: assert something, f"The inode value for the socket {SOCKET} has changed." Instead of the try-except block.

Please sign in to comment.