wazuh-qa icon indicating copy to clipboard operation
wazuh-qa copied to clipboard

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

Open vikman90 opened this issue 1 year ago • 0 comments

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 "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 148, in _get_module_details
  File "<frozen runpy>", line 112, in _get_module_details
  File "/root/wazuh-qa/venv/lib/python3.11/site-packages/pytest/__init__.py", line 5, in <module>
    from _pytest._code import ExceptionInfo
  File "/root/wazuh-qa/venv/lib/python3.11/site-packages/_pytest/_code/__init__.py", line 2, in <module>
    from .code import Code
  File "/root/wazuh-qa/venv/lib/python3.11/site-packages/_pytest/_code/code.py", line 43, in <module>
    from _pytest._io import TerminalWriter
  File "/root/wazuh-qa/venv/lib/python3.11/site-packages/_pytest/_io/__init__.py", line 1, in <module>
    from .terminalwriter import get_terminal_width
  File "/root/wazuh-qa/venv/lib/python3.11/site-packages/_pytest/_io/terminalwriter.py", line 10, in <module>
    from _pytest.compat import final
  File "/root/wazuh-qa/venv/lib/python3.11/site-packages/_pytest/compat.py", line 35, in <module>
    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 "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", 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 ==============================

vikman90 avatar Apr 22 '24 07:04 vikman90