Skip adding host to aggregate with az if host already in other zone
Running test_aggregate_add_host_create_server_with_az fails if all
hosts are already in other zones, with error info like:
"conflictingRequest":
{"message": "Cannot add host to aggregate 62.
Reason: One or more hosts already in availability
zone(s)[u'rally_test'].", "code": 409}
This is to find a host that has not been added to other zone, and
skip test_aggregate_add_host_create_server_with_az if all hosts in
the system are already in other zones.
Change-Id: I996d257e089f0676e316f2b14207c343063ccf8e
Closes-Bug: #1748377
This commit is contained in:
@@ -48,11 +48,11 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
if (hyper['hypervisor_type'] ==
|
if (hyper['hypervisor_type'] ==
|
||||||
CONF.compute.hypervisor_type)]
|
CONF.compute.hypervisor_type)]
|
||||||
|
|
||||||
hosts_available = [hyper['service']['host'] for hyper in hypers
|
cls.hosts_available = [hyper['service']['host'] for hyper in hypers
|
||||||
if (hyper['state'] == 'up' and
|
if (hyper['state'] == 'up' and
|
||||||
hyper['status'] == 'enabled')]
|
hyper['status'] == 'enabled')]
|
||||||
if hosts_available:
|
if cls.hosts_available:
|
||||||
cls.host = hosts_available[0]
|
cls.host = cls.hosts_available[0]
|
||||||
else:
|
else:
|
||||||
msg = "no available compute node found"
|
msg = "no available compute node found"
|
||||||
if CONF.compute.hypervisor_type:
|
if CONF.compute.hypervisor_type:
|
||||||
@@ -206,11 +206,23 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
az_name = data_utils.rand_name(self.az_name_prefix)
|
az_name = data_utils.rand_name(self.az_name_prefix)
|
||||||
aggregate = self._create_test_aggregate(availability_zone=az_name)
|
aggregate = self._create_test_aggregate(availability_zone=az_name)
|
||||||
|
|
||||||
self.client.add_host(aggregate['id'], host=self.host)
|
# Find a host that has not been added to other zone,
|
||||||
self.addCleanup(self.client.remove_host, aggregate['id'],
|
# for one host can't be added to different zones.
|
||||||
host=self.host)
|
aggregates = self.client.list_aggregates()['aggregates']
|
||||||
|
hosts_in_zone = []
|
||||||
|
for v in aggregates:
|
||||||
|
if v['availability_zone']:
|
||||||
|
hosts_in_zone.extend(v['hosts'])
|
||||||
|
hosts = [v for v in self.hosts_available if v not in hosts_in_zone]
|
||||||
|
if not hosts:
|
||||||
|
raise self.skipException("All hosts are already in other zones, "
|
||||||
|
"so can't add host to aggregate.")
|
||||||
|
host = hosts[0]
|
||||||
|
|
||||||
|
self.client.add_host(aggregate['id'], host=host)
|
||||||
|
self.addCleanup(self.client.remove_host, aggregate['id'], host=host)
|
||||||
admin_servers_client = self.os_admin.servers_client
|
admin_servers_client = self.os_admin.servers_client
|
||||||
server = self.create_test_server(availability_zone=az_name,
|
server = self.create_test_server(availability_zone=az_name,
|
||||||
wait_until='ACTIVE')
|
wait_until='ACTIVE')
|
||||||
body = admin_servers_client.show_server(server['id'])['server']
|
body = admin_servers_client.show_server(server['id'])['server']
|
||||||
self.assertEqual(self.host, body['OS-EXT-SRV-ATTR:host'])
|
self.assertEqual(host, body['OS-EXT-SRV-ATTR:host'])
|
||||||
|
|||||||
Reference in New Issue
Block a user