Browse Source

Add volume resize functional test for replication

Change-Id: Id08df79f064ddf9a31247853fb19625e695f7bd0
changes/15/743415/1
Lingxian Kong 2 weeks ago
parent
commit
5371dbbd92
2 changed files with 63 additions and 36 deletions
  1. +43
    -36
      trove_tempest_plugin/tests/base.py
  2. +20
    -0
      trove_tempest_plugin/tests/scenario/base_replication.py

+ 43
- 36
trove_tempest_plugin/tests/base.py View File

@@ -255,12 +255,22 @@ class BaseTroveTest(test.BaseTestCase):
"""
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
# configured.
if not datastore_version:
elif not datastore_version:
default_versions = CONF.database.default_datastore_versions
datastore_version = default_versions.get(cls.datastore)

if not datastore_version:
res = cls.client.list_resources("datastores")
for d in res['datastores']:
@@ -270,41 +280,38 @@ class BaseTroveTest(test.BaseTestCase):
else:
datastore_version = d['versions'][0]['name']
break

if not datastore_version:
message = ('Failed to get available datastore version.')
raise exceptions.TempestException(message)

body = {
"instance": {
"name": name,
"datastore": {
"type": cls.datastore,
"version": datastore_version
},
"flavorRef": CONF.database.flavor_id,
"volume": {
"size": 1,
"type": CONF.database.volume_type
},
"nics": [{"net-id": cls.private_network}],
"databases": [{"name": database}],
"users": [
{
"name": username,
"password": password,
"databases": [{"name": database}]
}
],
"access": {"is_public": True}
if not datastore_version:
message = ('Failed to get available datastore version.')
raise exceptions.TempestException(message)

if not replica_of:
body = {
"instance": {
"name": name,
"datastore": {
"type": cls.datastore,
"version": datastore_version
},
"flavorRef": CONF.database.flavor_id,
"volume": {
"size": 1,
"type": CONF.database.volume_type
},
"nics": [{"net-id": cls.private_network}],
"databases": [{"name": database}],
"users": [
{
"name": username,
"password": password,
"databases": [{"name": database}]
}
],
"access": {"is_public": True}
}
}
}
if backup_id:
body['instance'].update({'restorePoint': {'backupRef': backup_id}})
if replica_of:
body['instance']['replica_of'] = replica_of
body['instance'].pop('databases', None)
body['instance'].pop('users', None)
if backup_id:
body['instance'].update(
{'restorePoint': {'backupRef': backup_id}})

res = cls.client.create_resource("instances", body)
cls.addClassResourceCleanup(cls.wait_for_instance_status,


+ 20
- 0
trove_tempest_plugin/tests/scenario/base_replication.py View File

@@ -167,6 +167,26 @@ class TestReplicationBase(trove_base.BaseTroveTest):
self.verify_data_replication(replica2_ip, constants.DB_USER,
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
LOG.info(f"Promoting replica1 {replica1_id} to primary")
promote_primary = {


Loading…
Cancel
Save