]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Check for installed cinder in filter tests.
authorJohn Griffith <john.griffith@solidfire.com>
Tue, 22 Jan 2013 04:50:20 +0000 (21:50 -0700)
committerJohn Griffith <john.griffith@solidfire.com>
Thu, 24 Jan 2013 18:25:41 +0000 (11:25 -0700)
Some of the filter tests require that the cinder pkg is
installed on the system, specifically cinder.egg-info/entry_points.

This change check that the egg-info directory exists in the root
cinder directory and determines whether to skip or not.

Change-Id: I36145f170e802aed5dfae8eec4684e60ad3d6f2c

cinder/tests/scheduler/test_capacity_weigher.py
cinder/tests/scheduler/test_filter_scheduler.py
cinder/tests/scheduler/test_host_filters.py
cinder/tests/utils.py

index 471364f9c47bfddbf1cba230e9519254bc6679c7..a569ff2552741bcd1c62e7134ae2bbc706635421 100644 (file)
@@ -20,6 +20,7 @@ from cinder import context
 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):
@@ -45,6 +46,8 @@ 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()
 
@@ -58,6 +61,8 @@ class CapacityWeigherTestCase(test.TestCase):
         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()
@@ -72,6 +77,8 @@ class CapacityWeigherTestCase(test.TestCase):
         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()
index 6f56575f76744e33c47cc7bc66c12e4ce0ed04c9..064c2746183a3fa159a64e930a0d52ff3d84fe19 100644 (file)
 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):
@@ -37,6 +36,8 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
 
     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.
@@ -54,6 +55,8 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
         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."""
@@ -78,6 +81,8 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
                           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."""
index 5bcffd63c082e7bce8bddfa8eeec4609bcba547f..76b808b6a07901e12d10e31e3bd0ed0b2781184b 100644 (file)
@@ -25,6 +25,7 @@ from cinder.openstack.common import jsonutils
 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
 
 
@@ -75,6 +76,8 @@ class HostFiltersTestCase(test.TestCase):
             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']()
@@ -86,6 +89,8 @@ class HostFiltersTestCase(test.TestCase):
                                     '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']()
index 5b9086b7542afb4a29693bdc63221508a9c283e3..221e6b097b44450da8049dabf2ab782776a96e46 100644 (file)
 #    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