Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logcollector integration tests T0: reconnect_time option #1312

Merged
merged 11 commits into from
May 12, 2021

Conversation

Rebits
Copy link
Member

@Rebits Rebits commented May 7, 2021

Related issue
Closes #1251

Description

This PR adds logcollector tests for reconnect_time option.

  • Test reconnect time: Check that logcollector reconnect to Windows event log using reconnect_time value.

This test is valid for Windows agents.

Every case of reconnect_time greater than 30 seconds will be marked as xfail due to this issue: wazuh/wazuh#8580

Test results

Windows - Agent

reconnect_time_logcollector

Documentation

Test reconnect time

test_reconnec_time_docu

@Rebits Rebits self-assigned this May 7, 2021
@Rebits Rebits changed the title 1251 logcollector reconnect time Logcollector integration tests T0: reconnect_time option May 7, 2021
Comment on lines 219 to 223
return monitoring.make_callback(pattern=msg, prefix=prefix, escape=escape)



def callback_event_log_service_down(location, severity='WARNING'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return monitoring.make_callback(pattern=msg, prefix=prefix, escape=escape)
def callback_event_log_service_down(location, severity='WARNING'):
return monitoring.make_callback(pattern=msg, prefix=prefix, escape=escape)
def callback_event_log_service_down(location, severity='WARNING'):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 4d788e1

Comment on lines 236 to 239
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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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):
return monitoring.make_callback(pattern=log_format_message, prefix=monitoring.AGENT_DETECTOR_PREFIX)
def callback_trying_to_reconnect(location, reconnect_time):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 4d788e1

Comment on lines 252 to 255
print(f"{log_format_message}")
return monitoring.make_callback(pattern=log_format_message, prefix=monitoring.AGENT_DETECTOR_PREFIX)

def callback_reconnect_eventchannel(location):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(f"{log_format_message}")
return monitoring.make_callback(pattern=log_format_message, prefix=monitoring.AGENT_DETECTOR_PREFIX)
def callback_reconnect_eventchannel(location):
return monitoring.make_callback(pattern=log_format_message, prefix=monitoring.AGENT_DETECTOR_PREFIX)
def callback_reconnect_eventchannel(location):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 4d788e1

Comment on lines 256 to 258
"""

"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is missing here 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 4d788e1

Comment on lines 240 to 243
"""Control Windows event log service

Args:
control (str): Start or Stop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Control Windows event log service
Args:
control (str): Start or Stop
"""Control Windows event log service.
Args:
control (str): Start or Stop.

Raises section is missing here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 4d788e1

Comment on lines 24 to 25
- 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 4d788e1

Comment on lines 16 to 19
if sys.platform != 'win32':
pytestmark = [pytest.mark.skip, pytest.mark.tier(level=0)]
else:
pytestmark = pytest.mark.tier(level=0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 4d788e1

config = get_configuration['metadata']

if time_to_seconds(config['reconnect_time']) >= timeout_callback_reconnect_time:
pytest.xfail("Expected fail: ")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add more detail here explaining why the error is expected.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 4d788e1


before = str(datetime.now())

if time_to_seconds(config['reconnect_time']) >= timeout_callback_reconnect_time:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if time_to_seconds(config['reconnect_time']) >= timeout_callback_reconnect_time:
if time_to_seconds(config['reconnect_time']) >= timeout_callback_reconnect_time:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 4d788e1

@BraulioV BraulioV merged commit 8038105 into master May 12, 2021
@BraulioV BraulioV deleted the 1251_logcollector_reconnect_time branch May 12, 2021 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logcollector integration tests T0: Check reconnect_time
2 participants