functional test utf-encode-decode issues with python3
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-manilaclient |
Fix Released
|
Undecided
|
Tom Barron |
Bug Description
Functional tests for python-manilaclient include tests to list shares and share_networks by "inexact" unicode name and description. These take unicode values for 'name' and 'description' fields, and substrings of these for filter values, create the resource, and then list the resource based on the filters.
The tests use tempest.lib.client exec routine to to the manila command that creates the resource (share or share-network) with unicode name and description fields.
When run under python3, the creation fails with stack traces like the following:
manilaclient.
-------
Captured traceback:
~~~~~~~~~~~~~~~~~~~
b'Traceback (most recent call last):'
b' File "/opt/stack/
b' cleanup_
b' File "/opt/stack/
b' share = client.
b' File "/opt/stack/
b' share_raw = self.manila(cmd, microversion=
b' File "/opt/stack/
b" 'manila', action, flags, params, fail_ok, merge_stderr)"
b' File "/opt/stack/
b' self.cli_dir, prefix=
b' File "/opt/stack/
b" proc = subprocess.
b' File "/usr/lib/
b' restore_signals, start_new_session)'
b' File "/usr/lib/
b' restore_signals, start_new_session, preexec_fn)'
b"UnicodeEn
b''
Within tempest/lib/cli subprocess.
I tried supplying a "encoding='utf-8'" argument to subprocess.Popen() to no effect.
We can byte-encode the "action" string as utf-8 and avoid the UnicodeEncodeError but then the wrong command is passed to the manila command to create the share or share network. They get created, but with unintended name and description values. To make a byte-encoded transport over the pipe work correctly the receiving end would have to know that it's getting bytes and decode back to UTF-8 strings before running the manila command.
description: | updated |
Changed in python-manilaclient: | |
assignee: | nobody → Goutham Pacha Ravi (gouthamr) |
status: | New → In Progress |
Changed in python-manilaclient: | |
assignee: | Goutham Pacha Ravi (gouthamr) → Tom Barron (tpb) |
Reviewed: https:/ /review. openstack. org/630462 /git.openstack. org/cgit/ openstack/ python- manilaclient/ commit/ ?id=b955ac9064b 15d00e8966dda74 5814c146c8af01
Committed: https:/
Submitter: Zuul
Branch: master
commit b955ac9064b15d0 0e8966dda745814 c146c8af01
Author: Goutham Pacha Ravi <email address hidden>
Date: Wed Jan 16 16:31:21 2019 -0800
[Python3] Fix python3 bugs in code
- The BaseException class no longer has a "message"
attribute in python 3 [1]. On the contrary, the
string representation of an Exception object will
print all the exception args in all supported
python versions, so use that instead.
- Functional tests were run with a specific locale,
remove those annotations so we can handle unicode
encoding and decoding in python3 envs.
- Cleanup errors were not being handled correctly,
cleanup the code so we don't have spurious failures.
- In python3, dict.keys() gives you a view for lazy
loading, so convert occurrences to lists as expected
in our functional tests.
- Start capturing STDOUT and STDERR in tox envs to
enable troubleshooting.
Co-Authored-By: Goutham Pacha Ravi <email address hidden> 3fbd298e1957419 5f2d663c6f4 /www.python. org/dev/ peps/pep- 0352/#transitio n-plan
Closes-Bug: #1811627
Closes-Bug: #1811516
Change-Id: Idaa2fb9b60451b
[1] https:/