ansible-collections / google.cloud

GCP Ansible Collection https://galaxy.ansible.com/google/cloud
https://cloud.google.com
GNU General Public License v3.0
98 stars 130 forks source link

Rpmbuild with unitests #629

Open volga629-1 opened 6 months ago

volga629-1 commented 6 months ago

Hello Everyone, I am trying to generate RPM with UNItests option and it failing, please see error bellow.

SUMMARY

Uni tests with RPM build is failing

ISSUE TYPE
COMPONENT NAME

Unitest

ANSIBLE VERSION
 rpm -qa | grep ansible
ansible-srpm-macros-1-12.fc39.noarch
ansible-core-2.16.5-1.fc39.noarch
ansible-packaging-1-12.fc39.noarch
ansible-packaging-tests-1-12.fc39.noarch
COLLECTION VERSION
1.3.0
OS / ENVIRONMENT
uname -a
Linux canldev01-fedora39 6.7.6-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Feb 23 18:27:29 UTC 2024 x86_64 GNU/Linux
STEPS TO REPRODUCE

rpmbuild -ba ansible-collection-google-cloud.spec

EXPECTED RESULTS

Build will be completed

ACTUAL RESULTS
+ cd ansible-collection-google-cloud-1.3.0
+ /usr/lib/rpm/ansible_collection.py test -- --python-interpreter /usr/bin/python3 --local
Loading collection metadata from /home/volga629/rpmbuild/BUILD/ansible-collection-google-cloud-1.3.0/galaxy.yml
Running: ('ansible-test', 'units', '--python-interpreter', '/usr/bin/python3', '--local')

Unit test controller with Python 3.12
============================= test session starts ==============================
platform linux -- Python 3.12.2, pytest-7.3.2, pluggy-1.2.0
rootdir: /tmp/tmppuyiwjyz/ansible_collections/google/cloud
configfile: ../../../../../usr/lib/python3.12/site-packages/ansible_test/_data/pytest/config/default.ini
plugins: mock-3.11.1, xdist-3.3.1
created: 4/4 workers
4 workers [17 items]

..........F.FF.FF                                                        [100%]
=================================== FAILURES ===================================
_______ GCPRequestDifferenceTestCase.test_arrays_strings_with_difference _______
[gw3] linux -- Python 3.12.2 /usr/bin/python3

self = <ansible_collections.google.cloud.tests.unit.plugins.test_gcp_utils.GCPRequestDifferenceTestCase testMethod=test_arrays_strings_with_difference>

    def test_arrays_strings_with_difference(self):
        value1 = {
            "foo": [
                "baz",
                "bar",
            ]
        }

        value2 = {"foo": ["baz", "hello"]}
        difference = {
            "foo": [
                "bar",
            ]
        }
        request1 = GcpRequest(value1)
        request2 = GcpRequest(value2)
>       self.assertNotEquals(request1, request2)
E       AttributeError: 'GCPRequestDifferenceTestCase' object has no attribute 'assertNotEquals'. Did you mean: 'assertNotEqual'?

tests/unit/plugins/test_gcp_utils.py:126: AttributeError
______________ GCPRequestDifferenceTestCase.test_simple_different ______________
[gw2] linux -- Python 3.12.2 /usr/bin/python3

self = <ansible_collections.google.cloud.tests.unit.plugins.test_gcp_utils.GCPRequestDifferenceTestCase testMethod=test_simple_different>

    def test_simple_different(self):
        value1 = {"foo": "bar", "test": "original"}
        value2 = {"foo": "bar", "test": "different"}
        difference = {"test": "original"}
        request1 = GcpRequest(value1)
        request2 = GcpRequest(value2)
>       self.assertNotEquals(request1, request2)
E       AttributeError: 'GCPRequestDifferenceTestCase' object has no attribute 'assertNotEquals'. Did you mean: 'assertNotEqual'?

tests/unit/plugins/test_gcp_utils.py:88: AttributeError
________ GCPRequestDifferenceTestCase.test_arrays_dicts_with_difference ________
[gw1] linux -- Python 3.12.2 /usr/bin/python3

self = <ansible_collections.google.cloud.tests.unit.plugins.test_gcp_utils.GCPRequestDifferenceTestCase testMethod=test_arrays_dicts_with_difference>

    def test_arrays_dicts_with_difference(self):
        value1 = {"foo": [{"test": "value", "foo": "bar"}, {"different": "dict"}]}
        value2 = {
            "foo": [
                {"test": "value2", "foo": "bar2"},
            ]
        }
        difference = {"foo": [{"test": "value", "foo": "bar"}]}
        request1 = GcpRequest(value1)
        request2 = GcpRequest(value2)
>       self.assertNotEquals(request1, request2)
E       AttributeError: 'GCPRequestDifferenceTestCase' object has no attribute 'assertNotEquals'. Did you mean: 'assertNotEqual'?

tests/unit/plugins/test_gcp_utils.py:144: AttributeError
____ GCPRequestDifferenceTestCase.test_nested_dictionaries_with_difference _____
[gw0] linux -- Python 3.12.2 /usr/bin/python3

self = <ansible_collections.google.cloud.tests.unit.plugins.test_gcp_utils.GCPRequestDifferenceTestCase testMethod=test_nested_dictionaries_with_difference>

    def test_nested_dictionaries_with_difference(self):
        value1 = {"foo": {"quiet": {"tree": "test"}, "bar": "baz"}, "test": "original"}
        value2 = {"foo": {"quiet": {"tree": "baz"}, "bar": "hello"}, "test": "original"}
        difference = {"foo": {"quiet": {"tree": "test"}, "bar": "baz"}}
        request1 = GcpRequest(value1)
        request2 = GcpRequest(value2)
>       self.assertNotEquals(request1, request2)
E       AttributeError: 'GCPRequestDifferenceTestCase' object has no attribute 'assertNotEquals'. Did you mean: 'assertNotEqual'?

tests/unit/plugins/test_gcp_utils.py:102: AttributeError
_______ GCPRequestDifferenceTestCase.test_dicts_boolean_with_difference ________
[gw1] linux -- Python 3.12.2 /usr/bin/python3

self = <ansible_collections.google.cloud.tests.unit.plugins.test_gcp_utils.GCPRequestDifferenceTestCase testMethod=test_dicts_boolean_with_difference>

    def test_dicts_boolean_with_difference(self):
        value1 = {
            "foo": True,
            "bar": False,
            "baz": True,
            "qux": False,
        }

        value2 = {
            "foo": True,
            "bar": False,
            "baz": False,
            "qux": True,
        }

        difference = {
            "baz": True,
            "qux": True,
        }
        request1 = GcpRequest(value1)
        request2 = GcpRequest(value2)
>       self.assertNotEquals(request1, request2)
E       AttributeError: 'GCPRequestDifferenceTestCase' object has no attribute 'assertNotEquals'. Did you mean: 'assertNotEqual'?

tests/unit/plugins/test_gcp_utils.py:168: AttributeError
- generated xml file: /tmp/tmppuyiwjyz/ansible_collections/google/cloud/tests/output/junit/python3.12-controller-units.xml -
=========================== short test summary info ============================
FAILED tests/unit/plugins/test_gcp_utils.py::GCPRequestDifferenceTestCase::test_arrays_strings_with_difference - AttributeError: 'GCPRequestDifferenceTestCase' object has no attribute 'ass...
FAILED tests/unit/plugins/test_gcp_utils.py::GCPRequestDifferenceTestCase::test_simple_different - AttributeError: 'GCPRequestDifferenceTestCase' object has no attribute 'ass...
FAILED tests/unit/plugins/test_gcp_utils.py::GCPRequestDifferenceTestCase::test_arrays_dicts_with_difference - AttributeError: 'GCPRequestDifferenceTestCase' object has no attribute 'ass...
FAILED tests/unit/plugins/test_gcp_utils.py::GCPRequestDifferenceTestCase::test_nested_dictionaries_with_difference - AttributeError: 'GCPRequestDifferenceTestCase' object has no attribute 'ass...
FAILED tests/unit/plugins/test_gcp_utils.py::GCPRequestDifferenceTestCase::test_dicts_boolean_with_difference - AttributeError: 'GCPRequestDifferenceTestCase' object has no attribute 'ass...
========================= 5 failed, 12 passed in 1.00s =========================
FATAL: Command "pytest -r a -n auto --color yes -p no:cacheprovider -c /usr/lib/python3.12/site-packages/ansible_test/_data/pytest/config/default.ini --junit-xml /tmp/tmppuyiwjyz/ansible_collections/google/cloud/tests/output/junit/python3.12-controller-units.xml --strict-markers --rootdir /tmp/tmppuyiwjyz/ansible_collections/google/cloud --confcutdir /tmp/tmppuyiwjyz/ansible_collections/google/cloud tests/unit/plugins/test_gcp_utils.py" returned exit status 1.
Command '('ansible-test', 'units', '--python-interpreter', '/usr/bin/python3', '--local')' returned non-zero exit status 1.
error: Bad exit status from /var/tmp/rpm-tmp.H0FSgs (%check)

RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.H0FSgs (%check)
leegarrett commented 5 months ago

I can confirm that the google.cloud unit tests fail on Debian sid, too. Reason is the switch from Python 3.11 to 3.12 in the last couple of days. Would be nice to fix the unit tests so that it works again. CI logs: https://salsa.debian.org/python-team/packages/ansible/-/jobs/5888569