Skip to content

Commit

Permalink
Add control_event_log_service raise documentation
Browse files Browse the repository at this point in the history
Add issue to xfail case description for reconnect_time logcollector test
Fix minnor documentation error
  • Loading branch information
Rebits committed May 10, 2021
1 parent 196a0b7 commit 4d788e1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions deps/wazuh_testing/wazuh_testing/logcollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ def callback_running_command(log_format, command, prefix=monitoring.LOG_COLLECTO
return monitoring.make_callback(pattern=msg, prefix=prefix, escape=escape)



def callback_event_log_service_down(location, severity='WARNING'):
"""Create a callback to detect "DEBUG: Running <log_format> '<command>'" debug line.
Expand All @@ -233,7 +232,6 @@ def callback_event_log_service_down(location, severity='WARNING'):
callable: callback to detect this event.
"""
log_format_message = f"{severity}: The eventlog service is down. Unable to collect logs from '{location}' channel."
print(f"{log_format_message}")
return monitoring.make_callback(pattern=log_format_message, prefix=monitoring.AGENT_DETECTOR_PREFIX)

def callback_trying_to_reconnect(location, reconnect_time):
Expand All @@ -249,11 +247,13 @@ def callback_trying_to_reconnect(location, reconnect_time):
callable: callback to detect this event.
"""
log_format_message = f"DEBUG: Trying to reconnect {location} channel in {reconnect_time} seconds."
print(f"{log_format_message}")
return monitoring.make_callback(pattern=log_format_message, prefix=monitoring.AGENT_DETECTOR_PREFIX)

def callback_reconnect_eventchannel(location):
"""
"""Create a callback to detect if specified channel has been reconnected successfully.
Args:
location (str): Location channel.
"""
log_format_message = f"INFO: '{location}' channel has been reconnected succesfully."
Expand Down
7 changes: 5 additions & 2 deletions deps/wazuh_testing/wazuh_testing/tools/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,13 @@ def check_if_process_is_running(process_name):


def control_event_log_service(control):
"""Control Windows event log service
"""Control Windows event log service.
Args:
control (str): Start or Stop
control (str): Start or Stop.
Raises:
ValueError: If the event log channel does not start/stop correctly.
"""
for _ in range(10):
control_sc = 'disabled' if control == 'stop' else 'auto'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Then, system time is changed using `reconnect_time` value. After that, Wazuh sho

## Expected behavior

- Fail if Wazuh agent does not reconnect to Windows event log at the time specified by `reconnect_time `
- Fail if Wazuh agent does not generate a debug message when Windows event log is down
- Fail if Wazuh agent does not reconnect to Windows event log at the time specified by `reconnect_time`.
- Fail if Wazuh agent does not generate a debug message when the Windows event log is down.

## Code documentation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
from wazuh_testing.tools.time import time_to_seconds
import wazuh_testing.tools.services as services

if sys.platform != 'win32':
pytestmark = [pytest.mark.skip, pytest.mark.tier(level=0)]
else:
pytestmark = pytest.mark.tier(level=0)
pytestmark = [pytest.mark.win32, pytest.mark.tier(level=0)]

local_internal_options = {
'logcollector.remote_commands': 1,
Expand Down Expand Up @@ -81,8 +78,8 @@ def test_reconnect_time(get_local_internal_options, configure_local_internal_opt

config = get_configuration['metadata']

if time_to_seconds(config['reconnect_time']) >= timeout_callback_reconnect_time:
pytest.xfail("Expected fail: ")
if time_to_seconds(config['reconnect_time']) >= timeout_callback_reconnect_time:
pytest.xfail("Expected fail: https://github.com/wazuh/wazuh/issues/8580")

log_callback = logcollector.callback_eventchannel_analyzing(config['location'])
wazuh_log_monitor.start(timeout=global_parameters.default_timeout, callback=log_callback,
Expand All @@ -103,7 +100,7 @@ def test_reconnect_time(get_local_internal_options, configure_local_internal_opt

time.sleep(1)

if time_to_seconds(config['reconnect_time']) >= timeout_callback_reconnect_time:
if time_to_seconds(config['reconnect_time']) >= timeout_callback_reconnect_time:
before = str(datetime.now())
seconds_to_travel = time_to_seconds(config['reconnect_time']) / 2
TimeMachine.travel_to_future(timedelta(seconds=seconds_to_travel))
Expand All @@ -113,7 +110,7 @@ def test_reconnect_time(get_local_internal_options, configure_local_internal_opt

before = str(datetime.now())

if time_to_seconds(config['reconnect_time']) >= timeout_callback_reconnect_time:
if time_to_seconds(config['reconnect_time']) >= timeout_callback_reconnect_time:
TimeMachine.travel_to_future(timedelta(seconds=(seconds_to_travel)))
logger.debug(f"Changing the system clock from {before} to {datetime.now()}")

Expand Down

0 comments on commit 4d788e1

Please sign in to comment.