コード例 #1
0
    def test_copy_share_data_remote_access_exception(self):
        fake_share = db_utils.create_share(
            id='fakeid', status=constants.STATUS_AVAILABLE, host='fake_host')
        fake_share_instance = {'id': 'fake_id', 'host': 'fake_host'}
        share_driver = self._setup_mocks_copy_share_data()
        remote = {'access': {'access_to': '192.168.0.1'},
                  'mount': 'fake_mount',
                  'umount': 'fake_umount'}
        local = {'access': {'access_to': '192.168.1.1'},
                 'mount': 'fake_mount',
                 'umount': 'fake_umount'}
        helper = migration.ShareMigrationHelper(None, None, None, None, None)

        driver.CONF.set_default('migration_tmp_location', '/fake/path')
        driver.CONF.set_default('migration_ignore_files', None)

        self.mock_object(migration.ShareMigrationHelper,
                         'deny_migration_access')
        self.mock_object(
            migration.ShareMigrationHelper,
            'allow_migration_access',
            mock.Mock(side_effect=[None,
                                   exception.ShareMigrationFailed(
                                       reason='fake')]))
        self.mock_object(migration.ShareMigrationHelper,
                         'cleanup_migration_access')
        self.assertRaises(exception.ShareMigrationFailed,
                          share_driver.copy_share_data, 'ctx', helper,
                          fake_share, fake_share_instance, None,
                          fake_share_instance, None, local, remote)

        args = ((None, local['access'], False),
                (None, remote['access'], False))
        migration.ShareMigrationHelper.deny_migration_access.assert_has_calls(
            [mock.call(*a) for a in args])
コード例 #2
0
 def setUp(self):
     super(ShareMigrationHelperTestCase, self).setUp()
     self.share = db_utils.create_share()
     self.context = context.get_admin_context()
     self.helper = migration.ShareMigrationHelper(
         self.context, db,
         driver.CONF.migration_create_delete_share_timeout,
         driver.CONF.migration_wait_access_rules_timeout, self.share)
コード例 #3
0
ファイル: test_migration.py プロジェクト: ponychou/manila
 def setUp(self):
     super(ShareMigrationHelperTestCase, self).setUp()
     self.share = db_utils.create_share()
     self.share_instance = db_utils.create_share_instance(
         share_id=self.share['id'], share_network_id='fake_network_id')
     self.context = context.get_admin_context()
     self.helper = migration.ShareMigrationHelper(self.context, db,
                                                  self.share)
コード例 #4
0
    def test_copy_share_data_mount_for_migration_exception2(self):
        fake_share = db_utils.create_share(id='fakeid',
                                           status=constants.STATUS_AVAILABLE,
                                           host='fake_host')
        fake_share_instance = {'id': 'fake_id', 'host': 'fake_host'}
        share_driver = self._setup_mocks_copy_share_data()
        remote = {
            'access': {
                'access_to': '192.168.0.1'
            },
            'mount': 'fake_mount',
            'umount': 'fake_umount'
        }
        local = {
            'access': {
                'access_to': '192.168.1.1'
            },
            'mount': 'fake_mount',
            'umount': 'fake_umount'
        }
        helper = migration.ShareMigrationHelper(None, None, None, None, None)

        msg = ('Failed to mount temporary folder for migration of share '
               'instance fake_id to fake_id')

        driver.CONF.set_default('migration_tmp_location', '/fake/path')

        self.mock_object(migration.ShareMigrationHelper,
                         'deny_migration_access')
        self.mock_object(migration.ShareMigrationHelper,
                         'allow_migration_access',
                         mock.Mock(return_value='fake_access_ref'))
        self.mock_object(migration.ShareMigrationHelper,
                         'cleanup_migration_access')
        self.mock_object(migration.ShareMigrationHelper, 'cleanup_temp_folder')
        self.mock_object(migration.ShareMigrationHelper,
                         'cleanup_unmount_temp_folder')
        self.mock_object(
            utils, 'execute',
            mock.Mock(side_effect=[
                None, None, None,
                exception.ShareMigrationFailed(msg)
            ]))

        self.assertRaises(exception.ShareMigrationFailed,
                          share_driver.copy_share_data, 'ctx', helper,
                          fake_share, fake_share_instance, None,
                          fake_share_instance, None, local, remote)
        args = ((None, local['access'], False), (None, remote['access'],
                                                 False))
        migration.ShareMigrationHelper.deny_migration_access.assert_has_calls(
            [mock.call(*a) for a in args])
コード例 #5
0
    def test_copy_share_data(self):
        fake_share = db_utils.create_share(id='fakeid',
                                           status=constants.STATUS_AVAILABLE,
                                           host='fake_host')
        fake_share_instance = {'id': 'fake_id', 'host': 'fake_host'}
        share_driver = self._setup_mocks_copy_share_data()
        remote = {
            'access': {
                'access_to': '192.168.0.1'
            },
            'mount': 'fake_mount',
            'umount': 'fake_umount'
        }
        local = {
            'access': {
                'access_to': '192.168.1.1'
            },
            'mount': 'fake_mount',
            'umount': 'fake_umount'
        }
        helper = migration.ShareMigrationHelper(None, None, None, None, None)

        driver.CONF.set_default('migration_tmp_location', '/fake/path')
        driver.CONF.set_default('migration_ignore_files', None)

        self.mock_object(migration.ShareMigrationHelper,
                         'deny_migration_access')
        self.mock_object(migration.ShareMigrationHelper,
                         'allow_migration_access',
                         mock.Mock(return_value='fake_access_ref'))
        self.mock_object(utils, 'execute')
        self.mock_object(share_utils.Copy, 'get_progress',
                         mock.Mock(return_value={'total_progress': 100}))

        share_driver.copy_share_data('ctx', helper, fake_share,
                                     fake_share_instance, None,
                                     fake_share_instance, None, local, remote)

        args = ((None, local['access'], False), (None, remote['access'],
                                                 False),
                ('fake_access_ref', local['access']), ('fake_access_ref',
                                                       remote['access']))
        migration.ShareMigrationHelper.deny_migration_access.assert_has_calls(
            [mock.call(*a) for a in args])