Пример #1
0
    def test_init_backup_repo_path(self):
        self.override_config('glusterfs_backup_share', FAKE_BACKUP_SHARE)
        self.override_config('glusterfs_backup_mount_point',
                             FAKE_BACKUP_MOUNT_POINT_BASE)
        mock_remotefsclient = mock.Mock()
        mock_remotefsclient.get_mount_point = mock.Mock(
            return_value=FAKE_BACKUP_PATH)
        self.mock_object(glusterfs.GlusterfsBackupDriver,
                         '_check_configuration')
        self.mock_object(remotefs_brick,
                         'RemoteFsClient',
                         return_value=mock_remotefsclient)
        self.mock_object(os, 'getegid', return_value=333333)
        self.mock_object(utils, 'get_file_gid', return_value=333333)
        self.mock_object(utils, 'get_file_mode', return_value=00000)
        self.mock_object(utils, 'get_root_helper')

        with mock.patch.object(glusterfs.GlusterfsBackupDriver,
                               '_init_backup_repo_path'):
            driver = glusterfs.GlusterfsBackupDriver(self.ctxt)
        self.mock_object(driver, '_execute')
        path = driver._init_backup_repo_path()

        self.assertEqual(FAKE_BACKUP_PATH, path)
        utils.get_root_helper.called_once()
        mock_remotefsclient.mount.assert_called_once_with(FAKE_BACKUP_SHARE)
        mock_remotefsclient.get_mount_point.assert_called_once_with(
            FAKE_BACKUP_SHARE)
Пример #2
0
    def test_check_configuration(self):
        self.override_config('glusterfs_backup_share', FAKE_BACKUP_SHARE)
        self.mock_object(glusterfs.GlusterfsBackupDriver,
                         '_init_backup_repo_path',
                         return_value=FAKE_BACKUP_PATH)

        driver = glusterfs.GlusterfsBackupDriver(self.ctxt)
        driver.check_for_setup_error()
Пример #3
0
    def test_check_configuration_no_backup_share(self):
        self.override_config('glusterfs_backup_share', None)
        self.mock_object(glusterfs.GlusterfsBackupDriver,
                         '_init_backup_repo_path',
                         return_value=FAKE_BACKUP_PATH)

        driver = glusterfs.GlusterfsBackupDriver(self.ctxt)
        self.assertRaises(exception.InvalidConfigurationValue,
                          driver.check_for_setup_error)
Пример #4
0
    def test_check_configuration(self):
        self.override_config('glusterfs_backup_share', FAKE_BACKUP_SHARE)
        self.mock_object(glusterfs.GlusterfsBackupDriver,
                         '_init_backup_repo_path',
                         mock.Mock(return_value=FAKE_BACKUP_PATH))

        with mock.patch.object(glusterfs.GlusterfsBackupDriver,
                               '_check_configuration'):
            driver = glusterfs.GlusterfsBackupDriver(self.ctxt)
        driver._check_configuration()
Пример #5
0
    def test_check_configuration_no_backup_share(self):
        self.override_config('glusterfs_backup_share', None)
        self.mock_object(glusterfs.GlusterfsBackupDriver,
                         '_init_backup_repo_path',
                         return_value=FAKE_BACKUP_PATH)

        with mock.patch.object(glusterfs.GlusterfsBackupDriver,
                               '_check_configuration'):
            driver = glusterfs.GlusterfsBackupDriver(self.ctxt)
        self.assertRaises(exception.ConfigNotFound,
                          driver._check_configuration)