Merge lp:~soren/nova/include-test-extensions into lp:~hudson-openstack/nova/trunk

Proposed by Soren Hansen
Status: Merged
Approved by: Soren Hansen
Approved revision: 893
Merged at revision: 903
Proposed branch: lp:~soren/nova/include-test-extensions
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 51 lines (+26/-8)
2 files modified
nova/api/openstack/extensions.py (+11/-8)
nova/tests/api/openstack/extensions/__init__.py (+15/-0)
To merge this branch: bzr merge lp:~soren/nova/include-test-extensions
Reviewer Review Type Date Requested Status
Sandy Walsh (community) Approve
Dan Prince (community) Approve
Vish Ishaya (community) Approve
Jay Pipes (community) Approve
Review via email: mp+55146@code.launchpad.net

This proposal supersedes a proposal from 2011-03-25.

Commit message

Toss an __init__ in the test extensions dir. This gets it included in the tarball.

Make extensions code ignore modules whose name starts with '_'.

Warn if an extension doesn't define a class or factory by the right name.

Description of the change

Resubmitting, since it's suddenly more of an actual patch.

To post a comment you must log in.
Revision history for this message
Sandy Walsh (sandy-walsh) wrote : Posted in a previous version of this proposal

sure

review: Approve
Revision history for this message
Jay Pipes (jaypipes) wrote : Posted in a previous version of this proposal

lgtm.

review: Approve
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Posted in a previous version of this proposal
Download full text (86.3 KiB)

The attempt to merge lp:~soren/nova/include-test-extensions into lp:nova failed. Below is the output from the failed tests.

AccountsTest
    test_account_create OK
    test_account_delete OK
    test_account_update OK
    test_get_account OK
AdminAPITest
    test_admin_disabled OK
    test_admin_enabled OK
APITest
    test_exceptions_are_converted_to_faults OK
Test
    test_authorize_token OK
    test_authorize_user OK
    test_bad_token OK
    test_bad_user_bad_key OK
    test_bad_user_good_key OK
    test_no_user OK
    test_token_expiry OK
TestFunctional
    test_token_doesnotexist OK
    test_token_expiry OK
TestLimiter
    test_authorize_token OK
LimiterTest
    test_limiter_custom_max_limit OK
    test_limiter_limit_and_offset OK
    test_limiter_limit_medium OK
    test_limiter_limit_over_max OK
    test_limiter_limit_zero OK
    test_limiter_negative_limit OK
    test_limiter_negative_offset OK
    test_limiter_nothing OK
    test_limiter_offset_bad OK
    test_limiter_offset_blank OK
    test_limiter_offset_medium OK
    test_limiter_offset_over_max OK
    test_limiter_offset_zero OK
ActionExtensionTest
    test_extended_action ERROR
    test_invalid_action ERROR
    test_invalid_action_body ERROR
ExtensionControllerTest
    test_get_by_alias ERROR
    test_index ERROR
ExtensionManagerTest
    test_get_resources ERROR
ResourceExtensionTest
    test_get_resources OK
    test_get_resources_with_controller OK
    test_no_extension_present OK
ResponseExtensionTest
    test_get_resources_with_mgr ERROR
    test_get_resources_with_stub_mgr OK
TestFaults
    test_fault_parts OK
    test_raise ...

Revision history for this message
Soren Hansen (soren) wrote : Posted in a previous version of this proposal

:(

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Posted in a previous version of this proposal
Download full text (87.0 KiB)

The attempt to merge lp:~soren/nova/include-test-extensions into lp:nova failed. Below is the output from the failed tests.

AccountsTest
    test_account_create OK
    test_account_delete OK
    test_account_update OK
    test_get_account OK
AdminAPITest
    test_admin_disabled OK
    test_admin_enabled OK
APITest
    test_exceptions_are_converted_to_faults OK
Test
    test_authorize_token OK
    test_authorize_user OK
    test_bad_token OK
    test_bad_user_bad_key OK
    test_bad_user_good_key OK
    test_no_user OK
    test_token_expiry OK
TestFunctional
    test_token_doesnotexist OK
    test_token_expiry OK
TestLimiter
    test_authorize_token OK
LimiterTest
    test_limiter_custom_max_limit OK
    test_limiter_limit_and_offset OK
    test_limiter_limit_medium OK
    test_limiter_limit_over_max OK
    test_limiter_limit_zero OK
    test_limiter_negative_limit OK
    test_limiter_negative_offset OK
    test_limiter_nothing OK
    test_limiter_offset_bad OK
    test_limiter_offset_blank OK
    test_limiter_offset_medium OK
    test_limiter_offset_over_max OK
    test_limiter_offset_zero OK
ActionExtensionTest
    test_extended_action ERROR
    test_invalid_action ERROR
    test_invalid_action_body ERROR
ExtensionControllerTest
    test_get_by_alias ERROR
    test_index ERROR
ExtensionManagerTest
    test_get_resources ERROR
ResourceExtensionTest
    test_get_resources OK
    test_get_resources_with_controller OK
    test_no_extension_present OK
ResponseExtensionTest
    test_get_resources_with_mgr ERROR
    test_get_resources_with_stub_mgr OK
TestFaults
    test_fault_parts OK
    test_raise ...

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Posted in a previous version of this proposal
Download full text (87.2 KiB)

The attempt to merge lp:~soren/nova/include-test-extensions into lp:nova failed. Below is the output from the failed tests.

AccountsTest
    test_account_create OK
    test_account_delete OK
    test_account_update OK
    test_get_account OK
AdminAPITest
    test_admin_disabled OK
    test_admin_enabled OK
APITest
    test_exceptions_are_converted_to_faults OK
Test
    test_authorize_token OK
    test_authorize_user OK
    test_bad_token OK
    test_bad_user_bad_key OK
    test_bad_user_good_key OK
    test_no_user OK
    test_token_expiry OK
TestFunctional
    test_token_doesnotexist OK
    test_token_expiry OK
TestLimiter
    test_authorize_token OK
LimiterTest
    test_limiter_custom_max_limit OK
    test_limiter_limit_and_offset OK
    test_limiter_limit_medium OK
    test_limiter_limit_over_max OK
    test_limiter_limit_zero OK
    test_limiter_negative_limit OK
    test_limiter_negative_offset OK
    test_limiter_nothing OK
    test_limiter_offset_bad OK
    test_limiter_offset_blank OK
    test_limiter_offset_medium OK
    test_limiter_offset_over_max OK
    test_limiter_offset_zero OK
ActionExtensionTest
    test_extended_action ERROR
    test_invalid_action ERROR
    test_invalid_action_body ERROR
ExtensionControllerTest
    test_get_by_alias ERROR
    test_index ERROR
ExtensionManagerTest
    test_get_resources ERROR
ResourceExtensionTest
    test_get_resources OK
    test_get_resources_with_controller OK
    test_no_extension_present OK
ResponseExtensionTest
    test_get_resources_with_mgr ERROR
    test_get_resources_with_stub_mgr OK
TestFaults
    test_fault_parts OK
    test_raise ...

Revision history for this message
Soren Hansen (soren) wrote : Posted in a previous version of this proposal

This makes *no* sense to me.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Posted in a previous version of this proposal
Download full text (87.5 KiB)

The attempt to merge lp:~soren/nova/include-test-extensions into lp:nova failed. Below is the output from the failed tests.

AccountsTest
    test_account_create OK
    test_account_delete OK
    test_account_update OK
    test_get_account OK
AdminAPITest
    test_admin_disabled OK
    test_admin_enabled OK
APITest
    test_exceptions_are_converted_to_faults OK
Test
    test_authorize_token OK
    test_authorize_user OK
    test_bad_token OK
    test_bad_user_bad_key OK
    test_bad_user_good_key OK
    test_no_user OK
    test_token_expiry OK
TestFunctional
    test_token_doesnotexist OK
    test_token_expiry OK
TestLimiter
    test_authorize_token OK
LimiterTest
    test_limiter_custom_max_limit OK
    test_limiter_limit_and_offset OK
    test_limiter_limit_medium OK
    test_limiter_limit_over_max OK
    test_limiter_limit_zero OK
    test_limiter_negative_limit OK
    test_limiter_negative_offset OK
    test_limiter_nothing OK
    test_limiter_offset_bad OK
    test_limiter_offset_blank OK
    test_limiter_offset_medium OK
    test_limiter_offset_over_max OK
    test_limiter_offset_zero OK
ActionExtensionTest
    test_extended_action ERROR
    test_invalid_action ERROR
    test_invalid_action_body ERROR
ExtensionControllerTest
    test_get_by_alias ERROR
    test_index ERROR
ExtensionManagerTest
    test_get_resources ERROR
ResourceExtensionTest
    test_get_resources OK
    test_get_resources_with_controller OK
    test_no_extension_present OK
ResponseExtensionTest
    test_get_resources_with_mgr ERROR
    test_get_resources_with_stub_mgr OK
TestFaults
    test_fault_parts OK
    test_raise ...

Revision history for this message
Soren Hansen (soren) wrote : Posted in a previous version of this proposal

Stab in the dark: Added contents (license and copyright) to the file. Trying again.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Posted in a previous version of this proposal
Download full text (87.5 KiB)

The attempt to merge lp:~soren/nova/include-test-extensions into lp:nova failed. Below is the output from the failed tests.

AccountsTest
    test_account_create OK
    test_account_delete OK
    test_account_update OK
    test_get_account OK
AdminAPITest
    test_admin_disabled OK
    test_admin_enabled OK
APITest
    test_exceptions_are_converted_to_faults OK
Test
    test_authorize_token OK
    test_authorize_user OK
    test_bad_token OK
    test_bad_user_bad_key OK
    test_bad_user_good_key OK
    test_no_user OK
    test_token_expiry OK
TestFunctional
    test_token_doesnotexist OK
    test_token_expiry OK
TestLimiter
    test_authorize_token OK
LimiterTest
    test_limiter_custom_max_limit OK
    test_limiter_limit_and_offset OK
    test_limiter_limit_medium OK
    test_limiter_limit_over_max OK
    test_limiter_limit_zero OK
    test_limiter_negative_limit OK
    test_limiter_negative_offset OK
    test_limiter_nothing OK
    test_limiter_offset_bad OK
    test_limiter_offset_blank OK
    test_limiter_offset_medium OK
    test_limiter_offset_over_max OK
    test_limiter_offset_zero OK
ActionExtensionTest
    test_extended_action ERROR
    test_invalid_action ERROR
    test_invalid_action_body ERROR
ExtensionControllerTest
    test_get_by_alias ERROR
    test_index ERROR
ExtensionManagerTest
    test_get_resources ERROR
ResourceExtensionTest
    test_get_resources OK
    test_get_resources_with_controller OK
    test_no_extension_present OK
ResponseExtensionTest
    test_get_resources_with_mgr ERROR
    test_get_resources_with_stub_mgr OK
TestFaults
    test_fault_parts OK
    test_raise ...

Revision history for this message
termie (termie) wrote : Posted in a previous version of this proposal

neat bug

Revision history for this message
Soren Hansen (soren) wrote : Posted in a previous version of this proposal

Ok, I *swear* I ran the test suite before uploading this. I'm *almost*
sure I even ran it in the right directory.

Revision history for this message
Jay Pipes (jaypipes) wrote :

funny little bug. good patience tracking this down.

review: Approve
Revision history for this message
Sandy Walsh (sandy-walsh) wrote :

Is the try-except block still required? If so, which operation throws the AttributeError?

LOG.warn(_('Did not find expected name "%(ext_name)" in %(ext_path)s') % locals())

If load_source fails the entire service fails, correct? (not really related to this patch, but still a concern)

Personally I think I'd rather see an except Exception, e: to log the failure and press on. But others may disagree?

review: Needs Fixing
Revision history for this message
Soren Hansen (soren) wrote :

> Personally I think I'd rather see an except Exception, e: to log the failure
> and press on. But others may disagree?

Personally, to be frank, I don't give a crap. I'm just trying to get usable tarballs again. Just tell me what to do, I'll do it.

Revision history for this message
Vish Ishaya (vishvananda) wrote :

I vote for getting this in as is. Soren has been fighting with this one for far too long

review: Approve
Revision history for this message
Soren Hansen (soren) wrote :

> I vote for getting this in as is. Soren has been fighting with this one for
> far too long

Admittedly, most of the wait has been my fault, but thanks for the approve nonetheless.

Revision history for this message
Dan Prince (dan-prince) wrote :

Hey Soren,

Sorry that I missed this in my initial extensions work BTW. Didn't realize we needed the extra __init__.py files for tarball happiness, etc.

Anyway. Just tried your branch.

Got a pep8 error:

[dan.prince@dovetail nova-include-test-extensions]$ pep8 nova/api/openstack/extensions.py
nova/api/openstack/extensions.py:327:31: E201 whitespace after '{'

Revision history for this message
Dan Prince (dan-prince) wrote :

Otherwise this looks good to me. Anxious to have PPA working again too!

review: Approve
Revision history for this message
Sandy Walsh (sandy-walsh) wrote :

/me caves to the pressure :)

review: Approve
Revision history for this message
Soren Hansen (soren) wrote :

/me applies JIT pep8

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/api/openstack/extensions.py'
2--- nova/api/openstack/extensions.py 2011-03-21 18:00:39 +0000
3+++ nova/api/openstack/extensions.py 2011-03-28 20:23:27 +0000
4@@ -317,16 +317,19 @@
5 LOG.audit(_('Loading extension file: %s'), f)
6 mod_name, file_ext = os.path.splitext(os.path.split(f)[-1])
7 ext_path = os.path.join(self.path, f)
8- if file_ext.lower() == '.py':
9+ if file_ext.lower() == '.py' and not mod_name.startswith('_'):
10 mod = imp.load_source(mod_name, ext_path)
11 ext_name = mod_name[0].upper() + mod_name[1:]
12- try:
13- new_ext = getattr(mod, ext_name)()
14- self._check_extension(new_ext)
15- self.extensions[new_ext.get_alias()] = new_ext
16- except AttributeError as ex:
17- LOG.exception(_("Exception loading extension: %s"),
18- unicode(ex))
19+ new_ext_class = getattr(mod, ext_name, None)
20+ if not new_ext_class:
21+ LOG.warn(_('Did not find expected name '
22+ '"%(ext_name)" in %(file)s'),
23+ {'ext_name': ext_name,
24+ 'file': ext_path})
25+ continue
26+ new_ext = new_ext_class()
27+ self._check_extension(new_ext)
28+ self.extensions[new_ext.get_alias()] = new_ext
29
30
31 class ResponseExtension(object):
32
33=== added file 'nova/tests/api/openstack/extensions/__init__.py'
34--- nova/tests/api/openstack/extensions/__init__.py 1970-01-01 00:00:00 +0000
35+++ nova/tests/api/openstack/extensions/__init__.py 2011-03-28 20:23:27 +0000
36@@ -0,0 +1,15 @@
37+# vim: tabstop=4 shiftwidth=4 softtabstop=4
38+
39+# Copyright 2011 OpenStack LLC
40+#
41+# Licensed under the Apache License, Version 2.0 (the "License"); you may
42+# not use this file except in compliance with the License. You may obtain
43+# a copy of the License at
44+#
45+# http://www.apache.org/licenses/LICENSE-2.0
46+#
47+# Unless required by applicable law or agreed to in writing, software
48+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
49+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
50+# License for the specific language governing permissions and limitations
51+# under the License.