Bug 1841968 - ansibe FTBFS due to test failures with Pytest 5
Summary: ansibe FTBFS due to test failures with Pytest 5
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: ansible
Version: 33
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kevin Fenzi
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-05-30 00:03 UTC by Charalampos Stratakis
Modified: 2021-04-24 19:05 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-04-24 19:05:34 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
build log (4.43 MB, text/plain)
2020-05-30 00:03 UTC, Charalampos Stratakis
no flags Details

Description Charalampos Stratakis 2020-05-30 00:03:43 UTC
Created attachment 1693572 [details]
build log

After updating in rawhide to Pytest 5, some tests are failing:

<snippet>

__________ ERROR at setup of test_show_list_returns_serializable_data __________
[gw1] linux -- Python 3.9.0 /usr/bin/python3
"""
    $ jq '._meta.hostvars[].config' data.json | head
    {
      "alternateguestname": "",
      "instanceuuid": "5035a5cd-b8e8-d717-e133-2d383eb0d675",
      "memoryhotaddenabled": false,
      "guestfullname": "Red Hat Enterprise Linux 7 (64-bit)",
      "changeversion": "2016-05-16T18:43:14.977925Z",
      "uuid": "4235fc97-5ddb-7a17-193b-9a3ac97dc7b4",
      "cpuhotremoveenabled": false,
      "vpmcenabled": false,
      "firmware": "bios",
    """
    
    from __future__ import print_function
    
    import atexit
    import datetime
    import itertools
    import json
    import os
    import re
    import ssl
    import sys
    import uuid
    from time import time
    
    from jinja2 import Environment
    
    from ansible.module_utils.six import integer_types, PY3
    from ansible.module_utils.six.moves import configparser
    
    try:
        import argparse
    except ImportError:
        sys.exit('Error: This inventory script required "argparse" python module.  Please install it or upgrade to python-2.7')
    
    try:
>       from pyVmomi import vim, vmodl
E       ModuleNotFoundError: No module named 'pyVmomi'

contrib/inventory/vmware_inventory.py:52: ModuleNotFoundError

During handling of the above exception, another exception occurred:

    @pytest.fixture
    def vmware_inventory():
        inventory_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'contrib', 'inventory'))
    
        sys.path.append(inventory_dir)
    
        try:
>           import vmware_inventory

test/units/contrib/inventory/test_vmware_inventory.py:34: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    """
    $ jq '._meta.hostvars[].config' data.json | head
    {
      "alternateguestname": "",
      "instanceuuid": "5035a5cd-b8e8-d717-e133-2d383eb0d675",
      "memoryhotaddenabled": false,
      "guestfullname": "Red Hat Enterprise Linux 7 (64-bit)",
      "changeversion": "2016-05-16T18:43:14.977925Z",
      "uuid": "4235fc97-5ddb-7a17-193b-9a3ac97dc7b4",
      "cpuhotremoveenabled": false,
      "vpmcenabled": false,
      "firmware": "bios",
    """
    
    from __future__ import print_function
    
    import atexit
    import datetime
    import itertools
    import json
    import os
    import re
    import ssl
    import sys
    import uuid
    from time import time
    
    from jinja2 import Environment
    
    from ansible.module_utils.six import integer_types, PY3
    from ansible.module_utils.six.moves import configparser
    
    try:
        import argparse
    except ImportError:
        sys.exit('Error: This inventory script required "argparse" python module.  Please install it or upgrade to python-2.7')
    
    try:
        from pyVmomi import vim, vmodl
        from pyVim.connect import SmartConnect, Disconnect
    except ImportError:
>       sys.exit("ERROR: This inventory script required 'pyVmomi' Python module, it was not able to load it")
E       SystemExit: ERROR: This inventory script required 'pyVmomi' Python module, it was not able to load it

contrib/inventory/vmware_inventory.py:55: SystemExit

During handling of the above exception, another exception occurred:

    @pytest.fixture
    def vmware_inventory():
        inventory_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'contrib', 'inventory'))
    
        sys.path.append(inventory_dir)
    
        try:
            import vmware_inventory
        except BaseException as ex:
>           pytest.skip(ex)

test/units/contrib/inventory/test_vmware_inventory.py:36: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.9/site-packages/_pytest/outcomes.py:67: in __init__
    OutcomeException.__init__(self, msg=msg, pytrace=pytrace)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'Skipped' object has no attribute 'msg'") raised in repr()] Skipped object at 0x7fc24abc99a0>
msg = SystemExit("ERROR: This inventory script required 'pyVmomi' Python module, it was not able to load it")
pytrace = True

    def __init__(self, msg: Optional[str] = None, pytrace: bool = True) -> None:
        if msg is not None and not isinstance(msg, str):
            error_msg = (
                "{} expected string as 'msg' parameter, got '{}' instead.\n"
                "Perhaps you meant to use a mark?"
            )
>           raise TypeError(error_msg.format(type(self).__name__, type(msg).__name__))
E           TypeError: Skipped expected string as 'msg' parameter, got 'SystemExit' instead.
E           Perhaps you meant to use a mark?

/usr/lib/python3.9/site-packages/_pytest/outcomes.py:40: TypeError


<snippet>

List of failing tests:

ERROR test/units/contrib/inventory/test_vmware_inventory.py::test_show_returns_serializable_data
ERROR test/units/contrib/inventory/test_vmware_inventory.py::test_host_info_returns_single_host
ERROR test/units/contrib/inventory/test_vmware_inventory.py::test_show_host_returns_just_host
ERROR test/units/contrib/inventory/test_vmware_inventory.py::test_show_host_returns_serializable_data
ERROR test/units/contrib/inventory/test_vmware_inventory.py::test_show_list_returns_all_data
ERROR test/units/contrib/inventory/test_vmware_inventory.py::test_show_list_returns_serializable_data

Full build log attached

Comment 1 Charalampos Stratakis 2020-05-30 00:04:39 UTC
Pinning the Pytest version to 4 (we have a compat package provided at this point) works around the issue. Will fix it that way for the time being in order to build ansible.

Comment 2 Ben Cotton 2020-08-11 13:35:10 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 33 development cycle.
Changing version to 33.

Comment 3 Kevin Fenzi 2020-09-01 22:03:36 UTC
Sadly now the compat package won't work for ansible. ;( 

Since python-pytest-mock grew a dep on >= pytest 5

DEBUG util.py:621:   Problem: package python3-pytest4-4.6.11-2.fc33.noarch conflicts with python3.9dist(pytest) provided by python3-pytest-6.0.1-1.fc33.noarch
DEBUG util.py:621:    - package python3-pytest-mock-3.3.1-1.fc34.noarch requires python3.9dist(pytest) >= 5, but none of the providers can be installed

I'll try and get things working with pytest6.

Comment 4 Kevin Fenzi 2021-04-24 19:05:34 UTC
This was fixed a while back, sorry for not closing the bug. ;( 

I disabled the following tests that were failing with ptest6:

rm -f test/units/module_utils/facts/hardware/test_sunos_get_uptime_facts.py
rm -f test/units/modules/source_control/test_gitlab_runner.py
rm -f test/units/plugins/lookup/test_aws_secret.py
rm -f test/units/plugins/lookup/test_aws_ssm.py

I'll try and report them/track down why


Note You need to log in before you can comment on or make changes to this bug.