Ejemplo n.º 1
0
 def test_backup_swift_url_conf(self):
     self.ctxt.service_catalog = [{
         u'type':
         u'object-store',
         u'name':
         u'swift',
         u'endpoints': [{
             u'adminURL': u'http://example.com'
         }]
     }, {
         u'type':
         u'identity',
         u'name':
         u'keystone',
         u'endpoints': [{
             u'publicURL': u'http://example.com'
         }]
     }]
     self.ctxt.project_id = fake.project_id
     self.override_config("backup_swift_url", "http://public.example.com/")
     backup = swift_dr.SwiftBackupDriver(self.ctxt)
     self.assertEqual(
         "%s%s" % (CONF.backup_swift_url, self.ctxt.project_id),
         backup.swift_url)
Ejemplo n.º 2
0
    def test_backup_backup_metadata_fail(self):
        """Test of when an exception occurs in backup().

        In backup(), after an exception occurs in
        self._backup_metadata(), we want to check the process of an
        exception handler.
        """
        self._create_backup_db_entry()
        self.flags(backup_compression_algorithm='none')
        service = swift_dr.SwiftBackupDriver(self.ctxt)
        self.volume_file.seek(0)
        backup = db.backup_get(self.ctxt, 123)

        def fake_backup_metadata(self, backup, object_meta):
            raise exception.BackupDriverException(message=_('fake'))

        # Raise a pseudo exception.BackupDriverException.
        self.stubs.Set(swift_dr.SwiftBackupDriver, '_backup_metadata',
                       fake_backup_metadata)

        # We expect that an exception be notified directly.
        self.assertRaises(exception.BackupDriverException,
                          service.backup,
                          backup, self.volume_file)
Ejemplo n.º 3
0
 def test_no_user_context(self, mock_initialize):
     # With no user_id the driver should not initialize itself.
     admin_context = context.get_admin_context()
     swift_dr.SwiftBackupDriver(admin_context)
     mock_initialize.assert_not_called()
Ejemplo n.º 4
0
 def test_delete(self):
     self._create_backup_db_entry()
     service = swift_dr.SwiftBackupDriver(self.ctxt)
     backup = objects.Backup.get_by_id(self.ctxt, 123)
     service.delete(backup)
Ejemplo n.º 5
0
 def test_delete(self):
     self._create_backup_db_entry()
     service = swift_dr.SwiftBackupDriver(self.ctxt)
     backup = db.backup_get(self.ctxt, 123)
     service.delete(backup)
Ejemplo n.º 6
0
 def test_delete(self):
     object_prefix = 'test_prefix'
     self._create_backup_db_entry(service_metadata=object_prefix)
     service = swift_dr.SwiftBackupDriver(self.ctxt)
     backup = objects.Backup.get_by_id(self.ctxt, 123)
     service.delete(backup)
Ejemplo n.º 7
0
 def test_backup_swift_create_storage_policy_head_socket_error(self):
     self.override_config('backup_swift_create_storage_policy',
                          'mypolicy')
     service = swift_dr.SwiftBackupDriver(self.ctxt)
     self.assertRaises(exception.SwiftConnectionFailed,
                       service.put_container, 'socket_error_on_head')
Ejemplo n.º 8
0
 def test_default_backup_swift_create_storage_policy_head_error(self):
     service = swift_dr.SwiftBackupDriver(self.ctxt)
     self.assertRaises(exception.SwiftConnectionFailed,
                       service.put_container, 'unauthorized_container')
Ejemplo n.º 9
0
 def test_default_backup_swift_create_storage_policy_put_socket_error(self):
     service = swift_dr.SwiftBackupDriver(self.ctxt)
     self.assertRaises(exception.SwiftConnectionFailed,
                       service.put_container,
                       'missing_container_socket_error_on_put')
Ejemplo n.º 10
0
 def test_default_backup_swift_create_storage_policy(self, mock_put):
     service = swift_dr.SwiftBackupDriver(self.ctxt)
     service.put_container('missing_container')
     mock_put.assert_called_once_with('missing_container', headers=None)