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

Create local_internal_options configuration handler fixture #1835

Merged
merged 8 commits into from
Sep 7, 2021

Conversation

Rebits
Copy link
Member

@Rebits Rebits commented Sep 3, 2021

Related issue
#1829

Description

This PR closes #1829. It adds a common Wazuh local_internal_options configuration handler fixture for all integration tests.

Usage

In order to use this fixture, it is necessary to define a local_internal_options variable. This should be a dictionary with the necessary internal options for the test. For example:

local_internal_options = {'monitord.rotate_log': '0', 'syscheck.debug': '0' }

With this variable defined the fixture will works for each test which calls it.

This fixture is defined for module scope cases. In those tests that changes local_internal_options according to a list, it is recommended to use the currently defined fixture.

Tests

  • Proven that this fixture works correctly
  • Python codebase satisfies PEP-8 style style guide. pycodestyle --max-line-length=120 --show-source --show-pep8 file.py.
  • Python codebase is documented following the Google Style for Python docstrings.

@juliamagan juliamagan self-requested a review September 6, 2021 06:21
Copy link
Member

@juliamagan juliamagan left a comment

Choose a reason for hiding this comment

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

GJ, some changes are required

@@ -602,3 +602,30 @@ def create_file_structure_function(get_files_list):
yield

delete_file_structure(get_files_list)


@pytest.fixture(scope="module")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@pytest.fixture(scope="module")
@pytest.fixture(scope='module')

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 87039c1

Comment on lines 623 to 624
logger.error('Configure Local Internal Options: DEBUG - Set local_internal_option to ' +
f"{str(local_internal_options)}")
Copy link
Member

Choose a reason for hiding this comment

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

This logger lever should be info or debug

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 87039c1

Comment on lines 629 to 630
logger.error('Configure Local Internal Options: DEBUG - Restore local_internal_option to ' +
f"{str(backup_local_internal_options)}")
Copy link
Member

Choose a reason for hiding this comment

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

Same as before

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 87039c1

@juliamagan
Copy link
Member

We can test these changes before the merge in temporal branch: common-fixtures-testing

Copy link
Contributor

@jmv74211 jmv74211 left a comment

Choose a reason for hiding this comment

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

GJ some requested changes. I think you would have to make a custom class for the logger and use an appropriate format.

REMOTED_LOCAL_INTERNAL_OPTIONS = {'remoted.debug': '2', 'wazuh_database.interval': '2', 'wazuh_db.commit_time': '2',
'wazuh_db.commit_time_max': '3' }.update(DISABLE_MONITORD_ROTATE_LOG_OPTION)
VD_LOCAL_INTERNAL_OPTIONS = {'wazuh_modules.debug': '2'}.update(DISABLE_MONITORD_ROTATE_LOG_OPTION)
WPK_LOCAL_INTERNAL_OPTIONS = {'wazuh_modules.debug': '2'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix indentations of this file

Copy link
Member Author

@Rebits Rebits Sep 6, 2021

Choose a reason for hiding this comment

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

Done 453f1c6


backup_local_internal_options = conf.get_local_internal_options_dict()

logger.error('Configure Local Internal Options: DEBUG - Set local_internal_option to ' +
Copy link
Contributor

Choose a reason for hiding this comment

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

Change this to logger.debug

Copy link
Contributor

Choose a reason for hiding this comment

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

+ is not neccessary


yield

logger.error('Configure Local Internal Options: DEBUG - Restore local_internal_option to ' +
Copy link
Contributor

Choose a reason for hiding this comment

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

Change this to logger.debug

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 87039c1

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.

Create common tools to edit local internal options file
3 participants