Beispiel #1
0
 def setUp(self, *args, **kwargs):
     super(BaseVolumeTestCase, self).setUp(*args, **kwargs)
     self.extension_manager = extension.ExtensionManager(
         "BaseVolumeTestCase")
     vol_tmpdir = tempfile.mkdtemp()
     self.flags(volumes_dir=vol_tmpdir)
     self.addCleanup(self._cleanup)
     self.volume = importutils.import_object(CONF.volume_manager)
     self.volume.message_api = mock.Mock()
     self.configuration = mock.Mock(conf.Configuration)
     self.context = context.get_admin_context()
     self.context.user_id = fake.USER_ID
     # NOTE(mriedem): The id is hard-coded here for tracking race fail
     # assertions with the notification code, it's part of an
     # elastic-recheck query so don't remove it or change it.
     self.project_id = '7f265bd4-3a85-465e-a899-5dc4854a86d3'
     self.context.project_id = self.project_id
     self.volume_params = {
         'status': 'creating',
         'host': CONF.host,
         'size': 1
     }
     self.mock_object(brick_lvm.LVM, 'get_all_volume_groups',
                      self.fake_get_all_volume_groups)
     fake_image.mock_image_service(self)
     self.mock_object(brick_lvm.LVM, '_vg_exists', lambda x: True)
     self.mock_object(os.path, 'exists', lambda x: True)
     self.mock_object(image_utils, 'check_available_space',
                      lambda x, y, z: True)
     self.volume.driver.set_initialized()
     self.volume.stats = {'allocated_capacity_gb': 0, 'pools': {}}
     # keep ordered record of what we execute
     self.called = []
     self.volume_api = volume_api.API()
Beispiel #2
0
 def setUp(self, *args, **kwargs):
     super(BaseVolumeTestCase, self).setUp(*args, **kwargs)
     self.extension_manager = extension.ExtensionManager(
         "BaseVolumeTestCase")
     vol_tmpdir = tempfile.mkdtemp()
     self.flags(volumes_dir=vol_tmpdir)
     self.addCleanup(self._cleanup)
     self.volume = importutils.import_object(CONF.volume_manager)
     self.volume.message_api = mock.Mock()
     self.configuration = mock.Mock(conf.Configuration)
     self.context = context.get_admin_context()
     self.context.user_id = fake.USER_ID
     # NOTE(mriedem): The id is hard-coded here for tracking race fail
     # assertions with the notification code, it's part of an
     # elastic-recheck query so don't remove it or change it.
     self.project_id = '7f265bd4-3a85-465e-a899-5dc4854a86d3'
     self.context.project_id = self.project_id
     self.volume_params = {
         'status': 'creating',
         'host': CONF.host,
         'size': 1}
     self.mock_object(brick_lvm.LVM,
                      'get_all_volume_groups',
                      self.fake_get_all_volume_groups)
     fake_image.mock_image_service(self)
     self.mock_object(brick_lvm.LVM, '_vg_exists', lambda x: True)
     self.mock_object(os.path, 'exists', lambda x: True)
     self.volume.driver.set_initialized()
     self.volume.stats = {'allocated_capacity_gb': 0,
                          'pools': {}}
     # keep ordered record of what we execute
     self.called = []
     self.volume_api = volume_api.API()
Beispiel #3
0
 def setUp(self):
     super(VolumeApiTest, self).setUp()
     self.ext_mgr = extensions.ExtensionManager()
     self.ext_mgr.extensions = {}
     fake_image.mock_image_service(self)
     self.controller = volumes.VolumeController(self.ext_mgr)
     self.maxDiff = None
     self.ctxt = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
Beispiel #4
0
    def setUp(self):
        super(VolumeApiTest, self).setUp()
        self.ext_mgr = extensions.ExtensionManager()
        self.ext_mgr.extensions = {}
        fake_image.mock_image_service(self)
        self.controller = volumes.VolumeController(self.ext_mgr)

        self.flags(host='fake')
        self.ctxt = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
Beispiel #5
0
    def setUp(self):
        super(VolumeApiTest, self).setUp()
        self.ext_mgr = extensions.ExtensionManager()
        self.ext_mgr.extensions = {}
        fake_image.mock_image_service(self)
        self.controller = volumes.VolumeController(self.ext_mgr)

        self.flags(host='fake')
        self.ctxt = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
        # This will be cleaned up by the NestedTempfile fixture in base class
        self.tmp_path = self.useFixture(fixtures.TempDir()).path
Beispiel #6
0
    def setUp(self):
        super(VolumeApiTest, self).setUp()
        self.ext_mgr = extensions.ExtensionManager()
        self.ext_mgr.extensions = {}
        fake_image.mock_image_service(self)
        self.controller = volumes.VolumeController(self.ext_mgr)

        self.flags(host='fake')
        self.ctxt = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
        # This will be cleaned up by the NestedTempfile fixture in base class
        self.tmp_path = self.useFixture(fixtures.TempDir()).path
Beispiel #7
0
    def setUp(self):
        super(VolumeApiTest, self).setUp()
        self.ext_mgr = extensions.ExtensionManager()
        self.ext_mgr.extensions = {}
        fake_image.mock_image_service(self)
        self.controller = volumes.VolumeController(self.ext_mgr)

        self.stubs.Set(db, 'volume_get_all', stubs.stub_volume_get_all)
        self.patch('cinder.db.service_get_all',
                   autospec=True,
                   return_value=stubs.stub_service_get_all(None))
        self.stubs.Set(volume_api.API, 'delete', stubs.stub_volume_delete)
Beispiel #8
0
    def setUp(self):
        super(VolumeApiTest, self).setUp()
        self.ext_mgr = extensions.ExtensionManager()
        self.ext_mgr.extensions = {}
        fake_image.mock_image_service(self)
        self.controller = volumes.VolumeController(self.ext_mgr)

        self.stubs.Set(db, 'volume_get_all', stubs.stub_volume_get_all)
        self.patch(
            'cinder.db.service_get_all', autospec=True,
            return_value=stubs.stub_service_get_all(None))
        self.stubs.Set(volume_api.API, 'delete', stubs.stub_volume_delete)
Beispiel #9
0
 def setUp(self):
     super(CinderPolicyTests, self).setUp()
     self.project_id = fake_constants.PROJECT_ID
     self.other_project_id = fake_constants.PROJECT2_ID
     self.admin_context = cinder_context.RequestContext(
         user_id=uuid.uuid4().hex,
         project_id=self.project_id,
         roles=['admin'])
     self.user_context = cinder_context.RequestContext(
         user_id=uuid.uuid4().hex,
         project_id=self.project_id,
         roles=['non-admin'])
     self.other_user_context = cinder_context.RequestContext(
         user_id=uuid.uuid4().hex,
         project_id=self.other_project_id,
         roles=['non-admin'])
     fake_image.mock_image_service(self)
Beispiel #10
0
 def setUp(self):
     super(CinderPolicyTests, self).setUp()
     self.project_id = fake_constants.PROJECT_ID
     self.other_project_id = fake_constants.PROJECT2_ID
     self.admin_context = cinder_context.RequestContext(
         user_id=uuid.uuid4().hex, project_id=self.project_id,
         roles=['admin']
     )
     self.user_context = cinder_context.RequestContext(
         user_id=uuid.uuid4().hex, project_id=self.project_id,
         roles=['non-admin']
     )
     self.other_user_context = cinder_context.RequestContext(
         user_id=uuid.uuid4().hex, project_id=self.other_project_id,
         roles=['non-admin']
     )
     fake_image.mock_image_service(self)
Beispiel #11
0
 def setUp(self):
     super(CinderPolicyTests, self).setUp()
     self.project_id = fake_constants.PROJECT_ID
     self.other_project_id = fake_constants.PROJECT2_ID
     self.admin_context = cinder_context.RequestContext(
         user_id=fake_constants.USER_ID, project_id=self.project_id,
         roles=['admin']
     )
     self.other_admin_context = cinder_context.RequestContext(
         user_id=fake_constants.USER_ID, project_id=self.other_project_id,
         roles=['admin']
     )
     self.user_context = cinder_context.RequestContext(
         user_id=fake_constants.USER2_ID, project_id=self.project_id,
         roles=['non-admin']
     )
     self.other_user_context = cinder_context.RequestContext(
         user_id=fake_constants.USER3_ID, project_id=self.other_project_id,
         roles=['non-admin']
     )
     self.system_admin_context = cinder_context.RequestContext(
         user_id=fake_constants.USER_ID, project_id=self.project_id,
         roles=['admin'], system_scope='all')
     fake_image.mock_image_service(self)
Beispiel #12
0
 def setUp(self):
     super(VolumeReimageTestCase, self).setUp()
     self.patch('cinder.volume.volume_utils.clear_volume', autospec=True)
     fake_image.mock_image_service(self)
     self.image_meta = fake_image.FakeImageService().show(
         self.context, fake_constants.IMAGE_ID)