Fix checksum verification exception.
Previously if an invalid checksum was found, the exception would not be raised. This commit also makes the tests for backup run in fake mode run again (turns out there was no reason to disable them) since they helped find this, and cleans up an issue with the restore backup test (it used the current size of an instance created elsewhere for no reason). Fixes bug 1246368 Change-Id: I96a570a93695b017e5c6966fa1482d6ec5aef426
This commit is contained in:
parent
e41eed6c8c
commit
0b6136cdbc
@ -227,7 +227,7 @@ class DBBackup(DatabaseModelBase):
|
||||
swift_checksum = resp['etag'].strip('"')
|
||||
if self.checksum != swift_checksum:
|
||||
raise exception.RestoreBackupIntegrityError(
|
||||
backup_id=backup_id)
|
||||
backup_id=self.id)
|
||||
return True
|
||||
except ClientException as e:
|
||||
if e.http_status == 404:
|
||||
|
@ -191,12 +191,11 @@ class RestoreUsingBackup(object):
|
||||
@test
|
||||
def test_restore(self):
|
||||
"""test restore"""
|
||||
if test_config.auth_strategy == "fake":
|
||||
raise SkipTest("Skipping restore tests for fake mode.")
|
||||
_flavor, flavor_href = instance_info.find_default_flavor()
|
||||
restorePoint = {"backupRef": backup_info.id}
|
||||
result = instance_info.dbaas.instances.create(
|
||||
instance_info.name + "_restore",
|
||||
instance_info.dbaas_flavor_href,
|
||||
flavor_href,
|
||||
instance_info.volume,
|
||||
restorePoint=restorePoint)
|
||||
assert_equal(200, instance_info.dbaas.last_http_code)
|
||||
@ -216,9 +215,6 @@ class WaitForRestoreToFinish(object):
|
||||
@test
|
||||
@time_out(60 * 32)
|
||||
def test_instance_restored(self):
|
||||
if test_config.auth_strategy == "fake":
|
||||
raise SkipTest("Skipping restore tests for fake mode.")
|
||||
|
||||
# This version just checks the REST API status.
|
||||
def result_is_active():
|
||||
instance = instance_info.dbaas.instances.get(restore_instance_id)
|
||||
@ -242,8 +238,6 @@ class DeleteBackups(object):
|
||||
@test
|
||||
def test_delete_restored_instance(self):
|
||||
"""test delete restored instance"""
|
||||
if test_config.auth_strategy == "fake":
|
||||
raise SkipTest("Skipping delete restored instance for fake mode.")
|
||||
instance_info.dbaas.instances.delete(restore_instance_id)
|
||||
assert_equal(202, instance_info.dbaas.last_http_code)
|
||||
|
||||
|
@ -99,6 +99,23 @@ class InstanceTestInfo(object):
|
||||
self.users = None # The users created on the instance.
|
||||
self.consumer = create_usage_verifier()
|
||||
|
||||
def find_default_flavor(self):
|
||||
if EPHEMERAL_SUPPORT:
|
||||
flavor_name = CONFIG.values.get('instance_eph_flavor_name',
|
||||
'eph.rd-tiny')
|
||||
else:
|
||||
flavor_name = CONFIG.values.get('instance_flavor_name', 'm1.tiny')
|
||||
flavors = self.dbaas.find_flavors_by_name(flavor_name)
|
||||
assert_equal(len(flavors), 1,
|
||||
"Number of flavors with name '%s' "
|
||||
"found was '%d'." % (flavor_name, len(flavors)))
|
||||
flavor = flavors[0]
|
||||
assert_true(flavor is not None, "Flavor '%s' not found!" % flavor_name)
|
||||
flavor_href = self.dbaas.find_flavor_self_href(flavor)
|
||||
assert_true(flavor_href is not None,
|
||||
"Flavor href '%s' not found!" % flavor_name)
|
||||
return flavor, flavor_href
|
||||
|
||||
def get_address(self):
|
||||
result = self.dbaas_admin.mgmt.instances.show(self.id)
|
||||
return result.ip[0]
|
||||
@ -176,20 +193,7 @@ class InstanceSetup(object):
|
||||
|
||||
@test
|
||||
def test_find_flavor(self):
|
||||
if EPHEMERAL_SUPPORT:
|
||||
flavor_name = CONFIG.values.get('instance_eph_flavor_name',
|
||||
'eph.rd-tiny')
|
||||
else:
|
||||
flavor_name = CONFIG.values.get('instance_flavor_name', 'm1.tiny')
|
||||
flavors = dbaas.find_flavors_by_name(flavor_name)
|
||||
assert_equal(len(flavors), 1,
|
||||
"Number of flavors with name '%s' "
|
||||
"found was '%d'." % (flavor_name, len(flavors)))
|
||||
flavor = flavors[0]
|
||||
assert_true(flavor is not None, "Flavor '%s' not found!" % flavor_name)
|
||||
flavor_href = dbaas.find_flavor_self_href(flavor)
|
||||
assert_true(flavor_href is not None,
|
||||
"Flavor href '%s' not found!" % flavor_name)
|
||||
flavor, flavor_href = instance_info.find_default_flavor()
|
||||
instance_info.dbaas_flavor = flavor
|
||||
instance_info.dbaas_flavor_href = flavor_href
|
||||
|
||||
|
@ -469,6 +469,4 @@ class SwiftClientStub(object):
|
||||
|
||||
|
||||
def fake_create_swift_client(calculate_etag=False, *args):
|
||||
if calculate_etag:
|
||||
return FakeSwiftConnectionWithRealEtag()
|
||||
return FakeSwiftClient.Connection(*args)
|
||||
|
@ -16,7 +16,8 @@ import testtools
|
||||
from mockito import when, verify, unstub, mock, any, contains
|
||||
from trove.common.context import TroveContext
|
||||
|
||||
from trove.tests.fakes.swift import fake_create_swift_client
|
||||
from trove.tests.fakes.swift import FakeSwiftConnection
|
||||
from trove.tests.fakes.swift import FakeSwiftConnectionWithRealEtag
|
||||
from trove.tests.unittests.backup.test_backupagent \
|
||||
import MockBackup as MockBackupRunner
|
||||
from trove.guestagent.strategies.storage.swift \
|
||||
@ -54,7 +55,7 @@ class SwiftStorageSaveChecksumTests(testtools.TestCase):
|
||||
password = 'password'
|
||||
backup_container = 'database_backups'
|
||||
|
||||
swift_client = fake_create_swift_client(calculate_etag=True)
|
||||
swift_client = FakeSwiftConnectionWithRealEtag()
|
||||
when(swift).create_swift_client(context).thenReturn(swift_client)
|
||||
storage_strategy = SwiftStorage(context)
|
||||
|
||||
@ -83,7 +84,7 @@ class SwiftStorageSaveChecksumTests(testtools.TestCase):
|
||||
password = 'password'
|
||||
backup_container = 'database_backups'
|
||||
|
||||
swift_client = fake_create_swift_client(calculate_etag=True)
|
||||
swift_client = FakeSwiftConnectionWithRealEtag()
|
||||
when(swift).create_swift_client(context).thenReturn(swift_client)
|
||||
storage_strategy = SwiftStorage(context)
|
||||
|
||||
@ -114,7 +115,7 @@ class SwiftStorageSaveChecksumTests(testtools.TestCase):
|
||||
password = 'password'
|
||||
backup_container = 'database_backups'
|
||||
|
||||
swift_client = fake_create_swift_client(calculate_etag=True)
|
||||
swift_client = FakeSwiftConnectionWithRealEtag()
|
||||
when(swift).create_swift_client(context).thenReturn(swift_client)
|
||||
storage_strategy = SwiftStorage(context)
|
||||
|
||||
@ -155,7 +156,7 @@ class SwiftStorageLoad(testtools.TestCase):
|
||||
is_zipped = False
|
||||
backup_checksum = "fake-md5-sum"
|
||||
|
||||
swift_client = fake_create_swift_client()
|
||||
swift_client = FakeSwiftConnection()
|
||||
when(swift).create_swift_client(context).thenReturn(swift_client)
|
||||
download_process = MockProcess()
|
||||
subprocess = mock(swift.subprocess)
|
||||
@ -192,7 +193,7 @@ class SwiftStorageLoad(testtools.TestCase):
|
||||
is_zipped = False
|
||||
backup_checksum = "checksum_different_then_fake_swift_etag"
|
||||
|
||||
swift_client = fake_create_swift_client()
|
||||
swift_client = FakeSwiftConnection()
|
||||
when(swift).create_swift_client(context).thenReturn(swift_client)
|
||||
|
||||
storage_strategy = SwiftStorage(context)
|
||||
|
Loading…
x
Reference in New Issue
Block a user