https://review.openstack.org/468020 broke unit tests for python-openstackclient

Bug #1694937 reported by Javier Peña
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
os-client-config
Invalid
Undecided
Unassigned
python-openstackclient
Fix Released
Undecided
Unassigned

Bug Description

Trying to run python-openstackclient unit tests using the latest os-client-config commit instead of the current version in upper-constraints (1.27.0) results in the following error:

DEBUG: "file.yaml" defines a cloud named "qaz", but OS_CLOUD_NAME is also set to "qaz". Please rename either your environment based cloud, or one of your file-based clouds.
DEBUG: END return value: 1
DEBUG: }}}
DEBUG: Traceback (most recent call last):
DEBUG: File "/usr/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched
DEBUG: return func(*args, **keywargs)
DEBUG: File "/builddir/build/BUILD/python-openstackclient-3.11.1.dev27/openstackclient/tests/unit/integ/cli/test_shell.py", line 414, in test_shell_args_precedence_1
DEBUG: self.assertEqual(len(self.requests_mock.request_history), 2)
DEBUG: File "/usr/lib/python2.7/site-packages/testtools/testcase.py", line 350, in assertEqual
DEBUG: self.assertThat(observed, matcher, message)
DEBUG: File "/usr/lib/python2.7/site-packages/testtools/testcase.py", line 435, in assertThat
DEBUG: raise mismatch_error
DEBUG: testtools.matchers._impl.MismatchError: 0 != 2

You can see a full output at https://trunk.rdoproject.org/centos7-master-head/d0/34/d034b980ab03bbd50d31ef8bd439bc80a91a7d77_b81ca2c8/rpmbuild.log

Checking all commits, it was introduced by https://review.openstack.org/468020.

Revision history for this message
Javier Peña (jpena-c) wrote :

I've been doing some more research on the bug. The issue is that class OpenStackConfig from [1] is initialized twice, at [2] and [3], with OS_CLOUD_NAME passed as an environment variable.

The first time it is initialized, the configuration gets inside self.cloud_config, and since the environment variable is still around, the second time it fails in [4].

We could either remove the check in [4] or make the OpenStackConfig init code resilient to multiple initializations. I'm not familiar enough with the codebase to decide which option is better.

[1] - https://github.com/openstack/os-client-config/blob/990cfa3ce24d0a92c7578b52ae1fea02d69f7e87/os_client_config/config.py#L177
[2] - https://github.com/openstack/python-openstackclient/blob/ef99f444628282d06feae04514bd2a6328d87b93/openstackclient/shell.py#L137
[3] - https://github.com/openstack/python-openstackclient/blob/ef99f444628282d06feae04514bd2a6328d87b93/openstackclient/shell.py#L146-L152
[4] - https://github.com/openstack/os-client-config/blob/990cfa3ce24d0a92c7578b52ae1fea02d69f7e87/os_client_config/config.py#L250-L256

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

See also bug 1703783

Revision history for this message
Akihiro Motoki (amotoki) wrote :
Changed in python-openstackclient:
status: New → Fix Released
Revision history for this message
Akihiro Motoki (amotoki) wrote :

Regarding os-client-config, this is the valid behavior and the usage in OSC is special. It should be handled in OSC side.
Mark it as Invalid in os-client-config side.

Changed in os-client-config:
status: New → Invalid
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.