Add volume resize functional test for replication
Change-Id: Id08df79f064ddf9a31247853fb19625e695f7bd0
This commit is contained in:
parent
177648d906
commit
5371dbbd92
|
@ -255,12 +255,22 @@ class BaseTroveTest(test.BaseTestCase):
|
||||||
"""
|
"""
|
||||||
name = name or cls.get_resource_name("instance")
|
name = name or cls.get_resource_name("instance")
|
||||||
|
|
||||||
|
# Flavor, volume, datastore are not needed for creating replica.
|
||||||
|
if replica_of:
|
||||||
|
body = {
|
||||||
|
"instance": {
|
||||||
|
"name": name,
|
||||||
|
"nics": [{"net-id": cls.private_network}],
|
||||||
|
"access": {"is_public": True},
|
||||||
|
"replica_of": replica_of,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Get datastore version. Get from API if the default ds version is not
|
# Get datastore version. Get from API if the default ds version is not
|
||||||
# configured.
|
# configured.
|
||||||
if not datastore_version:
|
elif not datastore_version:
|
||||||
default_versions = CONF.database.default_datastore_versions
|
default_versions = CONF.database.default_datastore_versions
|
||||||
datastore_version = default_versions.get(cls.datastore)
|
datastore_version = default_versions.get(cls.datastore)
|
||||||
|
|
||||||
if not datastore_version:
|
if not datastore_version:
|
||||||
res = cls.client.list_resources("datastores")
|
res = cls.client.list_resources("datastores")
|
||||||
for d in res['datastores']:
|
for d in res['datastores']:
|
||||||
|
@ -270,41 +280,38 @@ class BaseTroveTest(test.BaseTestCase):
|
||||||
else:
|
else:
|
||||||
datastore_version = d['versions'][0]['name']
|
datastore_version = d['versions'][0]['name']
|
||||||
break
|
break
|
||||||
|
if not datastore_version:
|
||||||
|
message = ('Failed to get available datastore version.')
|
||||||
|
raise exceptions.TempestException(message)
|
||||||
|
|
||||||
if not datastore_version:
|
if not replica_of:
|
||||||
message = ('Failed to get available datastore version.')
|
body = {
|
||||||
raise exceptions.TempestException(message)
|
"instance": {
|
||||||
|
"name": name,
|
||||||
body = {
|
"datastore": {
|
||||||
"instance": {
|
"type": cls.datastore,
|
||||||
"name": name,
|
"version": datastore_version
|
||||||
"datastore": {
|
},
|
||||||
"type": cls.datastore,
|
"flavorRef": CONF.database.flavor_id,
|
||||||
"version": datastore_version
|
"volume": {
|
||||||
},
|
"size": 1,
|
||||||
"flavorRef": CONF.database.flavor_id,
|
"type": CONF.database.volume_type
|
||||||
"volume": {
|
},
|
||||||
"size": 1,
|
"nics": [{"net-id": cls.private_network}],
|
||||||
"type": CONF.database.volume_type
|
"databases": [{"name": database}],
|
||||||
},
|
"users": [
|
||||||
"nics": [{"net-id": cls.private_network}],
|
{
|
||||||
"databases": [{"name": database}],
|
"name": username,
|
||||||
"users": [
|
"password": password,
|
||||||
{
|
"databases": [{"name": database}]
|
||||||
"name": username,
|
}
|
||||||
"password": password,
|
],
|
||||||
"databases": [{"name": database}]
|
"access": {"is_public": True}
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"access": {"is_public": True}
|
|
||||||
}
|
}
|
||||||
}
|
if backup_id:
|
||||||
if backup_id:
|
body['instance'].update(
|
||||||
body['instance'].update({'restorePoint': {'backupRef': backup_id}})
|
{'restorePoint': {'backupRef': backup_id}})
|
||||||
if replica_of:
|
|
||||||
body['instance']['replica_of'] = replica_of
|
|
||||||
body['instance'].pop('databases', None)
|
|
||||||
body['instance'].pop('users', None)
|
|
||||||
|
|
||||||
res = cls.client.create_resource("instances", body)
|
res = cls.client.create_resource("instances", body)
|
||||||
cls.addClassResourceCleanup(cls.wait_for_instance_status,
|
cls.addClassResourceCleanup(cls.wait_for_instance_status,
|
||||||
|
|
|
@ -167,6 +167,26 @@ class TestReplicationBase(trove_base.BaseTroveTest):
|
||||||
self.verify_data_replication(replica2_ip, constants.DB_USER,
|
self.verify_data_replication(replica2_ip, constants.DB_USER,
|
||||||
constants.DB_PASS, constants.DB_NAME)
|
constants.DB_PASS, constants.DB_NAME)
|
||||||
|
|
||||||
|
# Volume resize to primary
|
||||||
|
LOG.info(f"Resizing volume for primary {self.instance_id} to 2G")
|
||||||
|
req_body = {
|
||||||
|
"resize": {
|
||||||
|
"volume": {"size": 2}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.client.create_resource(f"instances/{self.instance_id}/action",
|
||||||
|
req_body, expected_status_code=202,
|
||||||
|
need_response=False)
|
||||||
|
self.wait_for_instance_status(self.instance_id)
|
||||||
|
self.wait_for_instance_status(replica1_id)
|
||||||
|
self.wait_for_instance_status(replica2_id)
|
||||||
|
|
||||||
|
# Verify the volumes of all the replicas are also resized to 2G
|
||||||
|
replica1 = self.client.get_resource('instances', replica1_id)
|
||||||
|
self.assertEqual(2, replica1['instance']['volume'].get('size', 0))
|
||||||
|
replica2 = self.client.get_resource('instances', replica2_id)
|
||||||
|
self.assertEqual(2, replica2['instance']['volume'].get('size', 0))
|
||||||
|
|
||||||
# Promote replica1 to primary
|
# Promote replica1 to primary
|
||||||
LOG.info(f"Promoting replica1 {replica1_id} to primary")
|
LOG.info(f"Promoting replica1 {replica1_id} to primary")
|
||||||
promote_primary = {
|
promote_primary = {
|
||||||
|
|
Loading…
Reference in New Issue