From da72729919eb7056757ad4d5226682ab1350101b Mon Sep 17 00:00:00 2001 From: Fernando Date: Wed, 22 Dec 2021 11:27:36 +0100 Subject: [PATCH] refac: Changed test name #1850 --- .../test_queue_socket_properties.py} | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) rename tests/integration/test_analysisd/{test_queue_socket_status/test_queue_socket_status.py => test_queue_socket_properties/test_queue_socket_properties.py} (52%) diff --git a/tests/integration/test_analysisd/test_queue_socket_status/test_queue_socket_status.py b/tests/integration/test_analysisd/test_queue_socket_properties/test_queue_socket_properties.py similarity index 52% rename from tests/integration/test_analysisd/test_queue_socket_status/test_queue_socket_status.py rename to tests/integration/test_analysisd/test_queue_socket_properties/test_queue_socket_properties.py index 4a73792a05..ec3c8fd422 100644 --- a/tests/integration/test_analysisd/test_queue_socket_status/test_queue_socket_status.py +++ b/tests/integration/test_analysisd/test_queue_socket_properties/test_queue_socket_properties.py @@ -5,43 +5,36 @@ from wazuh_testing.tools import WAZUH_PATH from wazuh_testing.tools.services import control_service, check_daemon_status - - # Marks pytestmark = [pytest.mark.linux, pytest.mark.tier(level=0), pytest.mark.server] # variables - ANALYSISD_SOCKET = os.path.join(WAZUH_PATH, 'queue', 'sockets', 'queue') analysisd_path = os.path.join(WAZUH_PATH,'bin', 'wazuh-analysisd') command_exec = f'{analysisd_path} -t' +# Fixture +def configure_analysisd_queue_socket(): + # restart analysisd daemon + control_service('restart', daemon='wazuh-analysisd') + check_daemon_status(running_condition=True, target_daemon='wazuh-analysisd') -def test_queue_socket_status(): - + # Updating Analysisd + run = subprocess.Popen(['/bin/bash', '-c', command_exec]) + run.communicate() + +def test_queue_socket_properties(): # Check if analysisd daemon is running - check_daemon_status(running_condition=True, target_daemon='wazuh-analysisd') + if check_daemon_status(running_condition=True, target_daemon='wazuh-analysisd') is not True: + control_service('start', daemon='wazuh-analysisd') 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') + configure_analysisd_queue_socket() + assert current_inode_file == os.stat(ANALYSISD_SOCKET).st_ino, \ + f"The Inode value for the socket {ANALYSISD_SOCKET} has changed" - # Updating Analysisd - run = subprocess.Popen(['/bin/bash', '-c', command_exec]) - run.communicate() - - try: - assert current_inode_file == os.stat(ANALYSISD_SOCKET).st_ino - except AssertionError: - raise AssertionError(f'The Inode value for the socket {ANALYSISD_SOCKET} has changed') - - try: - assert current_status_time == os.path.getmtime(ANALYSISD_SOCKET) - except AssertionError: - raise AssertionError(f'The Filetime value for the socket {ANALYSISD_SOCKET} has changed') + assert current_status_time == os.path.getmtime(ANALYSISD_SOCKET), \ + f"The Filetime value for the socket {ANALYSISD_SOCKET} has changed" \ No newline at end of file