summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJoe Gordon <jogo@cloudscaling.com>2013-04-03 16:54:08 -0700
committerJoe Gordon <jogo@cloudscaling.com>2013-04-04 01:10:46 +0000
commit820f43fc6113b39d55d13fbff8dca67eb954cfd9 (patch)
tree5da7c8ed41467cc76b93f012c18b56e661b20179 /nova/tests
parentf3d6e5ccdad2520ee4261835517e1db2c80b8f3a (diff)
Remove deprecated Grizzly code.
Now that Havana development has started remove code deprecated in Grizzly. Change-Id: Ie3e7611347c334c359dea98d759345b97c66c9c1
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/network/test_deprecated_api.py80
-rw-r--r--nova/tests/scheduler/test_host_filters.py16
-rw-r--r--nova/tests/scheduler/test_least_cost.py143
-rw-r--r--nova/tests/scheduler/test_weights.py14
4 files changed, 0 insertions, 253 deletions
diff --git a/nova/tests/network/test_deprecated_api.py b/nova/tests/network/test_deprecated_api.py
deleted file mode 100644
index 48a7e4d6d..000000000
--- a/nova/tests/network/test_deprecated_api.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# 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)
diff --git a/nova/tests/scheduler/test_host_filters.py b/nova/tests/scheduler/test_host_filters.py
index c977871d5..20906051f 100644
--- a/nova/tests/scheduler/test_host_filters.py
+++ b/nova/tests/scheduler/test_host_filters.py
@@ -256,22 +256,6 @@ class HostFiltersTestCase(test.TestCase):
for cls in classes:
self.class_map[cls.__name__] = cls
- def test_standard_filters_is_deprecated(self):
- info = {'called': False}
-
- def _fake_deprecated(*args, **kwargs):
- info['called'] = True
-
- self.stubs.Set(filters.LOG, 'deprecated', _fake_deprecated)
-
- filter_handler = filters.HostFilterHandler()
- filter_handler.get_matching_classes(
- ['nova.scheduler.filters.standard_filters'])
-
- self.assertTrue(info['called'])
- self.assertIn('AllHostsFilter', self.class_map)
- self.assertIn('ComputeFilter', self.class_map)
-
def test_all_filters(self):
# Double check at least a couple of known filters exist
self.assertIn('AllHostsFilter', self.class_map)
diff --git a/nova/tests/scheduler/test_least_cost.py b/nova/tests/scheduler/test_least_cost.py
deleted file mode 100644
index 8cee3b4d7..000000000
--- a/nova/tests/scheduler/test_least_cost.py
+++ /dev/null
@@ -1,143 +0,0 @@
-# Copyright 2011-2012 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 Least Cost functions.
-"""
-
-from oslo.config import cfg
-
-from nova import context
-from nova.scheduler import weights
-from nova.scheduler.weights import least_cost
-from nova import test
-from nova.tests.scheduler import fakes
-
-test_least_cost_opts = [
- cfg.FloatOpt('compute_fake_weigher1_weight',
- default=2.0,
- help='How much weight to give the fake_weigher1 function'),
- cfg.FloatOpt('compute_fake_weigher2_weight',
- default=1.0,
- help='How much weight to give the fake_weigher2 function'),
- ]
-
-CONF = cfg.CONF
-CONF.import_opt('least_cost_functions', 'nova.scheduler.weights.least_cost')
-CONF.import_opt('compute_fill_first_cost_fn_weight',
- 'nova.scheduler.weights.least_cost')
-CONF.register_opts(test_least_cost_opts)
-
-
-def compute_fake_weigher1(hostinfo, options):
- return hostinfo.free_ram_mb + 10000
-
-
-def compute_fake_weigher2(hostinfo, options):
- return hostinfo.free_ram_mb * 2
-
-
-class LeastCostTestCase(test.TestCase):
- def setUp(self):
- super(LeastCostTestCase, self).setUp()
- self.host_manager = fakes.FakeHostManager()
- self.weight_handler = weights.HostWeightHandler()
-
- def _get_weighed_host(self, hosts, weight_properties=None):
- weigher_classes = least_cost.get_least_cost_weighers()
- if weight_properties is None:
- weight_properties = {}
- return self.weight_handler.get_weighed_objects(weigher_classes,
- hosts, weight_properties)[0]
-
- def _get_all_hosts(self):
- ctxt = context.get_admin_context()
- fakes.mox_host_manager_db_calls(self.mox, ctxt)
- self.mox.ReplayAll()
- host_states = self.host_manager.get_all_host_states(ctxt)
- self.mox.VerifyAll()
- self.mox.ResetAll()
- return host_states
-
- def test_default_of_spread_first(self):
- # Default modifier is -1.0, so it turns out that hosts with
- # the most free memory win
- hostinfo_list = self._get_all_hosts()
-
- # host1: free_ram_mb=512
- # host2: free_ram_mb=1024
- # host3: free_ram_mb=3072
- # host4: free_ram_mb=8192
-
- # so, host1 should win:
- weighed_host = self._get_weighed_host(hostinfo_list)
- self.assertEqual(weighed_host.weight, 8192)
- self.assertEqual(weighed_host.obj.host, 'host4')
-
- def test_filling_first(self):
- self.flags(compute_fill_first_cost_fn_weight=1.0)
- hostinfo_list = self._get_all_hosts()
-
- # host1: free_ram_mb=-512
- # host2: free_ram_mb=-1024
- # host3: free_ram_mb=-3072
- # host4: free_ram_mb=-8192
-
- # so, host1 should win:
- weighed_host = self._get_weighed_host(hostinfo_list)
- self.assertEqual(weighed_host.weight, -512)
- self.assertEqual(weighed_host.obj.host, 'host1')
-
- def test_weighted_sum_provided_method(self):
- fns = ['nova.tests.scheduler.test_least_cost.compute_fake_weigher1',
- 'nova.tests.scheduler.test_least_cost.compute_fake_weigher2']
- self.flags(least_cost_functions=fns)
- hostinfo_list = self._get_all_hosts()
-
- # host1: free_ram_mb=512
- # host2: free_ram_mb=1024
- # host3: free_ram_mb=3072
- # host4: free_ram_mb=8192
-
- # [offset, scale]=
- # [10512, 11024, 13072, 18192]
- # [1024, 2048, 6144, 16384]
-
- # adjusted [ 2.0 * x + 1.0 * y] =
- # [22048, 24096, 32288, 52768]
-
- # so, host1 should win:
- weighed_host = self._get_weighed_host(hostinfo_list)
- self.assertEqual(weighed_host.weight, 52768)
- self.assertEqual(weighed_host.obj.host, 'host4')
-
- def test_weighted_sum_single_function(self):
- fns = ['nova.tests.scheduler.test_least_cost.compute_fake_weigher1']
- self.flags(least_cost_functions=fns)
- hostinfo_list = self._get_all_hosts()
-
- # host1: free_ram_mb=0
- # host2: free_ram_mb=1536
- # host3: free_ram_mb=3072
- # host4: free_ram_mb=8192
-
- # [offset, ]=
- # [10512, 11024, 13072, 18192]
- # adjusted [ 2.0 * x ]=
- # [21024, 22048, 26144, 36384]
-
- # so, host1 should win:
- weighed_host = self._get_weighed_host(hostinfo_list)
- self.assertEqual(weighed_host.weight, 36384)
- self.assertEqual(weighed_host.obj.host, 'host4')
diff --git a/nova/tests/scheduler/test_weights.py b/nova/tests/scheduler/test_weights.py
index 3ea6c945f..aa0f0c15f 100644
--- a/nova/tests/scheduler/test_weights.py
+++ b/nova/tests/scheduler/test_weights.py
@@ -37,20 +37,6 @@ class TestWeighedHost(test.TestCase):
self.assertEqual(len(classes), 1)
self.assertIn('RAMWeigher', class_names)
- def test_all_weighers_with_deprecated_config1(self):
- self.flags(compute_fill_first_cost_fn_weight=-1.0)
- classes = weights.all_weighers()
- class_names = [cls.__name__ for cls in classes]
- self.assertEqual(len(classes), 1)
- self.assertIn('_LeastCostWeigher', class_names)
-
- def test_all_weighers_with_deprecated_config2(self):
- self.flags(least_cost_functions=['something'])
- classes = weights.all_weighers()
- class_names = [cls.__name__ for cls in classes]
- self.assertEqual(len(classes), 1)
- self.assertIn('_LeastCostWeigher', class_names)
-
class RamWeigherTestCase(test.TestCase):
def setUp(self):