Пример #1
0
    def test_cast_create_volume(self):

        props = {}
        spec = {
            'volume_id': None,
            'source_volid': None,
            'snapshot_id': None,
            'image_id': None,
            'source_replicaid': None,
            'consistencygroup_id': None,
            'cgsnapshot_id': None
        }

        task = create_volume.VolumeCastTask(fake_scheduler_rpc_api(spec, self),
                                            fake_volume_api(spec, self),
                                            fake_db())

        task._cast_create_volume(self.ctxt, spec, props)

        spec = {
            'volume_id': 1,
            'source_volid': 2,
            'snapshot_id': 3,
            'image_id': 4,
            'source_replicaid': 5,
            'consistencygroup_id': 5,
            'cgsnapshot_id': None
        }

        task = create_volume.VolumeCastTask(fake_scheduler_rpc_api(spec, self),
                                            fake_volume_api(spec, self),
                                            fake_db())

        task._cast_create_volume(self.ctxt, spec, props)
Пример #2
0
    def test_cast_create_volume(self, mock_time):

        props = {}
        spec = {'volume_id': None,
                'source_volid': None,
                'snapshot_id': None,
                'image_id': None,
                'source_replicaid': None,
                'consistencygroup_id': None,
                'cgsnapshot_id': None}

        # Fake objects assert specs
        task = create_volume.VolumeCastTask(
            fake_volume_api.FakeSchedulerRpcAPI(spec, self),
            fake_volume_api.FakeVolumeAPI(spec, self),
            fake_volume_api.FakeDb())

        task._cast_create_volume(self.ctxt, spec, props)

        spec = {'volume_id': 1,
                'source_volid': 2,
                'snapshot_id': 3,
                'image_id': 4,
                'source_replicaid': 5,
                'consistencygroup_id': 5,
                'cgsnapshot_id': None}

        # Fake objects assert specs
        task = create_volume.VolumeCastTask(
            fake_volume_api.FakeSchedulerRpcAPI(spec, self),
            fake_volume_api.FakeVolumeAPI(spec, self),
            fake_volume_api.FakeDb())

        task._cast_create_volume(self.ctxt, spec, props)
    def test_cast_create_volume(self, consistencygroup_get_by_id, mock_time,
                                mock_extract_host, volume_get_by_id):
        mock_time.side_effect = self.time_inc
        volume = fake_volume.fake_volume_obj(self.ctxt)
        volume_get_by_id.return_value = volume
        props = {}
        cg_obj = (fake_consistencygroup.fake_consistencyobject_obj(
            self.ctxt, consistencygroup_id=1, host='host@backend#pool'))
        consistencygroup_get_by_id.return_value = cg_obj
        spec = {
            'volume_id': None,
            'volume': None,
            'source_volid': None,
            'snapshot_id': None,
            'image_id': None,
            'source_replicaid': None,
            'consistencygroup_id': None,
            'cgsnapshot_id': None,
            'group_id': None,
        }

        # Fake objects assert specs
        task = create_volume.VolumeCastTask(
            fake_volume_api.FakeSchedulerRpcAPI(spec, self),
            fake_volume_api.FakeVolumeAPI(spec, self),
            fake_volume_api.FakeDb())

        task._cast_create_volume(self.ctxt, spec, props)

        spec = {
            'volume_id': volume.id,
            'volume': volume,
            'source_volid': 2,
            'snapshot_id': 3,
            'image_id': 4,
            'source_replicaid': 5,
            'consistencygroup_id': 5,
            'cgsnapshot_id': None,
            'group_id': None,
        }

        # Fake objects assert specs
        task = create_volume.VolumeCastTask(
            fake_volume_api.FakeSchedulerRpcAPI(spec, self),
            fake_volume_api.FakeVolumeAPI(spec, self),
            fake_volume_api.FakeDb())

        task._cast_create_volume(self.ctxt, spec, props)
        consistencygroup_get_by_id.assert_called_once_with(self.ctxt, 5)
        mock_extract_host.assert_called_once_with('host@backend#pool')
Пример #4
0
    def test_cast_create_volume(self, consistencygroup_get_by_id, mock_time,
                                volume_get_by_id):
        volume = fake_volume.fake_volume_obj(self.ctxt)
        volume_get_by_id.return_value = volume

        props = {}
        consistencygroup_obj = \
            fake_consistencygroup.fake_consistencyobject_obj(
                self.ctxt, consistencygroup_id=1, host=None)
        consistencygroup_get_by_id.return_value = consistencygroup_obj
        spec = {
            'volume_id': None,
            'source_volid': None,
            'snapshot_id': None,
            'image_id': None,
            'source_replicaid': None,
            'consistencygroup_id': None,
            'cgsnapshot_id': None
        }

        # Fake objects assert specs
        task = create_volume.VolumeCastTask(
            fake_volume_api.FakeSchedulerRpcAPI(spec, self),
            fake_volume_api.FakeVolumeAPI(spec, self),
            fake_volume_api.FakeDb())

        task._cast_create_volume(self.ctxt, spec, props)

        spec = {
            'volume_id': 1,
            'source_volid': 2,
            'snapshot_id': 3,
            'image_id': 4,
            'source_replicaid': 5,
            'consistencygroup_id': 5,
            'cgsnapshot_id': None
        }

        # Fake objects assert specs
        task = create_volume.VolumeCastTask(
            fake_volume_api.FakeSchedulerRpcAPI(spec, self),
            fake_volume_api.FakeVolumeAPI(spec, self),
            fake_volume_api.FakeDb())

        task._cast_create_volume(self.ctxt, spec, props)
        consistencygroup_get_by_id.assert_called_once_with(self.ctxt, 5)