Incorrect datatype for Python 3 in api-samples functional test

Bug #1632856 reported by Ed Leafe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Ed Leafe

Bug Description

The nova/tests/functional/api_sample_tests/test_servers.py contains the ServersSampleBase class, and in its class definition creates user data by base64 encoding a string. However, this will not work in Python 3, as the base64.b64encode() method requires bytes, not a string.

This can be seen by simply running 'tox -e functional' under Python 3, which then emits a series of errors, most of which look like:

Failed to import test module: nova.tests.functional.api_sample_tests.test_servers
Traceback (most recent call last):
  File "/home/ed/projects/nova/.tox/functional/lib/python3.4/site-packages/unittest2/loader.py", line 456, in _find_test_path
    module = self._get_module_from_name(name)
  File "/home/ed/projects/nova/.tox/functional/lib/python3.4/site-packages/unittest2/loader.py", line 395, in _get_module_from_name
    __import__(name)
  File "/home/ed/projects/nova/nova/tests/functional/api_sample_tests/test_servers.py", line 24, in <module>
    class ServersSampleBase(api_sample_base.ApiSampleTestBaseV21):
  File "/home/ed/projects/nova/nova/tests/functional/api_sample_tests/test_servers.py", line 29, in ServersSampleBase
    user_data = base64.b64encode(user_data_contents)
  File "/home/ed/projects/nova/.tox/functional/lib/python3.4/base64.py", line 62, in b64encode
    encoded = binascii.b2a_base64(s)[:-1]
TypeError: 'str' does not support the buffer interface

This was reported in https://bugs.launchpad.net/nova/+bug/1632521, and a fix was issued that simply forced tox to use py27.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/385686

Changed in nova:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/385686
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=a2d7ebd39b99db9c5728e2a256568b8bbbc4734f
Submitter: Jenkins
Branch: master

commit a2d7ebd39b99db9c5728e2a256568b8bbbc4734f
Author: EdLeafe <email address hidden>
Date: Wed Oct 12 20:55:40 2016 +0000

    Corrects the type of a base64 encoded string

    The nova/tests/functional/api_sample_tests/test_servers.py contains the
    ServersSampleBase class, and in its class definition creates a
    'user_data' attribute by base64 encoding a string. However, this will
    not work in Python 3, as the base64.b64encode() method requires bytes,
    not a string. As a result, importing the test class fails and no tests
    get run.

    Note that this change doesn't fix all tests to work under Python 3; it
    simply fixes the bug that prevents the tests from running at all under
    Python 3.

    Closes-Bug: #1632856

    Change-Id: I35a7b02132bed0387a173b339f6204bf0e3269de

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

This issue was fixed in the openstack/nova 15.0.0.0b2 development milestone.

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.