wazuh / wazuh-qa

Wazuh - Quality Assurance
GNU General Public License v2.0
60 stars 30 forks source link

Wazuh-DB integration tests won't run due to an old dependency #5280

Open vikman90 opened 1 week ago

vikman90 commented 1 week ago
Branch Offending dependency Sample test
4.8.0 py < 3.11.0 test_agent_database_version

We've run into some trouble launching the Wazuh-DB integration tests.

Environment

Python OS Environment
3.11.6 Ubuntu 23.10 @ aarch64 VM @ macOS 14.4 @ Apple M3

Current behavior

Setup

apt install python3-venv

cd wazuh-qa
python3 -m venv venv

source venv/bin/activate

pip3 install -r requirements.txt
cd deps/wazuh_testing
python3 setup.py install

cd ../..

Command

python3 -m pytest -vvvs tests/integration/test_wazuh_db/test_agent_database_version.py
Output ``` Traceback (most recent call last): File "/root/wazuh-qa/venv/lib/python3.11/site-packages/py/_vendored_packages/apipkg/__init__.py", line 145, in __makeattr modpath, attrname = self.__map__[name] ~~~~~~~~~~~~^^^^^^ KeyError: '__spec__' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 189, in _run_module_as_main File "", line 148, in _get_module_details File "", line 112, in _get_module_details File "/root/wazuh-qa/venv/lib/python3.11/site-packages/pytest/__init__.py", line 5, in from _pytest._code import ExceptionInfo File "/root/wazuh-qa/venv/lib/python3.11/site-packages/_pytest/_code/__init__.py", line 2, in from .code import Code File "/root/wazuh-qa/venv/lib/python3.11/site-packages/_pytest/_code/code.py", line 43, in from _pytest._io import TerminalWriter File "/root/wazuh-qa/venv/lib/python3.11/site-packages/_pytest/_io/__init__.py", line 1, in from .terminalwriter import get_terminal_width File "/root/wazuh-qa/venv/lib/python3.11/site-packages/_pytest/_io/terminalwriter.py", line 10, in from _pytest.compat import final File "/root/wazuh-qa/venv/lib/python3.11/site-packages/_pytest/compat.py", line 35, in LEGACY_PATH = py.path. local ^^^^^^^^^^^^^^ File "/root/wazuh-qa/venv/lib/python3.11/site-packages/py/_vendored_packages/apipkg/__init__.py", line 152, in __makeattr result = importobj(modpath, attrname) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/wazuh-qa/venv/lib/python3.11/site-packages/py/_vendored_packages/apipkg/__init__.py", line 72, in importobj module = __import__(modpath, None, None, ['__doc__']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1176, in _find_and_load File "", line 1136, in _find_and_load_unlocked File "/root/wazuh-qa/venv/lib/python3.11/site-packages/py/_vendored_packages/apipkg/__init__.py", line 150, in __makeattr raise AttributeError(name) AttributeError: __spec__ ```

Fixing the issue

@juliamagan found out that this problem is caused by an old version of py. We need py ≥ 3.11.0.

pip3 install py==1.11.0
python3 -m pytest -vvvs tests/integration/test_wazuh_db/test_agent_database_version.py
Output ``` ============================= test session starts ============================== platform linux -- Python 3.11.6, pytest-7.1.2, pluggy-1.5.0 -- /root/wazuh-qa/venv/bin/python3 cachedir: .pytest_cache metadata: {'Python': '3.11.6', 'Platform': 'Linux-6.5.0-28-generic-aarch64-with-glibc2.38', 'Packages': {'pytest': '7.1.2', 'pluggy': '1.5.0'}, 'Plugins': {'testinfra': '5.0.0', 'html': '3.1.1', 'metadata': '3.1.1'}} rootdir: /root/wazuh-qa/tests/integration, configfile: pytest.ini plugins: testinfra-5.0.0, html-3.1.1, metadata-3.1.1 collected 1 item tests/integration/test_wazuh_db/test_agent_database_version.py::test_agent_database_version PASSED ============================== 1 passed in 33.42s ============================== ```