Skip to content

Commit

Permalink
refac: Changed test name #1850
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando authored and mauromalara committed Sep 26, 2022
1 parent d0f5997 commit 4e513f7
Showing 1 changed file with 17 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 4e513f7

Please sign in to comment.