def test_backup_zlib(self): self._create_backup_db_entry() self.flags(backup_compression_algorithm='zlib') service = SwiftBackupDriver(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 = SwiftBackupDriver(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.assertEqual(backup['container'], 'volumebackups')
def test_backup_custom_container(self): container_name = 'fake99' self._create_backup_db_entry(container=container_name) service = SwiftBackupDriver(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.assertEqual(backup['container'], container_name)
def test_backup_default_container_notify(self, _send_progress, _send_progress_end): self._create_backup_db_entry(container=None) # If the backup_object_number_per_notification is set to 1, # the _send_progress method will be called for sure. CONF.set_override("backup_object_number_per_notification", 1) CONF.set_override("backup_swift_enable_progress_timer", False) service = SwiftBackupDriver(self.ctxt) self.volume_file.seek(0) backup = db.backup_get(self.ctxt, 123) service.backup(backup, self.volume_file) self.assertTrue(_send_progress.called) self.assertTrue(_send_progress_end.called) # If the backup_object_number_per_notification is increased to # another value, the _send_progress method will not be called. _send_progress.reset_mock() _send_progress_end.reset_mock() CONF.set_override("backup_object_number_per_notification", 10) service = SwiftBackupDriver(self.ctxt) self.volume_file.seek(0) backup = db.backup_get(self.ctxt, 123) service.backup(backup, self.volume_file) self.assertFalse(_send_progress.called) self.assertTrue(_send_progress_end.called) # If the timer is enabled, the _send_progress will be called, # since the timer can trigger the progress notification. _send_progress.reset_mock() _send_progress_end.reset_mock() CONF.set_override("backup_object_number_per_notification", 10) CONF.set_override("backup_swift_enable_progress_timer", True) service = SwiftBackupDriver(self.ctxt) self.volume_file.seek(0) backup = db.backup_get(self.ctxt, 123) service.backup(backup, self.volume_file) self.assertTrue(_send_progress.called) self.assertTrue(_send_progress_end.called)