ansible-collections / ansible-collections/google.cloud

Rpmbuild with unitests

Open Beginner friendly
#629 2 comments 0 reactions 0 assignees View on GitHub
stale
Dominant language
Python
Stars
105
Forks
144
Avg merge
5d 10h
Merged PRs (30d)
4

Description

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
- Bug Report

##### COMPONENT NAME
Unitest

##### ANSIBLE VERSION

```paste below
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

```paste below
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

```paste below
+ 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 =

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 =

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 =

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 =

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 =

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)
```

Contributor guide

Open the contributing guide

Research direction

Start with tests/unit/plugins/test_gcp_utils.py and the five failing GCPRequestDifferenceTestCase cases shown in the traceback. Run ansible-test units with the Python 3.12 interpreter, then verify that all 17 tests pass and the rpmbuild -ba ansible-collection-google-cloud.spec command completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, testing
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.