Skip to content

Commit

Permalink
refactor(#2947): Move EPS event monitor to analysisd module
Browse files Browse the repository at this point in the history
  • Loading branch information
jmv74211 committed Sep 5, 2022
1 parent 5e114eb commit 50eeb07
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re

import wazuh_testing as eps
from wazuh_testing import T_10, T_20, T_60
from wazuh_testing.modules.analysisd import ANALYSISD_PREFIX, MAILD_PREFIX
from wazuh_testing import LOG_FILE_PATH, ANALYSISD_STATE
from wazuh_testing.tools.monitoring import FileMonitor, generate_monitoring_callback_groups
Expand Down Expand Up @@ -28,8 +28,7 @@ def make_analysisd_callback(pattern, prefix=ANALYSISD_PREFIX):


def check_analysisd_event(file_monitor=None, callback='', error_message=None, update_position=True,
timeout=eps.T_60, prefix=ANALYSISD_PREFIX, accum_results=1,
file_to_monitor=LOG_FILE_PATH):
timeout=T_60, prefix=ANALYSISD_PREFIX, accum_results=1, file_to_monitor=LOG_FILE_PATH):
"""Check if a analysisd event occurs
Args:
Expand All @@ -51,18 +50,18 @@ def check_analysisd_event(file_monitor=None, callback='', error_message=None, up

def check_eps_disabled():
"""Check if the eps module is disabled"""
check_analysisd_event(callback=fr'.*INFO: EPS limit disabled.*', timeout=eps.T_10)
check_analysisd_event(callback=fr'.*INFO: EPS limit disabled.*', timeout=T_10)


def check_eps_enabled(maximum, timeframe):
"""Check if the eps module is enable"""
check_analysisd_event(callback=fr".*INFO: EPS limit enabled, EPS: '{maximum}', timeframe: '{timeframe}'",
timeout=eps.T_10)
timeout=T_10)


def check_configuration_error():
"""Check the configuration error event in ossec.log"""
check_analysisd_event(timeout=eps.T_10, callback=r".* \(\d+\): Configuration error at.*",
check_analysisd_event(timeout=T_10, callback=r".* \(\d+\): Configuration error at.*",
error_message="Could not find the event 'Configuration error at 'etc/ossec.conf' "
'in ossec.log', prefix=MAILD_PREFIX)

Expand Down Expand Up @@ -97,7 +96,7 @@ def get_messages_info(file_monitor, message, accum_results):
"""
error_message = f"Could not find this event in {message}"

result = file_monitor.start(timeout=eps.T_20, update_position=True, accum_results=accum_results,
result = file_monitor.start(timeout=T_20, update_position=True, accum_results=accum_results,
callback=generate_monitoring_callback_groups(message),
error_message=error_message).result()

Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest

from wazuh_testing.tools.configuration import load_configuration_template, get_test_cases_data
from wazuh_testing.modules.eps import event_monitor as evm
from wazuh_testing.modules.analysisd import event_monitor as evm
from wazuh_testing.modules.analysisd import ANALYSISD_STATE_INTERNAL_DEFAULT
from wazuh_testing.processes import check_if_daemons_are_running

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_analysisd/test_eps/test_disabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest

from wazuh_testing.tools.configuration import load_configuration_template, get_test_cases_data
from wazuh_testing.modules.eps import event_monitor as evm
from wazuh_testing.modules.analysisd import event_monitor as evm
from wazuh_testing.modules.analysisd import ANALYSISD_STATE_INTERNAL_DEFAULT
from wazuh_testing.processes import check_if_daemons_are_running

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_analysisd/test_eps/test_enabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest

from wazuh_testing.tools.configuration import load_configuration_template, get_test_cases_data
from wazuh_testing.modules.eps import event_monitor as evm
from wazuh_testing.modules.analysisd import event_monitor as evm
from wazuh_testing.modules.analysisd import ANALYSISD_STATE_INTERNAL_DEFAULT
from wazuh_testing.processes import check_if_daemons_are_running

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest

from wazuh_testing.tools.configuration import load_configuration_template, get_test_cases_data
from wazuh_testing.modules.eps import event_monitor as evm
from wazuh_testing.modules.analysisd import event_monitor as evm
from wazuh_testing.tools.services import control_service
from wazuh_testing.modules.analysisd import ANALYSISD_STATE_INTERNAL_DEFAULT
from wazuh_testing.processes import check_if_daemons_are_running
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest

from wazuh_testing.tools.configuration import load_configuration_template, get_test_cases_data
from wazuh_testing.modules.eps import event_monitor as evm
from wazuh_testing.modules.analysisd import event_monitor as evm
from wazuh_testing.tools.services import control_service
from wazuh_testing.modules.analysisd import ANALYSISD_STATE_INTERNAL_DEFAULT
from wazuh_testing.processes import check_if_daemons_are_running
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from wazuh_testing.tools.configuration import get_simulate_agent_configuration
from wazuh_testing.modules.eps import event_monitor as evm
from wazuh_testing.modules.analysisd import event_monitor as evm
from wazuh_testing.modules.analysisd import ANALYSISD_STATE_INTERNAL_DEFAULT, PERCENTAGE_PROCESS_MSGS


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from wazuh_testing.tools.configuration import load_configuration_template, get_test_cases_data, \
get_syslog_simulator_configuration
from wazuh_testing.modules.eps import event_monitor as evm
from wazuh_testing.modules.analysisd import event_monitor as evm
from wazuh_testing.tools.monitoring import FileMonitor
from wazuh_testing.tools.run_simulator import syslog_simulator
from wazuh_testing.tools import ALERT_FILE_PATH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from wazuh_testing.tools.configuration import load_configuration_template, get_test_cases_data, \
get_simulate_agent_configuration
from wazuh_testing.modules.eps import event_monitor as evm
from wazuh_testing.modules.analysisd import event_monitor as evm
from wazuh_testing.modules.analysisd import PERCENTAGE_PROCESS_MSGS, QUEUE_SIZE


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from wazuh_testing.tools.configuration import load_configuration_template, get_test_cases_data, \
get_simulate_agent_configuration
from wazuh_testing.modules.eps import event_monitor as evm
from wazuh_testing.modules.analysisd import event_monitor as evm
from wazuh_testing.modules.analysisd import PERCENTAGE_PROCESS_MSGS, QUEUE_SIZE


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from wazuh_testing.tools.configuration import load_configuration_template, get_test_cases_data, \
get_simulate_agent_configuration
from wazuh_testing.modules.eps import event_monitor as evm
from wazuh_testing.modules.analysisd import event_monitor as evm
from wazuh_testing.modules.analysisd import PERCENTAGE_PROCESS_MSGS


Expand Down

0 comments on commit 50eeb07

Please sign in to comment.