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
|
# Use a blacklist of tests known to fail on Python 3, until
|
||||||
# all unit tests will pass on Python 3.
|
# all unit tests will pass on Python 3.
|
||||||
backup.test_backup_models
|
backup.test_backup_models
|
||||||
cluster.test_galera_cluster
|
|
||||||
cluster.test_redis_cluster
|
|
||||||
guestagent.test_cassandra_manager
|
guestagent.test_cassandra_manager
|
||||||
guestagent.test_dbaas
|
guestagent.test_dbaas
|
||||||
guestagent.test_mongodb_manager
|
guestagent.test_mongodb_manager
|
||||||
|
@ -125,22 +125,21 @@ class GaleraCommonCluster(cluster_models.Cluster):
|
|||||||
str(name_index))
|
str(name_index))
|
||||||
name_index += 1
|
name_index += 1
|
||||||
|
|
||||||
return map(lambda instance:
|
return [Instance.create(context,
|
||||||
Instance.create(context,
|
instance['name'],
|
||||||
instance['name'],
|
instance['flavor_id'],
|
||||||
instance['flavor_id'],
|
datastore_version.image_id,
|
||||||
datastore_version.image_id,
|
[], [],
|
||||||
[], [],
|
datastore, datastore_version,
|
||||||
datastore, datastore_version,
|
instance.get('volume_size', None),
|
||||||
instance.get('volume_size', None),
|
None,
|
||||||
None,
|
availability_zone=instance.get(
|
||||||
availability_zone=instance.get(
|
'availability_zone', None),
|
||||||
'availability_zone', None),
|
nics=instance.get('nics', None),
|
||||||
nics=instance.get('nics', None),
|
configuration_id=None,
|
||||||
configuration_id=None,
|
cluster_config=member_config
|
||||||
cluster_config=member_config
|
)
|
||||||
),
|
for instance in instances]
|
||||||
instances)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, context, name, datastore, datastore_version,
|
def create(cls, context, name, datastore, datastore_version,
|
||||||
|
@ -56,7 +56,7 @@ class RedisCluster(models.Cluster):
|
|||||||
|
|
||||||
# Validate and Cache flavors
|
# Validate and Cache flavors
|
||||||
nova_client = remote.create_nova_client(context)
|
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 = {}
|
flavor_cache = {}
|
||||||
for fid in unique_flavors:
|
for fid in unique_flavors:
|
||||||
try:
|
try:
|
||||||
@ -89,24 +89,23 @@ class RedisCluster(models.Cluster):
|
|||||||
check_quotas(context.tenant, quota_request)
|
check_quotas(context.tenant, quota_request)
|
||||||
|
|
||||||
# Creating member instances
|
# Creating member instances
|
||||||
return map(lambda instance:
|
return [inst_models.Instance.create(context,
|
||||||
inst_models.Instance.create(context,
|
instance['name'],
|
||||||
instance['name'],
|
instance['flavor_id'],
|
||||||
instance['flavor_id'],
|
datastore_version.image_id,
|
||||||
datastore_version.image_id,
|
[], [],
|
||||||
[], [],
|
datastore, datastore_version,
|
||||||
datastore, datastore_version,
|
instance.get('volume_size'),
|
||||||
instance.get('volume_size'),
|
None,
|
||||||
None,
|
instance.get(
|
||||||
instance.get(
|
'availability_zone', None),
|
||||||
'availability_zone', None),
|
instance.get('nics', None),
|
||||||
instance.get('nics', None),
|
configuration_id=None,
|
||||||
configuration_id=None,
|
cluster_config={
|
||||||
cluster_config={
|
"id": db_info.id,
|
||||||
"id": db_info.id,
|
"instance_type": "member"}
|
||||||
"instance_type": "member"}
|
)
|
||||||
),
|
for instance in instances]
|
||||||
instances)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, context, name, datastore, datastore_version,
|
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)
|
remain_insts = [inst_models.Instance.load(self.context, inst.id)
|
||||||
for inst in all_instances
|
for inst in all_instances
|
||||||
if inst.id not in removal_ids]
|
if inst.id not in removal_ids]
|
||||||
map(lambda x: Cluster.get_guest(x).remove_nodes(node_ids),
|
|
||||||
remain_insts)
|
for inst in remain_insts:
|
||||||
map(lambda x: x.update_db(cluster_id=None), removal_insts)
|
guest = Cluster.get_guest(inst)
|
||||||
map(inst_models.Instance.delete, removal_insts)
|
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,
|
return RedisCluster(self.context, cluster_info,
|
||||||
self.ds, self.ds_version)
|
self.ds, self.ds_version)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user