From 1f7657cf32caf8c17ca26da40b89a4e685e30a29 Mon Sep 17 00:00:00 2001 From: Fernando Date: Mon, 20 Dec 2021 13:32:32 +0100 Subject: [PATCH] add: Add new test_queue_socket_status first approach #1850 --- .../test_queue_socket_status.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/integration/test_analysisd/test_queue_socket_status/test_queue_socket_status.py diff --git a/tests/integration/test_analysisd/test_queue_socket_status/test_queue_socket_status.py b/tests/integration/test_analysisd/test_queue_socket_status/test_queue_socket_status.py new file mode 100644 index 0000000000..ac3daac5f8 --- /dev/null +++ b/tests/integration/test_analysisd/test_queue_socket_status/test_queue_socket_status.py @@ -0,0 +1,35 @@ +import os +import pytest +import subprocess + +from wazuh_testing.tools import WAZUH_PATH + + +# 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' + + + +def test_queue_socket_status(): + current_inode_file = os.stat(ANALYSISD_SOCKET).st_ino + current_status_time = os.path.getmtime(ANALYSISD_SOCKET) + + # 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')