← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1747001] [NEW] Use of parse.urlencode with dict in nova/tests/unit/scheduler/client/test_report.py can result in unpredictable query strings and thus unreliable tests

 

Public bug reported:

In nova/tests/unit/scheduler/client/test_report.py there are several
tests which confirm the URLs that get passed to the placement service.
These create query strings by using code like:

        expected_url = '/allocation_candidates?%s' % parse.urlencode(
            {'resources': 'MEMORY_MB:1024,VCPU:1',
             'required': 'CUSTOM_TRAIT1',
             'limit': 1000})

This results in a query string that will have an unpredictable order.
Similarly, the code which is doing the actual query string creation is
using the same form.

Most of the time the results are the same, and the tests pass, but
sometimes they do not.

There are at least two potential ways to work around this:

* build the query strings using a sequence of tuples and set the 'doseq' param to urlencode to True. This will preserve order.
* Parse the expected_url's query params in the tests back to a dict and compare dicts

** Affects: nova
     Importance: Low
         Status: Triaged


** Tags: placement scheduler

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1747001

Title:
  Use of parse.urlencode with dict in
  nova/tests/unit/scheduler/client/test_report.py can result in
  unpredictable query strings and thus unreliable tests

Status in OpenStack Compute (nova):
  Triaged

Bug description:
  In nova/tests/unit/scheduler/client/test_report.py there are several
  tests which confirm the URLs that get passed to the placement service.
  These create query strings by using code like:

          expected_url = '/allocation_candidates?%s' % parse.urlencode(
              {'resources': 'MEMORY_MB:1024,VCPU:1',
               'required': 'CUSTOM_TRAIT1',
               'limit': 1000})

  This results in a query string that will have an unpredictable order.
  Similarly, the code which is doing the actual query string creation is
  using the same form.

  Most of the time the results are the same, and the tests pass, but
  sometimes they do not.

  There are at least two potential ways to work around this:

  * build the query strings using a sequence of tuples and set the 'doseq' param to urlencode to True. This will preserve order.
  * Parse the expected_url's query params in the tests back to a dict and compare dicts

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1747001/+subscriptions


Follow ups