Port galera and redis cluster tests to Python 3
* Replace map() with list-comprehension or regular loop to get the same behaviour on Python 2 and Python 3. * Remove test_galera_cluster and test_redis_cluster from blacklist-py3.txt to run them on Python 3 Partially implements: blueprint trove-python3 Change-Id: Id373a0431b98ea7687dc82a48e82f16fedaac5a0
This commit is contained in:
parent
3bd6496998
commit
e60db53db7
@ -1,8 +1,6 @@
|
||||
# Use a blacklist of tests known to fail on Python 3, until
|
||||
# all unit tests will pass on Python 3.
|
||||
backup.test_backup_models
|
||||
cluster.test_galera_cluster
|
||||
cluster.test_redis_cluster
|
||||
guestagent.test_cassandra_manager
|
||||
guestagent.test_dbaas
|
||||
guestagent.test_mongodb_manager
|
||||
|
@ -125,22 +125,21 @@ class GaleraCommonCluster(cluster_models.Cluster):
|
||||
str(name_index))
|
||||
name_index += 1
|
||||
|
||||
return map(lambda instance:
|
||||
Instance.create(context,
|
||||
instance['name'],
|
||||
instance['flavor_id'],
|
||||
datastore_version.image_id,
|
||||
[], [],
|
||||
datastore, datastore_version,
|
||||
instance.get('volume_size', None),
|
||||
None,
|
||||
availability_zone=instance.get(
|
||||
'availability_zone', None),
|
||||
nics=instance.get('nics', None),
|
||||
configuration_id=None,
|
||||
cluster_config=member_config
|
||||
),
|
||||
instances)
|
||||
return [Instance.create(context,
|
||||
instance['name'],
|
||||
instance['flavor_id'],
|
||||
datastore_version.image_id,
|
||||
[], [],
|
||||
datastore, datastore_version,
|
||||
instance.get('volume_size', None),
|
||||
None,
|
||||
availability_zone=instance.get(
|
||||
'availability_zone', None),
|
||||
nics=instance.get('nics', None),
|
||||
configuration_id=None,
|
||||
cluster_config=member_config
|
||||
)
|
||||
for instance in instances]
|
||||
|
||||
@classmethod
|
||||
def create(cls, context, name, datastore, datastore_version,
|
||||
|
@ -56,7 +56,7 @@ class RedisCluster(models.Cluster):
|
||||
|
||||
# Validate and Cache flavors
|
||||
nova_client = remote.create_nova_client(context)
|
||||
unique_flavors = set(map(lambda i: i['flavor_id'], instances))
|
||||
unique_flavors = set(inst['flavor_id'] for inst in instances)
|
||||
flavor_cache = {}
|
||||
for fid in unique_flavors:
|
||||
try:
|
||||
@ -89,24 +89,23 @@ class RedisCluster(models.Cluster):
|
||||
check_quotas(context.tenant, quota_request)
|
||||
|
||||
# Creating member instances
|
||||
return map(lambda instance:
|
||||
inst_models.Instance.create(context,
|
||||
instance['name'],
|
||||
instance['flavor_id'],
|
||||
datastore_version.image_id,
|
||||
[], [],
|
||||
datastore, datastore_version,
|
||||
instance.get('volume_size'),
|
||||
None,
|
||||
instance.get(
|
||||
'availability_zone', None),
|
||||
instance.get('nics', None),
|
||||
configuration_id=None,
|
||||
cluster_config={
|
||||
"id": db_info.id,
|
||||
"instance_type": "member"}
|
||||
),
|
||||
instances)
|
||||
return [inst_models.Instance.create(context,
|
||||
instance['name'],
|
||||
instance['flavor_id'],
|
||||
datastore_version.image_id,
|
||||
[], [],
|
||||
datastore, datastore_version,
|
||||
instance.get('volume_size'),
|
||||
None,
|
||||
instance.get(
|
||||
'availability_zone', None),
|
||||
instance.get('nics', None),
|
||||
configuration_id=None,
|
||||
cluster_config={
|
||||
"id": db_info.id,
|
||||
"instance_type": "member"}
|
||||
)
|
||||
for instance in instances]
|
||||
|
||||
@classmethod
|
||||
def create(cls, context, name, datastore, datastore_version,
|
||||
@ -180,10 +179,14 @@ class RedisCluster(models.Cluster):
|
||||
remain_insts = [inst_models.Instance.load(self.context, inst.id)
|
||||
for inst in all_instances
|
||||
if inst.id not in removal_ids]
|
||||
map(lambda x: Cluster.get_guest(x).remove_nodes(node_ids),
|
||||
remain_insts)
|
||||
map(lambda x: x.update_db(cluster_id=None), removal_insts)
|
||||
map(inst_models.Instance.delete, removal_insts)
|
||||
|
||||
for inst in remain_insts:
|
||||
guest = Cluster.get_guest(inst)
|
||||
guest.remove_nodes(node_ids)
|
||||
for inst in removal_insts:
|
||||
inst.update_db(cluster_id=None)
|
||||
for inst in removal_insts:
|
||||
inst_models.Instance.delete(inst)
|
||||
|
||||
return RedisCluster(self.context, cluster_info,
|
||||
self.ds, self.ds_version)
|
||||
|
Loading…
Reference in New Issue
Block a user