Don't mock internal heatclient calls

Bug #1626885 reported by Julie Pichon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo
Expired
Undecided
Unassigned

Bug Description

We're mocking internal calls inside heatclient ("heatclient.common.event_utils.get_events"), which can break us even though the interface didn't change. See https://review.openstack.org/#/c/374968/ for one example where it was fixed. A couple of other places where this is done should also be updated.

Previous description (for context):
---------------------
All the UT jobs, both on master and stable/newton, are failing with the following error:

2016-09-22 21:21:10.260701 | FAIL: tripleoclient.tests.test_utils.TestWaitForStackUtil.test_wait_for_stack_in_progress
2016-09-22 21:21:10.260734 | tags: worker-1
2016-09-22 21:21:10.260761 | ----------------------------------------------------------------------
2016-09-22 21:21:10.260777 | Traceback (most recent call last):
2016-09-22 21:21:10.260821 | File "/home/jenkins/workspace/gate-python-tripleoclient-python34/.tox/py34/lib/python3.4/site-packages/mock/mock.py", line 1305, in patched
2016-09-22 21:21:10.260842 | return func(*args, **keywargs)
2016-09-22 21:21:10.260888 | File "/home/jenkins/workspace/gate-python-tripleoclient-python34/tripleoclient/tests/test_utils.py", line 237, in test_wait_for_stack_in_progress
2016-09-22 21:21:10.260930 | utils.wait_for_stack_ready(self.mock_orchestration, 'stack')
2016-09-22 21:21:10.260971 | File "/home/jenkins/workspace/gate-python-tripleoclient-python34/tripleoclient/utils.py", line 281, in wait_for_stack_ready
2016-09-22 21:21:10.261004 | poll_period=5, marker=marker, out=out, nested_depth=2)
2016-09-22 21:21:10.261056 | File "/home/jenkins/workspace/gate-python-tripleoclient-python34/.tox/py34/lib/python3.4/site-packages/heatclient/common/event_utils.py", line 194, in poll_for_events
2016-09-22 21:21:10.261091 | events_log = utils.event_log_formatter(events, event_log_context)
2016-09-22 21:21:10.261142 | File "/home/jenkins/workspace/gate-python-tripleoclient-python34/.tox/py34/lib/python3.4/site-packages/heatclient/common/utils.py", line 172, in event_log_formatter
2016-09-22 21:21:10.261164 | rsrc_name = event_log_context.build_resource_name(event)
2016-09-22 21:21:10.261240 | File "/home/jenkins/workspace/gate-python-tripleoclient-python34/.tox/py34/lib/python3.4/site-packages/heatclient/common/utils.py", line 135, in build_resource_name
2016-09-22 21:21:10.261274 | stack_id = get_stack_id()
2016-09-22 21:21:10.261324 | File "/home/jenkins/workspace/gate-python-tripleoclient-python34/.tox/py34/lib/python3.4/site-packages/heatclient/common/utils.py", line 128, in get_stack_id
2016-09-22 21:21:10.261354 | for l in getattr(event, 'links', []):
2016-09-22 21:21:10.261373 | TypeError: 'Mock' object is not iterable

Example:
https://review.openstack.org/#/c/375125/1
http://logs.openstack.org/25/375125/1/check/gate-python-tripleoclient-python34/423218d/console.html#_2016-09-22_21_21_10_260701

Revision history for this message
Julie Pichon (jpichon) wrote :

I can recreate locally after recreating the tox environment.

Revision history for this message
mathieu bultel (mat-bultel) wrote :

AFAIK, the commit:
I0b959560ee7df194ec0f4a2b8a1605666fdec551
fix the issue.
A rebase should be enough, let me know if it still failed

Revision history for this message
Julie Pichon (jpichon) wrote :

Link for lazy people like me: https://review.openstack.org/#/c/374968/

I note that the internal call that was mocked is still used at least in 2 places above that change, though:

@mock.patch("heatclient.common.event_utils.get_events")
    def test_wait_for_stack_ready_failed(self, mock_el):

@mock.patch("heatclient.common.event_utils.get_events")
    def test_wait_for_stack_ready(self, mock_el):

I'll dramatically reduce the priority of this and keep it open to finish the mock refactoring. Thank you for your help matbu!!

Changed in tripleo:
importance: Critical → Low
milestone: newton-rc2 → ocata-1
assignee: Julie Pichon (jpichon) → nobody
Julie Pichon (jpichon)
description: updated
summary: - Client unit tests failing: "TypeError: 'Mock' object is not iterable"
+ Don't mock internal heatclient calls
tags: added: low-hanging-fruit
Steven Hardy (shardy)
Changed in tripleo:
milestone: ocata-1 → ocata-2
Changed in tripleo:
milestone: ocata-2 → ocata-3
Dougal Matthews (d0ugal)
Changed in tripleo:
milestone: ocata-3 → pike-1
Changed in tripleo:
milestone: pike-1 → pike-2
Changed in tripleo:
milestone: pike-2 → pike-3
Changed in tripleo:
milestone: pike-3 → pike-rc1
Changed in tripleo:
milestone: pike-rc1 → queens-1
Changed in tripleo:
milestone: queens-1 → queens-2
Changed in tripleo:
milestone: queens-2 → queens-3
Changed in tripleo:
milestone: queens-3 → queens-rc1
Changed in tripleo:
milestone: queens-rc1 → rocky-1
Changed in tripleo:
milestone: rocky-1 → rocky-2
Changed in tripleo:
milestone: rocky-2 → rocky-3
Changed in tripleo:
milestone: rocky-3 → rocky-rc1
Changed in tripleo:
milestone: rocky-rc1 → stein-1
Changed in tripleo:
milestone: stein-1 → stein-2
Revision history for this message
Emilien Macchi (emilienm) wrote : Cleanup EOL bug report

This is an automated cleanup. This bug report has been closed because it
is older than 18 months and there is no open code change to fix this.
After this time it is unlikely that the circumstances which lead to
the observed issue can be reproduced.

If you can reproduce the bug, please:
* reopen the bug report (set to status "New")
* AND add the detailed steps to reproduce the issue (if applicable)
* AND leave a comment "CONFIRMED FOR: <RELEASE_NAME>"
  Only still supported release names are valid (FUTURE, PIKE, QUEENS, ROCKY, STEIN).
  Valid example: CONFIRMED FOR: FUTURE

Changed in tripleo:
importance: Low → Undecided
status: Triaged → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.