diff options
| author | Jason Kölker <jason@koelker.net> | 2013-02-27 11:01:50 -0600 |
|---|---|---|
| committer | Jason Kölker <jason@koelker.net> | 2013-02-28 18:49:44 -0600 |
| commit | 94bf63da0d4a0fc7775e65627e5908de8a17b29e (patch) | |
| tree | 1a2200ed59ff3034e173cc7871d9beb10d84450f /nova/tests | |
| parent | 05aaea1e1c104579c9d324fb767d18f021fb9496 (diff) | |
Fix deprecated network api
The rpc-only network api is deprecated in Grizzly, but it should still
be able to function.
Change summary:
* Remove update_cache kwyword argument to get_instance_network_info
* Add conductor_api keyword argument to get_instance_network_info
* Add blanket **kwargs for future compat to get_instance_network_info
* Pass instance['uuid'] as instance_id kwarg in _get_instance_nw_info
* Add conductor_api keyword argument to remove_fixed_ip_from_instance
and add_fixed_ip_to_instance
* Add blanket **kwargs for future compat to remove_fixed_ip_from_instance
and add_fixed_ip_to_instance
* Pass empty rxtx_factor in remove_fixed_ip_from_instance and
add_fixed_ip_to_instance for rpcapi compat
* Add blanket **kwargs for future compat to deallocate_for_instance
* Add conductor_api and security_groups to allocate_for_instance
* Add blanket **kwargs for future compat to allocate_for_instance
* Pass instance['uuid'] as instance_id kwarg in allocate_for_instance
Fix Bug 1134512
Change-Id: I6791df1bf1ac2456c5e83ec5ae47b0226409cf95
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/network/test_deprecated_api.py | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/nova/tests/network/test_deprecated_api.py b/nova/tests/network/test_deprecated_api.py new file mode 100644 index 000000000..48a7e4d6d --- /dev/null +++ b/nova/tests/network/test_deprecated_api.py @@ -0,0 +1,80 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2013 Openstack Foundation +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""Tests for the deprecated network API.""" + +import inspect + +from nova.network import api +from nova.network import api_deprecated +from nova import test + +# NOTE(jkoelker) These tests require that decorators in the apis +# "do the right thing" and set __name__ properly +# they should all be using functools.wraps or similar +# functionality. + + +def isapimethod(obj): + if inspect.ismethod(obj) and not obj.__name__.startswith('_'): + return True + return False + + +def discover_real_method(name, method): + if method.func_closure: + for closure in method.func_closure: + if closure.cell_contents.__name__ == name: + return closure.cell_contents + return method + + +class DeprecatedApiTestCase(test.TestCase): + def setUp(self): + super(DeprecatedApiTestCase, self).setUp() + self.api = api.API() + self.api_deprecated = api_deprecated.API() + + self.api_methods = inspect.getmembers(self.api, isapimethod) + + def test_api_compat(self): + methods = [m[0] for m in self.api_methods] + deprecated_methods = [getattr(self.api_deprecated, n, None) + for n in methods] + missing = [m[0] for m in zip(methods, deprecated_methods) + if m[1] is None] + + self.assertFalse(missing, + 'Deprecated api needs methods: %s' % missing) + + def test_method_signatures(self): + for name, method in self.api_methods: + deprecated_method = getattr(self.api_deprecated, name, None) + self.assertIsNotNone(deprecated_method, + 'Deprecated api has no method %s' % name) + + method = discover_real_method(name, method) + deprecated_method = discover_real_method(name, + deprecated_method) + + api_argspec = inspect.getargspec(method) + deprecated_argspec = inspect.getargspec(deprecated_method) + + # NOTE/TODO(jkoelker) Should probably handle the case where + # varargs/keywords are used. + self.assertEqual(api_argspec.args, deprecated_argspec.args, + "API method %s arguments differ" % name) |
