from cinder.openstack.common.scheduler.weights import HostWeightHandler
from cinder import test
from cinder.tests.scheduler import fakes
+from cinder.tests import utils as test_utils
class CapacityWeigherTestCase(test.TestCase):
self.mox.ResetAll()
return host_states
+ @test.skip_if(not test_utils.is_cinder_installed(),
+ 'Test requires Cinder installed')
def test_default_of_spreading_first(self):
hostinfo_list = self._get_all_hosts()
self.assertEqual(weighed_host.weight, 921.0)
self.assertEqual(weighed_host.obj.host, 'host1')
+ @test.skip_if(not test_utils.is_cinder_installed(),
+ 'Test requires Cinder installed')
def test_capacity_weight_multiplier1(self):
self.flags(capacity_weight_multiplier=-1.0)
hostinfo_list = self._get_all_hosts()
self.assertEqual(weighed_host.weight, -190.0)
self.assertEqual(weighed_host.obj.host, 'host4')
+ @test.skip_if(not test_utils.is_cinder_installed(),
+ 'Test requires Cinder installed')
def test_capacity_weight_multiplier2(self):
self.flags(capacity_weight_multiplier=2.0)
hostinfo_list = self._get_all_hosts()
Tests For Filter Scheduler.
"""
-import mox
-
from cinder import context
from cinder import exception
+from cinder import test
+
from cinder.openstack.common.scheduler import weights
-from cinder.scheduler import driver
from cinder.scheduler import filter_scheduler
-from cinder.scheduler import host_manager
from cinder.tests.scheduler import fakes
from cinder.tests.scheduler import test_scheduler
+from cinder.tests import utils as test_utils
def fake_get_filtered_hosts(hosts, filter_properties):
driver_cls = filter_scheduler.FilterScheduler
+ @test.skip_if(not test_utils.is_cinder_installed(),
+ 'Test requires Cinder installed (try setup.py develop')
def test_create_volume_no_hosts(self):
"""
Ensure empty hosts & child_zones result in NoValidHosts exception.
self.assertRaises(exception.NoValidHost, sched.schedule_create_volume,
fake_context, request_spec, None)
+ @test.skip_if(not test_utils.is_cinder_installed(),
+ 'Test requires Cinder installed (try setup.py develop')
def test_create_volume_non_admin(self):
"""Test creating an instance locally using run_instance, passing
a non-admin context. DB actions should work."""
fake_context, request_spec, None)
self.assertTrue(self.was_admin)
+ @test.skip_if(not test_utils.is_cinder_installed(),
+ 'Test requires Cinder installed (try setup.py develop')
def test_schedule_happy_day(self):
"""Make sure there's nothing glaringly wrong with _schedule()
by doing a happy day pass through."""
from cinder.openstack.common.scheduler import filters
from cinder import test
from cinder.tests.scheduler import fakes
+from cinder.tests import utils as test_utils
from cinder import utils
return ret_value
self.stubs.Set(utils, 'service_is_up', fake_service_is_up)
+ @test.skip_if(not test_utils.is_cinder_installed(),
+ 'Test requires Cinder installed')
def test_capacity_filter_passes(self):
self._stub_service_is_up(True)
filt_cls = self.class_map['CapacityFilter']()
'service': service})
self.assertTrue(filt_cls.host_passes(host, filter_properties))
+ @test.skip_if(not test_utils.is_cinder_installed(),
+ 'Test requires Cinder installed')
def test_capacity_filter_fails(self):
self._stub_service_is_up(True)
filt_cls = self.class_map['CapacityFilter']()
# License for the specific language governing permissions and limitations
#
+import os
+
import cinder.context
-import cinder.db
-import cinder.flags
FLAGS = cinder.flags.FLAGS
def get_test_admin_context():
return cinder.context.get_admin_context()
+
+
+def is_cinder_installed():
+ if os.path.exists('../../cinder.cinder.egg-info'):
+ return True
+ else:
+ return False