Closed mirekdlugosz closed 4 years ago
We could just use .get
on if bz['status'] in OPEN_STATUSES:
so we avoid the problem, but I am afraid it is NOT a good idea, because if we go on that way we would be silencing those errors.
I think the best now would be going with implementing a proper serializer for BZ
from pydantic import BaseModel
class BZ(BaseModel):
id: int
status: str
target_milestone: str
...
bz = BZ(**data_from_bugzilla_api)
Then we would have a ValidationError
from pydantic.BaseModel
and then we can handle and log that error properly.
Anyway we need to debug the is_open_bz
function to see what is happening there.
After very fruitful debugging session with @rochacbruno , we were able to identify root cause:
in robottelo/issue_handlers/bugzilla.py
, try_from_cache
line 126 is:
return data or pytest.issue_data[issue]['data']
It's assumed that pytest.issue_data[issue]['data']
will raise KeyError exception, which in turn will execute line 129 which will get data about bugzilla.
Instead, pytest.issue_data[issue]
is:
{'data': {}, 'used_in': []}
This causes try_from_cache
to return empty dict instead of downloading data about missing bugzilla and returning that.
I will investigate further and raise PR.
@mirekdlugosz something like this?
def try_from_cache(issue, data=None):
"""Try to fetch issue from given data cache or previous loaded on pytest.
Arguments:
issue {str} -- The BZ reference e.g: BZ:123456
data {dict} -- Issue data indexed by <handler>:<number> or None
"""
try:
# issue must be passed in `data` argument or already fetched in pytest
result = data or pytest.issue_data[issue]['data']
except (KeyError, AttributeError):
result = None
# If not then call BZ API again
return result or get_single_bz(str(issue).partition(':')[-1])
@rochacbruno Something like that could work, but I decided to investigate why it works on master
, but fails on 6.6.z
. Turned out that robottelo/helpers.py
has some extra code in master, which I was able to track to 2d47a3e260565ebe7e4029a7537bf383252ebe39 - merged in #7465. I did see that before, but I ignored it as seemingly unrelated (at least commit title did not make it clear there are changes to bugzilla-gathering logic as well). After cherry-picking that commit to 6.6.z
, my affected test passed.
Raised #7687 with cherry-pick as fix for this.
tests/foreman/cli/test_hammer.py::HammerCommandsTestCase::test_positive_all_options
failed on automation-upgraded-6.6-all-tiers-rhel7 job #18 with following traceback:bz issue collector fails to collect data about BZ1666687. I can reproduce issue locally:
For whatever reason, it does work on current master branch. I do not see any significant changes between branches in relevant files.