diff options
| author | Joe Gordon <jogo@cloudscaling.com> | 2012-12-20 03:13:01 +0000 |
|---|---|---|
| committer | Joe Gordon <jogo@cloudscaling.com> | 2013-01-08 14:01:30 -0800 |
| commit | 1ab2fc6477c402e29a95fbc93fe4a67950c083df (patch) | |
| tree | ed42c15787905fe9e42ca3058bc8db3737d2fcbb /nova/tests | |
| parent | 9f4534ab584faeee1e24d4c1bb38a2b194f24626 (diff) | |
Remove availability_zones from service table
This is the final step in enabling availability_zones using aggregate
metadata. Previously all services had an availability_zone, but the
availability_zone is only used for nova-compute. Services such as
nova-scheduler, nova-network, nova-conductor have always spanned all
availability_zones.
After this change only compute nodes (nova-compute), will have an
availability_zone. In order to preserve current APIs, when running:
* nova host-list (os-hosts)
* euca-describe-availability-zones verbose
* nova-manage service list
Internal services will appear in there own internal availability_zone
(CONF.internal_service_availability_zone)
Internal zone is hidden in euca-describe-availability_zones
(non-verbose)
CONF.node_availability_zone has been renamed to
CONF.default_availability_zone and is only used by the nova-api and
nova-scheduler. CONF.node_availability_zone still works but is
deprecated
DocImpact
Completes blueprint aggregate-based-availability-zones
Change-Id: Ib772df5f9ac2865f20df479f8ddce575a9ce3aff
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/ec2/test_cloud.py | 36 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_hosts.py | 14 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 3 | ||||
| -rw-r--r-- | nova/tests/integrated/api_samples/os-hosts/hosts-list-resp.json.tpl | 8 | ||||
| -rw-r--r-- | nova/tests/network/test_quantumv2.py | 1 | ||||
| -rw-r--r-- | nova/tests/test_libvirt.py | 3 | ||||
| -rw-r--r-- | nova/tests/test_migrations.py | 58 | ||||
| -rw-r--r-- | nova/tests/test_service.py | 4 | ||||
| -rw-r--r-- | nova/tests/test_xenapi.py | 9 |
9 files changed, 96 insertions, 40 deletions
diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py index 429746dac..e0470689a 100644 --- a/nova/tests/api/ec2/test_cloud.py +++ b/nova/tests/api/ec2/test_cloud.py @@ -703,23 +703,24 @@ class CloudTestCase(test.TestCase): service1 = db.service_create(self.context, {'host': 'host1_zones', 'binary': "nova-compute", 'topic': 'compute', - 'report_count': 0, - 'availability_zone': "zone1"}) + 'report_count': 0}) service2 = db.service_create(self.context, {'host': 'host2_zones', 'binary': "nova-compute", 'topic': 'compute', - 'report_count': 0, - 'availability_zone': "zone2"}) + 'report_count': 0}) # Aggregate based zones agg = db.aggregate_create(self.context, - {'name': 'agg1'}, {'availability_zone': 'aggzones'}) + {'name': 'agg1'}, {'availability_zone': 'zone1'}) + db.aggregate_host_add(self.context, agg.id, 'host1_zones') + agg = db.aggregate_create(self.context, + {'name': 'agg2'}, {'availability_zone': 'zone2'}) db.aggregate_host_add(self.context, agg.id, 'host2_zones') result = self.cloud.describe_availability_zones(self.context) - self.assertEqual(len(result['availabilityZoneInfo']), 4) + self.assertEqual(len(result['availabilityZoneInfo']), 3) admin_ctxt = context.get_admin_context(read_deleted="no") result = self.cloud.describe_availability_zones(admin_ctxt, zone_name='verbose') - self.assertEqual(len(result['availabilityZoneInfo']), 18) + self.assertEqual(len(result['availabilityZoneInfo']), 16) db.service_destroy(self.context, service1['id']) db.service_destroy(self.context, service2['id']) @@ -728,13 +729,14 @@ class CloudTestCase(test.TestCase): service1 = db.service_create(self.context, {'host': 'host1_zones', 'binary': "nova-compute", 'topic': 'compute', - 'report_count': 0, - 'availability_zone': "zone1"}) + 'report_count': 0}) service2 = db.service_create(self.context, {'host': 'host2_zones', 'binary': "nova-compute", 'topic': 'compute', - 'report_count': 0, - 'availability_zone': "zone2"}) + 'report_count': 0}) + agg = db.aggregate_create(self.context, + {'name': 'agg1'}, {'availability_zone': 'second_zone'}) + db.aggregate_host_add(self.context, agg.id, 'host2_zones') admin_ctxt = context.get_admin_context(read_deleted="no") result = self.cloud.describe_availability_zones(admin_ctxt, @@ -765,11 +767,17 @@ class CloudTestCase(test.TestCase): 'hostname': 'server-4321', 'vm_state': 'active'}) comp1 = db.service_create(self.context, {'host': 'host1', - 'availability_zone': 'zone1', 'topic': "compute"}) + agg = db.aggregate_create(self.context, + {'name': 'agg1'}, {'availability_zone': 'zone1'}) + db.aggregate_host_add(self.context, agg.id, 'host1') + comp2 = db.service_create(self.context, {'host': 'host2', - 'availability_zone': 'zone2', 'topic': "compute"}) + agg2 = db.aggregate_create(self.context, + {'name': 'agg2'}, {'availability_zone': 'zone2'}) + db.aggregate_host_add(self.context, agg2.id, 'host2') + result = self.cloud.describe_instances(self.context) result = result['reservationSet'][0] self.assertEqual(len(result['instancesSet']), 2) @@ -852,11 +860,9 @@ class CloudTestCase(test.TestCase): inst3 = db.instance_create(self.context, inst3_kwargs) comp1 = db.service_create(self.context, {'host': 'host1', - 'availability_zone': 'zone1', 'topic': "compute"}) comp2 = db.service_create(self.context, {'host': 'host2', - 'availability_zone': 'zone2', 'topic': "compute"}) result = self.cloud.describe_instances(self.context) diff --git a/nova/tests/api/openstack/compute/contrib/test_hosts.py b/nova/tests/api/openstack/compute/contrib/test_hosts.py index 8469c7eba..71eae6f81 100644 --- a/nova/tests/api/openstack/compute/contrib/test_hosts.py +++ b/nova/tests/api/openstack/compute/contrib/test_hosts.py @@ -27,18 +27,14 @@ from nova import test LOG = logging.getLogger(__name__) HOST_LIST = {"hosts": [ {"host_name": "host_c1", "service": "compute", "zone": "nova"}, - {"host_name": "host_c2", "service": "compute", "zone": "nonova"}, - {"host_name": "host_v1", "service": "volume", "zone": "nova"}, - {"host_name": "host_v2", "service": "volume", "zone": "nonova"}] + {"host_name": "host_c2", "service": "compute", "zone": "nova"}] } HOST_LIST_NOVA_ZONE = [ {"host_name": "host_c1", "service": "compute", "zone": "nova"}, - {"host_name": "host_v1", "service": "volume", "zone": "nova"}] + {"host_name": "host_c2", "service": "compute", "zone": "nova"}] SERVICES_LIST = [ - {"host": "host_c1", "topic": "compute", "availability_zone": "nova"}, - {"host": "host_c2", "topic": "compute", "availability_zone": "nonova"}, - {"host": "host_v1", "topic": "volume", "availability_zone": "nova"}, - {"host": "host_v2", "topic": "volume", "availability_zone": "nonova"}] + {"host": "host_c1", "topic": "compute"}, + {"host": "host_c2", "topic": "compute"}] def stub_service_get_all(self, req): @@ -250,7 +246,7 @@ class HostTestCase(test.TestCase): """Create compute-manager(ComputeNode and Service record).""" ctxt = context.get_admin_context() dic = {'host': 'dummy', 'binary': 'nova-compute', 'topic': 'compute', - 'report_count': 0, 'availability_zone': 'dummyzone'} + 'report_count': 0} s_ref = db.service_create(ctxt, dic) dic = {'service_id': s_ref['id'], diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 823eeaf4e..f6889ff2c 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -5383,8 +5383,7 @@ def _create_service_entries(context, values={'avail_zone1': ['fake_host1', {'host': host, 'binary': 'nova-compute', 'topic': 'compute', - 'report_count': 0, - 'availability_zone': avail_zone}) + 'report_count': 0}) return values diff --git a/nova/tests/integrated/api_samples/os-hosts/hosts-list-resp.json.tpl b/nova/tests/integrated/api_samples/os-hosts/hosts-list-resp.json.tpl index 555901b2e..eeb191597 100644 --- a/nova/tests/integrated/api_samples/os-hosts/hosts-list-resp.json.tpl +++ b/nova/tests/integrated/api_samples/os-hosts/hosts-list-resp.json.tpl @@ -8,22 +8,22 @@ { "host_name": "%(host_name)s", "service": "cert", - "zone": "nova" + "zone": "internal" }, { "host_name": "%(host_name)s", "service": "network", - "zone": "nova" + "zone": "internal" }, { "host_name": "%(host_name)s", "service": "scheduler", - "zone": "nova" + "zone": "internal" }, { "host_name": "%(host_name)s", "service": "conductor", - "zone": "nova" + "zone": "internal" } ] } diff --git a/nova/tests/network/test_quantumv2.py b/nova/tests/network/test_quantumv2.py index 1eab23a03..622365c76 100644 --- a/nova/tests/network/test_quantumv2.py +++ b/nova/tests/network/test_quantumv2.py @@ -137,6 +137,7 @@ class TestQuantumv2(test.TestCase): self.instance = {'project_id': '9d049e4b60b64716978ab415e6fbd5c0', 'uuid': str(uuid.uuid4()), 'display_name': 'test_instance', + 'availability_zone': 'nova', 'security_groups': []} self.nets1 = [{'id': 'my_netid1', 'name': 'my_netname1', diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 6bc18251f..7443d5289 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -628,8 +628,7 @@ class LibvirtConnTestCase(test.TestCase): service_ref = {'host': kwargs.get('host', 'dummy'), 'binary': 'nova-compute', 'topic': 'compute', - 'report_count': 0, - 'availability_zone': 'zone'} + 'report_count': 0} return db.service_create(context.get_admin_context(), service_ref) diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py index bcd858d96..9badfb61a 100644 --- a/nova/tests/test_migrations.py +++ b/nova/tests/test_migrations.py @@ -331,3 +331,61 @@ class TestMigrations(test.TestCase): migration_api.downgrade(engine, TestMigrations.REPOSITORY, 145) _145_check() + + def test_migration_147(self): + az = 'test_zone' + host1 = 'compute-host1' + host2 = 'compute-host2' + + def _146_check(): + service = services.select(services.c.id == 1).execute().first() + self.assertEqual(az, service.availability_zone) + self.assertEqual(host1, service.host) + service = services.select(services.c.id == 2).execute().first() + self.assertNotEqual(az, service.availability_zone) + service = services.select(services.c.id == 3).execute().first() + self.assertEqual(az, service.availability_zone) + self.assertEqual(host2, service.host) + + for key, engine in self.engines.items(): + migration_api.version_control(engine, TestMigrations.REPOSITORY, + migration.INIT_VERSION) + migration_api.upgrade(engine, TestMigrations.REPOSITORY, 146) + metadata = sqlalchemy.schema.MetaData() + metadata.bind = engine + + #populate service table + services = sqlalchemy.Table('services', metadata, + autoload=True) + services.insert().values(id=1, host=host1, + binary='nova-compute', topic='compute', report_count=0, + availability_zone=az).execute() + services.insert().values(id=2, host='sched-host', + binary='nova-scheduler', topic='scheduler', report_count=0, + availability_zone='ignore_me').execute() + services.insert().values(id=3, host=host2, + binary='nova-compute', topic='compute', report_count=0, + availability_zone=az).execute() + + _146_check() + + migration_api.upgrade(engine, TestMigrations.REPOSITORY, 147) + + # check aggregate metadata + aggregate_metadata = sqlalchemy.Table('aggregate_metadata', + metadata, autoload=True) + aggregate_hosts = sqlalchemy.Table('aggregate_hosts', + metadata, autoload=True) + metadata = aggregate_metadata.select(aggregate_metadata.c. + aggregate_id == 1).execute().first() + self.assertEqual(az, metadata['value']) + self.assertEqual(aggregate_hosts.select( + aggregate_hosts.c.aggregate_id == 1).execute(). + first().host, host1) + blank = [h for h in aggregate_hosts.select( + aggregate_hosts.c.aggregate_id == 2).execute()] + self.assertEqual(blank, []) + + migration_api.downgrade(engine, TestMigrations.REPOSITORY, 146) + + _146_check() diff --git a/nova/tests/test_service.py b/nova/tests/test_service.py index 211a91e45..4c834e9c9 100644 --- a/nova/tests/test_service.py +++ b/nova/tests/test_service.py @@ -127,13 +127,11 @@ class ServiceTestCase(test.TestCase): service_create = {'host': self.host, 'binary': self.binary, 'topic': self.topic, - 'report_count': 0, - 'availability_zone': 'nova'} + 'report_count': 0} service_ref = {'host': self.host, 'binary': self.binary, 'topic': self.topic, 'report_count': 0, - 'availability_zone': 'nova', 'id': 1} service.db.service_get_by_args(mox.IgnoreArg(), diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 64659a21f..897bccd39 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -61,7 +61,7 @@ CONF.import_opt('compute_manager', 'nova.config') CONF.import_opt('compute_driver', 'nova.virt.driver') CONF.import_opt('host', 'nova.config') CONF.import_opt('network_manager', 'nova.config') -CONF.import_opt('node_availability_zone', 'nova.config') +CONF.import_opt('default_availability_zone', 'nova.availability_zones') IMAGE_MACHINE = '1' IMAGE_KERNEL = '2' @@ -206,7 +206,7 @@ class XenAPIVolumeTestCase(stubs.XenAPITestBase): vol['user_id'] = 'fake' vol['project_id'] = 'fake' vol['host'] = 'localhost' - vol['availability_zone'] = CONF.node_availability_zone + vol['availability_zone'] = CONF.default_availability_zone vol['status'] = "creating" vol['attach_status'] = "detached" return db.volume_create(self.context, vol) @@ -2196,8 +2196,7 @@ def _create_service_entries(context, values={'avail_zone1': ['fake_host1', {'host': host, 'binary': 'nova-compute', 'topic': 'compute', - 'report_count': 0, - 'availability_zone': avail_zone}) + 'report_count': 0}) return values @@ -2213,7 +2212,7 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): 'Dom0IptablesFirewallDriver', host='host', compute_driver='xenapi.XenAPIDriver', - node_availability_zone='avail_zone1') + default_availability_zone='avail_zone1') self.flags(use_local=True, group='conductor') host_ref = xenapi_fake.get_all('host')[0] stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests) |
