-
Notifications
You must be signed in to change notification settings - Fork 30
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 Test Fails for Windows Agents #4840
Comments
UpdateI have run locally on a Windows 11 agent the logcollector integration tests ( PS C:\Users\vagrant\wazuh-qa\tests\integration> python -m pytest -v --html=report.html .\test_logcollector\test_log_filter_options
============================= test session starts =============================
platform win32 -- Python 3.12.1, pytest-7.4.4, pluggy-1.3.0 -- C:\Users\vagrant\AppData\Local\Programs\Python\Python312\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.12.1', 'Platform': 'Windows-11-10.0.22621-SP0', 'Packages': {'pytest': '7.4.4', 'pluggy': '1.3.0'}, 'Plugins': {'html': '2.0.1', 'metadata': '3.0.0', 'testinfra': '10.0.0'}}
rootdir: C:\Users\vagrant\wazuh-qa\tests\integration
configfile: pytest.ini
plugins: html-2.0.1, metadata-3.0.0, testinfra-10.0.0
collecting ... collected 14 items
test_logcollector/test_log_filter_options/test_ignore_regex.py::test_ignore_multiple_regex[Log match - Two ignore tags - Match first tag-] PASSED [ 7%]
test_logcollector/test_log_filter_options/test_ignore_regex.py::test_ignore_multiple_regex[Log match - Two ignore tags - Match both tags-] PASSED [ 14%]
test_logcollector/test_log_filter_options/test_ignore_regex.py::test_ignore_multiple_regex[Log match - Two ignore tags - Match second tag-] PASSED [ 21%]
test_logcollector/test_log_filter_options/test_ignore_regex.py::test_ignore_multiple_regex[No match - Two ignore tags-] PASSED [ 28%]
test_logcollector/test_log_filter_options/test_restrict_ignore_regex.py::test_restrict_ignore_regex_values[Matches with restrict tag - Ignore and restrict tags with PCRE2 regex-] PASSED [ 35%]
test_logcollector/test_log_filter_options/test_restrict_ignore_regex.py::test_restrict_ignore_regex_values[Matches with ignore tag - Ignore and restrict tags with osregex regex-] PASSED [ 42%]
test_logcollector/test_log_filter_options/test_restrict_ignore_regex.py::test_restrict_ignore_regex_values[Log match - Ignore and restrict tags with osmatch regex-] PASSED [ 50%]
test_logcollector/test_log_filter_options/test_restrict_ignore_regex.py::test_restrict_ignore_regex_values[Matches with restrict tag - Ignore and restrict tags with pcre2 and osregex regex-] PASSED [ 57%]
test_logcollector/test_log_filter_options/test_restrict_ignore_regex.py::test_restrict_ignore_regex_values[Matches with ignore tag - Ignore and restrict tags with pcre2 and osmatch regex-] PASSED [ 64%]
test_logcollector/test_log_filter_options/test_restrict_ignore_regex.py::test_restrict_ignore_regex_values[Log match - Ignore and restrict tags with osregex and osmatch regex-] PASSED [ 71%]
test_logcollector/test_log_filter_options/test_restrict_regex.py::test_restrict_multiple_regex[Log match - Two Restrict tags - Match first tag-] PASSED [ 78%]
test_logcollector/test_log_filter_options/test_restrict_regex.py::test_restrict_multiple_regex[Log match - Two Restrict tags - Match both tags-] PASSED [ 85%]
test_logcollector/test_log_filter_options/test_restrict_regex.py::test_restrict_multiple_regex[Log match - Two Restrict tags - Match second tag-] PASSED [ 92%]
test_logcollector/test_log_filter_options/test_restrict_regex.py::test_restrict_multiple_regex[No match - Two Restrict tags-] PASSED [100%]
============================== warnings summary ===============================
test_logcollector/test_log_filter_options/test_ignore_regex.py: 20 warnings
test_logcollector/test_log_filter_options/test_restrict_ignore_regex.py: 30 warnings
test_logcollector/test_log_filter_options/test_restrict_regex.py: 20 warnings
C:\Users\vagrant\AppData\Local\Programs\Python\Python312\Lib\site-packages\wazuh_testing\tools\configuration.py:334: DeprecationWarning: Testing an element's truth value will raise an exception in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
if not section_conf:
test_logcollector/test_log_filter_options/test_ignore_regex.py: 4 warnings
test_logcollector/test_log_filter_options/test_restrict_ignore_regex.py: 6 warnings
test_logcollector/test_log_filter_options/test_restrict_regex.py: 4 warnings
C:\Users\vagrant\wazuh-qa\tests\integration\conftest.py:461: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
cells.insert(1, html.td(datetime.utcnow(), class_='col-time'))
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
- generated html file: file://C:\Users\vagrant\wazuh-qa\tests\integration\report.html -
================= 14 passed, 84 warnings in 232.89s (0:03:52) ================= HTML report: |
A further analysis was made and it is observed that in both cases the error occurs when the script tries to create the file new_file_path = 'c:\\test'
@pytest.fixture(scope='function')
def create_file(new_file_path):
"""Create an empty file.
Args:
new_file_path (str): File path to create.
"""
> write_file(new_file_path)
conftest.py:1340:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
file_path = 'c:\\test', data = ''
def write_file(file_path, data=''):
> with open(file_path, 'w') as f:
E PermissionError: [Errno 13] Permission denied: 'c:\\test'
C:\Python311\Lib\site-packages\wazuh_testing\tools\file.py:177: PermissionError The
It is probably due to the first option as the filepath does not contain the extension but we have not been able to reproduce the error locally. |
@nbertoldo @nmkoremblum @cborla we've confirmed there is an issue in the test. Can we get a fix? |
Considering that it was possible to run the tests locally several times without errors, I think it may be a problem with the environment. @wazuh/qa Is it possible to relaunch this test? |
UpdateThe test has been run again and the error occurs in another test case, so the failure is random.
Log errorconftest.py:1330: in create_files_in_folder
delete_path_recursively(folder_path)
C:\Python311\Lib\site-packages\wazuh_testing\tools\file.py:244: in delete_path_recursively
shutil.rmtree(path, onerror=on_write_error)
C:\Python311\Lib\shutil.py:759: in rmtree
return _rmtree_unsafe(path, onerror)
C:\Python311\Lib\shutil.py:626: in _rmtree_unsafe
onerror(os.rmdir, path, sys.exc_info())
C:\Python311\Lib\shutil.py:624: in _rmtree_unsafe
os.rmdir(path)
E OSError: [WinError 145] The directory is not empty: 'c:\\testfolder\\subfolder'
-----------------------------Captured stdout setup------------------------------
The Wazuh service was stopped successfully.
The Wazuh service is starting.
The Wazuh service was started successfully.
-----------------------------Captured stderr setup------------------------------
2024-01-23 17:13:18,157 - wazuh_testing - DEBUG - Set local_internal_option to {'windows.debug': '2', 'agent.debug': '2'}
2024-01-23 17:13:18,158 - wazuh_testing - DEBUG - Restarting all daemon
-------------------------------Captured log setup-------------------------------
DEBUG wazuh_testing:conftest.py:694 Set local_internal_option to {'windows.debug': '2', 'agent.debug': '2'}
DEBUG wazuh_testing:conftest.py:144 Restarting all daemon
----------------------------Captured stdout teardown----------------------------
The Wazuh service was stopped successfully.
----------------------------Captured stderr teardown----------------------------
2024-01-23 17:13:23,396 - wazuh_testing - DEBUG - Stopping all daemons
2024-01-23 17:13:23,586 - wazuh_testing - DEBUG - Restore local_internal_option to {'syscheck.debug': '2\n', 'agent.debug': '2\n', 'monitord.rotate_log': '0\n', 'analysisd.debug': '2\n', 'wazuh_modules.debug': '2\n', 'wazuh_database.interval': '1\n', 'wazuh_db.commit_time': '2\n', 'wazuh_db.commit_time_max': '3\n', 'remoted.debug': '2\n'}
-----------------------------Captured log teardown------------------------------
DEBUG wazuh_testing:conftest.py:156 Stopping all daemons
DEBUG wazuh_testing:conftest.py:699 Restore local_internal_option to {'syscheck.debug': '2\n', 'agent.debug': '2\n', 'monitord.rotate_log': '0\n', 'analysisd.debug': '2\n', 'wazuh_modules.debug': '2\n', 'wazuh_database.interval': '1\n', 'wazuh_db.commit_time': '2\n', 'wazuh_db.commit_time_max': '3\n', 'remoted.debug': '2\n'} |
UpdateIn a new test run, the test result has been successful, which confirms the random behaviour of the test. |
Let's add it to the @wazuh/devel-core1-div3's backlog. It's not a stopper. |
UpdateI have been able to reproduce the error locally. Steps to reproduce
Administrator@vm-win2016 MINGW64 ~/wazuh-qa/tests/integration (4.8.0)
$ python -m pytest -vvx --html=report.html test_logcollector/test_log_filter_options/
============================= test session starts =============================
platform win32 -- Python 3.11.9, pytest-7.1.2, pluggy-1.5.0 -- C:\Users\Administrator\AppData\Local\Programs\Python\Python311\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.11.9', 'Platform': 'Windows-10-10.0.14393-SP0', 'Packages': {'pytest': '7.1.2', 'pluggy': '1.5.0'}, 'Plugins': {'html': '3.1.1', 'metadata': '3.1.1'}}
rootdir: C:\Users\Administrator\wazuh-qa\tests\integration, configfile: pytest.ini
plugins: html-3.1.1, metadata-3.1.1
collecting ... collected 14 items
test_logcollector/test_log_filter_options/test_ignore_regex.py::test_ignore_multiple_regex[Log match - Two ignore tags - Match first tag-] ERROR [ 7%]
=================================== ERRORS ====================================
_ ERROR at setup of test_ignore_multiple_regex[Log match - Two ignore tags - Match first tag-] _
new_file_path = 'c:\\test'
@pytest.fixture(scope='function')
def create_file(new_file_path):
"""Create an empty file.
Args:
new_file_path (str): File path to create.
"""
> write_file(new_file_path)
conftest.py:1340:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
file_path = 'c:\\test', data = ''
def write_file(file_path, data=''):
> with open(file_path, 'w') as f:
E PermissionError: [Errno 13] Permission denied: 'c:\\test'
..\..\..\AppData\Local\Programs\Python\Python311\Lib\site-packages\wazuh_testing\tools\file.py:177: PermissionError
- generated html file: file://C:\Users\Administrator\wazuh-qa\tests\integration\report.html -
=========================== short test summary info ===========================
ERROR test_logcollector/test_log_filter_options/test_ignore_regex.py::test_ignore_multiple_regex[Log match - Two ignore tags - Match first tag-]
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!
============================== 1 error in 0.13s ===============================
Report: report.zip Could this situation occur in the test environment? |
The issue is closed for the following reasons:
|
Description
During the tests of Release 4.8.0 - Alpha 2 - Integration tests I have detected an error in Windows Agent. The specific error is
PermissionError: [Errno 13] Permission denied: 'c:\\test'
The error has been detected in the LogCollector tests.
Pipeline Error
Error in the Logs
Evidences
The text was updated successfully, but these errors were encountered: