merge
This commit is contained in:
		
							
								
								
									
										1
									
								
								Authors
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								Authors
									
									
									
									
									
								
							| @@ -15,6 +15,7 @@ Eldar Nugaev <enugaev@griddynamics.com> | |||||||
| Eric Day <eday@oddments.org> | Eric Day <eday@oddments.org> | ||||||
| Ewan Mellor <ewan.mellor@citrix.com> | Ewan Mellor <ewan.mellor@citrix.com> | ||||||
| Hisaki Ohara <hisaki.ohara@intel.com> | Hisaki Ohara <hisaki.ohara@intel.com> | ||||||
|  | Ilya Alekseyev <ialekseev@griddynamics.com> | ||||||
| Jay Pipes <jaypipes@gmail.com> | Jay Pipes <jaypipes@gmail.com> | ||||||
| Jesse Andrews <anotherjesse@gmail.com> | Jesse Andrews <anotherjesse@gmail.com> | ||||||
| Joe Heck <heckj@mac.com> | Joe Heck <heckj@mac.com> | ||||||
|   | |||||||
| @@ -285,6 +285,5 @@ DEFINE_string('image_service', 'nova.image.s3.S3ImageService', | |||||||
| DEFINE_string('host', socket.gethostname(), | DEFINE_string('host', socket.gethostname(), | ||||||
|               'name of this node') |               'name of this node') | ||||||
|  |  | ||||||
| # UNUSED |  | ||||||
| DEFINE_string('node_availability_zone', 'nova', | DEFINE_string('node_availability_zone', 'nova', | ||||||
|               'availability zone of this node') |               'availability zone of this node') | ||||||
|   | |||||||
| @@ -133,6 +133,25 @@ class CloudTestCase(test.TestCase): | |||||||
|         db.volume_destroy(self.context, vol1['id']) |         db.volume_destroy(self.context, vol1['id']) | ||||||
|         db.volume_destroy(self.context, vol2['id']) |         db.volume_destroy(self.context, vol2['id']) | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     def test_describe_availability_zones(self): | ||||||
|  |         """Makes sure describe_availability_zones works and filters results.""" | ||||||
|  |         service1 = db.service_create(self.context, {'host': 'host1_describe_zones', | ||||||
|  |                                          'binary': "nova-compute", | ||||||
|  |                                          'topic': 'compute', | ||||||
|  |                                          'report_count': 0, | ||||||
|  |                                          'availability_zone': "zone1"}) | ||||||
|  |         service2 = db.service_create(self.context, {'host': 'host2_describe_zones', | ||||||
|  |                                          'binary': "nova-compute", | ||||||
|  |                                          'topic': 'compute', | ||||||
|  |                                          'report_count': 0, | ||||||
|  |                                          'availability_zone': "zone2"}) | ||||||
|  |         result = self.cloud.describe_availability_zones(self.context) | ||||||
|  |         self.assertEqual(len(result['availabilityZoneInfo']), 3) | ||||||
|  |         db.service_destroy(self.context, service1['id']) | ||||||
|  |         db.service_destroy(self.context, service2['id']) | ||||||
|  |  | ||||||
|  |  | ||||||
|     def test_console_output(self): |     def test_console_output(self): | ||||||
|         image_id = FLAGS.default_image |         image_id = FLAGS.default_image | ||||||
|         instance_type = FLAGS.default_instance_type |         instance_type = FLAGS.default_instance_type | ||||||
| @@ -212,6 +231,21 @@ class CloudTestCase(test.TestCase): | |||||||
|                 logging.debug("Terminating instance %s" % instance_id) |                 logging.debug("Terminating instance %s" % instance_id) | ||||||
|                 rv = self.compute.terminate_instance(instance_id) |                 rv = self.compute.terminate_instance(instance_id) | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     def test_describe_instances(self): | ||||||
|  |         """Makes sure describe_instances works.""" | ||||||
|  |         instance1 = db.instance_create(self.context, {'host': 'host2'}) | ||||||
|  |         service1 = db.service_create(self.context, {'host': 'host2', | ||||||
|  |                                                     'availability_zone': 'zone1', | ||||||
|  |                                                     'topic': "compute"}) | ||||||
|  |         result = self.cloud.describe_instances(self.context) | ||||||
|  |         self.assertEqual(result['reservationSet'][0]\ | ||||||
|  |                          ['instancesSet'][0]\ | ||||||
|  |                          ['placement']['availabilityZone'], 'zone1') | ||||||
|  |         db.instance_destroy(self.context, instance1['id']) | ||||||
|  |         db.service_destroy(self.context, service1['id']) | ||||||
|  |  | ||||||
|  |          | ||||||
|     def test_instance_update_state(self): |     def test_instance_update_state(self): | ||||||
|         def instance(num): |         def instance(num): | ||||||
|             return { |             return { | ||||||
| @@ -261,6 +295,7 @@ class CloudTestCase(test.TestCase): | |||||||
|         #    data = self.cloud.get_metadata(instance(i)['private_dns_name']) |         #    data = self.cloud.get_metadata(instance(i)['private_dns_name']) | ||||||
|         #    self.assert_(data['meta-data']['ami-id'] == 'ami-%s' % i) |         #    self.assert_(data['meta-data']['ami-id'] == 'ami-%s' % i) | ||||||
|  |  | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def _fake_set_image_description(ctxt, image_id, description): |     def _fake_set_image_description(ctxt, image_id, description): | ||||||
|         from nova.objectstore import handler |         from nova.objectstore import handler | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ Tests For Scheduler | |||||||
|  |  | ||||||
| import datetime | import datetime | ||||||
|  |  | ||||||
|  | from mox import IgnoreArg | ||||||
| from nova import context | from nova import context | ||||||
| from nova import db | from nova import db | ||||||
| from nova import flags | from nova import flags | ||||||
| @@ -76,6 +77,48 @@ class SchedulerTestCase(test.TestCase): | |||||||
|         scheduler.named_method(ctxt, 'topic', num=7) |         scheduler.named_method(ctxt, 'topic', num=7) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class ZoneSchedulerTestCase(test.TestCase): | ||||||
|  |     """Test case for zone scheduler""" | ||||||
|  |     def setUp(self): | ||||||
|  |         super(ZoneSchedulerTestCase, self).setUp() | ||||||
|  |         self.flags(scheduler_driver='nova.scheduler.zone.ZoneScheduler') | ||||||
|  |  | ||||||
|  |     def _create_service_model(self, **kwargs): | ||||||
|  |         service = db.sqlalchemy.models.Service() | ||||||
|  |         service.host = kwargs['host'] | ||||||
|  |         service.disabled = False | ||||||
|  |         service.deleted = False | ||||||
|  |         service.report_count = 0 | ||||||
|  |         service.binary = 'nova-compute' | ||||||
|  |         service.topic = 'compute' | ||||||
|  |         service.id = kwargs['id'] | ||||||
|  |         service.availability_zone = kwargs['zone'] | ||||||
|  |         service.created_at = datetime.datetime.utcnow() | ||||||
|  |         return service | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     def test_with_two_zones(self): | ||||||
|  |         scheduler = manager.SchedulerManager() | ||||||
|  |         ctxt = context.get_admin_context() | ||||||
|  |         service_list =  [ | ||||||
|  |                         self._create_service_model(id=1, host='host1', zone='zone1'), | ||||||
|  |                         self._create_service_model(id=2, host='host2', zone='zone2'), | ||||||
|  |                         self._create_service_model(id=3, host='host3', zone='zone2'), | ||||||
|  |                         self._create_service_model(id=4, host='host4', zone='zone2'), | ||||||
|  |                         self._create_service_model(id=5, host='host5', zone='zone2') | ||||||
|  |                         ] | ||||||
|  |         self.mox.StubOutWithMock(db, 'service_get_all_by_topic') | ||||||
|  |         db.service_get_all_by_topic(IgnoreArg(), IgnoreArg()).AndReturn(service_list) | ||||||
|  |         self.mox.StubOutWithMock(rpc, 'cast', use_mock_anything=True) | ||||||
|  |         rpc.cast(ctxt, | ||||||
|  |                  'compute.host1', | ||||||
|  |                  {'method': 'run_instance', | ||||||
|  |                   'args':{'instance_id': 'i-ffffffff', | ||||||
|  |                           'availability_zone': 'zone1'}}) | ||||||
|  |         self.mox.ReplayAll() | ||||||
|  |         scheduler.run_instance(ctxt, 'compute', instance_id='i-ffffffff', availability_zone='zone1') | ||||||
|  |          | ||||||
|  |  | ||||||
| class SimpleDriverTestCase(test.TestCase): | class SimpleDriverTestCase(test.TestCase): | ||||||
|     """Test case for simple driver""" |     """Test case for simple driver""" | ||||||
|     def setUp(self): |     def setUp(self): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Eldar Nugaev
					Eldar Nugaev