Skip to content

Commit

Permalink
add: Added new fixtures implementation #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 4e513f7 commit 5914227
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,42 @@
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():
# Fixtures

@pytest.fixture(scope="function")
def socket_file_properties():
return os.stat(ANALYSISD_SOCKET).st_ino, os.path.getmtime(ANALYSISD_SOCKET)

@pytest.fixture(scope="function")
def run_analysisd_test_config():
# restart analysisd daemon
control_service('restart', daemon='wazuh-analysisd')
check_daemon_status(running_condition=True, target_daemon='wazuh-analysisd')

# Updating Analysisd
# run analysisd test configuration mode
run = subprocess.Popen(['/bin/bash', '-c', command_exec])
run.communicate()

def test_queue_socket_properties():

def test_queue_socket_properties(socket_file_properties, run_analysisd_test_config):
# Check if analysisd daemon is running
if check_daemon_status(running_condition=True, target_daemon='wazuh-analysisd') is not True:
control_service('start', daemon='wazuh-analysisd')
check_daemon_status(running_condition=True, target_daemon='wazuh-analysisd')

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

configure_analysisd_queue_socket()
run_analysisd_test_config

assert current_inode_file == os.stat(ANALYSISD_SOCKET).st_ino, \
f"The Inode 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"
f"The Filetime value for the socket {ANALYSISD_SOCKET} has changed"

0 comments on commit 5914227

Please sign in to comment.