test_multi_cell_list fails in python 3.7

Bug #1807970 reported by Chris Dent
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Matt Riedemann

Bug Description

Generators used in multi cell list handling raise StopIteration, which is not something python 3.7 likes. Efforts to add python 3.7 testing to nova [1] revealed this (and similar for neighboring tests):

nova.tests.unit.compute.test_multi_cell_list.TestBaseClass.test_with_failing_cells
----------------------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    b'Traceback (most recent call last):'
    b' File "/mnt/share/cdentsrc/nova/nova/compute/multi_cell_list.py", line 101, in query_wrapper'
    b' for record in fn(ctx, *args, **kwargs):'
    b' File "/mnt/share/cdentsrc/nova/nova/compute/multi_cell_list.py", line 348, in do_query'
    b' **kwargs)'
    b' File "/mnt/share/cdentsrc/nova/nova/tests/unit/compute/test_multi_cell_list.py", line 356, in get_by_filters'
    b' raise exception.CellTimeout'
    b'nova.exception.CellTimeout: Timeout waiting for response from cell'
    b''
    b'During handling of the above exception, another exception occurred:'
    b''
    b'Traceback (most recent call last):'
    b' File "/mnt/share/cdentsrc/nova/nova/compute/multi_cell_list.py", line 108, in query_wrapper'
    b' raise StopIteration'
    b'StopIteration'
    b''
    b'The above exception was the direct cause of the following exception:'
    b''
    b'Traceback (most recent call last):'
    b' File "/mnt/share/cdentsrc/nova/.tox/py37/lib/python3.7/site-packages/mock/mock.py", line 1305, in patched'
    b' return func(*args, **keywargs)'
    b' File "/mnt/share/cdentsrc/nova/nova/tests/unit/compute/test_multi_cell_list.py", line 384, in test_with_failing_cells'
    b' self.assertEqual(50, len(list(result)))'
    b' File "/mnt/share/cdentsrc/nova/nova/compute/multi_cell_list.py", line 400, in get_records_sorted'
    b' item = next(feeder)'
    b' File "/mnt/share/cdentsrc/nova/.tox/py37/lib/python3.7/heapq.py", line 359, in merge'
    b' s[0] = next() # raises StopIteration when exhausted'
    b'RuntimeError: generator raised StopIteration'
    b''

According to pep 479 [2] the fix for this is to 'return' instead of 'raise StopIteration'.

[1] https://review.openstack.org/#/c/624055/
[2] https://www.python.org/dev/peps/pep-0479/#writing-backwards-and-forwards-compatible-code

Tags: testing
Changed in nova:
assignee: nobody → Chris Dent (cdent)
status: New → In Progress
Changed in nova:
assignee: Chris Dent (cdent) → Balazs Gibizer (balazs-gibizer)
Changed in nova:
assignee: Balazs Gibizer (balazs-gibizer) → Matt Riedemann (mriedem)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/624055
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=2ea552e019bd427b5b1709160a6ed7da9dd23fbd
Submitter: Zuul
Branch: master

commit 2ea552e019bd427b5b1709160a6ed7da9dd23fbd
Author: Chris Dent <email address hidden>
Date: Mon Dec 10 11:22:54 2018 +0000

    Add python 3.7 unit and functional tox jobs

    Without these, if you try to run tox -epy37,functional-py37 you'll
    get a successful tox run, but no actual tests are run, which is
    rather misleading. Given the generaly availability of python 3.7
    this is a bad thing.

    Running the tests under python 3.7 identified a few minor tests
    failures, also fixed here. Each is a result of a change in behavior in
    python 3.7:

    * printable unicode changes with a new Unicode 11-based unicodedata
      package
    * intentionally raising StopIteration in a generator is now considered a
      RuntimeError, 'return' should be used instead
    * an exception message is different beween python 3 and python 2, and the
      guard for it was mapping python 3.5 and 3.6 but not 3.7.

    zuul configuration is adjusted to add an experimental job for python 3.7
    unit. A functional test job is not added, because we don't have 3.6 yet,
    and we probably want to get through that first.

    Closes-Bug: #1807976
    Closes-Bug: #1807970
    Change-Id: I37779a12d3b36eb3dc7e2733d07fe0ed23ab3da6

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 19.0.0.0rc1

This issue was fixed in the openstack/nova 19.0.0.0rc1 release candidate.

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.