Example #1
0
 def test_check_container_exists(self):
     service = SwiftBackupService(self.ctxt)
     exists = service._check_container_exists("fake_container")
     self.assertEquals(exists, True)
     exists = service._check_container_exists("missing_container")
     self.assertEquals(exists, False)
     self.assertRaises(swift.ClientException, service._check_container_exists, "unauthorized_container")
    def test_restore(self):
        self._create_backup_db_entry()
        service = SwiftBackupService(self.ctxt)

        with tempfile.NamedTemporaryFile() as volume_file:
            backup = db.backup_get(self.ctxt, 123)
            service.restore(backup, '1234-5678-1234-8888', volume_file)
 def test_backup_zlib(self):
     self._create_backup_db_entry()
     self.flags(backup_compression_algorithm='zlib')
     service = SwiftBackupService(self.ctxt)
     self.volume_file.seek(0)
     backup = db.backup_get(self.ctxt, 123)
     service.backup(backup, self.volume_file)
Example #4
0
    def test_restore(self):
        self._create_backup_db_entry()
        service = SwiftBackupService(self.ctxt)

        with tempfile.NamedTemporaryFile() as volume_file:
            backup = db.backup_get(self.ctxt, 123)
            service.restore(backup, '1234-5678-1234-8888', volume_file)
Example #5
0
 def test_backup_zlib(self):
     self._create_backup_db_entry()
     self.flags(backup_compression_algorithm='zlib')
     service = SwiftBackupService(self.ctxt)
     self.volume_file.seek(0)
     backup = db.backup_get(self.ctxt, 123)
     service.backup(backup, self.volume_file)
 def test_backup_default_container(self):
     self._create_backup_db_entry(container=None)
     service = SwiftBackupService(self.ctxt)
     self.volume_file.seek(0)
     backup = db.backup_get(self.ctxt, 123)
     service.backup(backup, self.volume_file)
     backup = db.backup_get(self.ctxt, 123)
     self.assertEquals(backup['container'], 'volumebackups')
Example #7
0
 def test_backup_default_container(self):
     self._create_backup_db_entry(container=None)
     service = SwiftBackupService(self.ctxt)
     self.volume_file.seek(0)
     backup = db.backup_get(self.ctxt, 123)
     service.backup(backup, self.volume_file)
     backup = db.backup_get(self.ctxt, 123)
     self.assertEquals(backup['container'], 'volumebackups')
 def test_check_container_exists(self):
     service = SwiftBackupService(self.ctxt)
     exists = service._check_container_exists('fake_container')
     self.assertEquals(exists, True)
     exists = service._check_container_exists('missing_container')
     self.assertEquals(exists, False)
     self.assertRaises(swift.ClientException,
                       service._check_container_exists,
                       'unauthorized_container')
Example #9
0
 def test_get_compressor(self):
     service = SwiftBackupService(self.ctxt)
     compressor = service._get_compressor('None')
     self.assertEquals(compressor, None)
     compressor = service._get_compressor('zlib')
     self.assertEquals(compressor, zlib)
     compressor = service._get_compressor('bz2')
     self.assertEquals(compressor, bz2)
     self.assertRaises(ValueError, service._get_compressor, 'fake')
Example #10
0
 def test_backup_custom_container(self):
     container_name = 'fake99'
     self._create_backup_db_entry(container=container_name)
     service = SwiftBackupService(self.ctxt)
     self.volume_file.seek(0)
     backup = db.backup_get(self.ctxt, 123)
     service.backup(backup, self.volume_file)
     backup = db.backup_get(self.ctxt, 123)
     self.assertEquals(backup['container'], container_name)
Example #11
0
 def test_get_compressor(self):
     service = SwiftBackupService(self.ctxt)
     compressor = service._get_compressor("None")
     self.assertEquals(compressor, None)
     compressor = service._get_compressor("zlib")
     self.assertEquals(compressor, zlib)
     compressor = service._get_compressor("bz2")
     self.assertEquals(compressor, bz2)
     self.assertRaises(ValueError, service._get_compressor, "fake")
 def test_backup_custom_container(self):
     container_name = 'fake99'
     self._create_backup_db_entry(container=container_name)
     service = SwiftBackupService(self.ctxt)
     self.volume_file.seek(0)
     backup = db.backup_get(self.ctxt, 123)
     service.backup(backup, self.volume_file)
     backup = db.backup_get(self.ctxt, 123)
     self.assertEquals(backup['container'], container_name)
 def test_get_compressor(self):
     service = SwiftBackupService(self.ctxt)
     compressor = service._get_compressor('None')
     self.assertEquals(compressor, None)
     compressor = service._get_compressor('zlib')
     self.assertEquals(compressor, zlib)
     compressor = service._get_compressor('bz2')
     self.assertEquals(compressor, bz2)
     self.assertRaises(ValueError, service._get_compressor, 'fake')
 def test_delete_wraps_socket_error(self):
     container_name = 'socket_error_on_delete'
     self._create_backup_db_entry(container=container_name)
     service = SwiftBackupService(self.ctxt)
     backup = db.backup_get(self.ctxt, 123)
     self.assertRaises(exception.SwiftConnectionFailed, service.delete,
                       backup)
 def test_create_backup_put_object_wraps_socket_error(self):
     container_name = 'socket_error_on_put'
     self._create_backup_db_entry(container=container_name)
     service = SwiftBackupService(self.ctxt)
     self.volume_file.seek(0)
     backup = db.backup_get(self.ctxt, 123)
     self.assertRaises(exception.SwiftConnectionFailed, service.backup,
                       backup, self.volume_file)
    def test_restore_wraps_socket_error(self):
        container_name = 'socket_error_on_get'
        self._create_backup_db_entry(container=container_name)
        service = SwiftBackupService(self.ctxt)

        with tempfile.NamedTemporaryFile() as volume_file:
            backup = db.backup_get(self.ctxt, 123)
            self.assertRaises(exception.SwiftConnectionFailed, service.restore,
                              backup, '1234-5678-1234-8888', volume_file)
    def test_restore_unsupported_version(self):
        container_name = 'unsupported_version'
        self._create_backup_db_entry(container=container_name)
        service = SwiftBackupService(self.ctxt)

        with tempfile.NamedTemporaryFile() as volume_file:
            backup = db.backup_get(self.ctxt, 123)
            self.assertRaises(exception.InvalidBackup, service.restore, backup,
                              '1234-5678-1234-8888', volume_file)
Example #18
0
 def test_delete(self):
     self._create_backup_db_entry()
     service = SwiftBackupService(self.ctxt)
     backup = db.backup_get(self.ctxt, 123)
     service.delete(backup)
 def test_delete(self):
     self._create_backup_db_entry()
     service = SwiftBackupService(self.ctxt)
     backup = db.backup_get(self.ctxt, 123)
     service.delete(backup)