Пример #1
0
    def test_cinder_volume_extend_detached(self):
        fv = vt_base.FakeVolume('creating',
                                'available',
                                size=1,
                                attachments=[])
        stack_name = 'test_volume_stack'

        # create script
        self._mock_create_volume(fv, stack_name)
        # update script
        self.cinder_fc.volumes.get(fv.id).AndReturn(fv)
        fv2 = vt_base.FakeLatencyVolume(life_cycle=('extending', 'extending',
                                                    'available'))
        self.cinder_fc.volumes.get(fv.id).AndReturn(fv2)

        self.cinder_fc.volumes.extend(fv.id, 2)

        self.m.ReplayAll()

        stack = utils.parse_stack(self.t, stack_name=stack_name)

        rsrc = self.create_volume(self.t, stack, 'volume')
        self.assertEqual('available', fv.status)

        props = copy.deepcopy(rsrc.properties.data)
        props['size'] = 2
        after = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(), props)

        update_task = scheduler.TaskRunner(rsrc.update, after)
        self.assertIsNone(update_task())

        self.assertEqual((rsrc.UPDATE, rsrc.COMPLETE), rsrc.state)
        self.m.VerifyAll()
Пример #2
0
    def test_cinder_volume_extend_fails_to_complete(self):
        fv = vt_base.FakeVolume('creating',
                                'available',
                                size=1,
                                attachments=[])
        stack_name = 'test_volume_stack'

        # create script
        self._mock_create_volume(fv, stack_name)
        # update script
        self.cinder_fc.volumes.get(fv.id).AndReturn(fv)
        fv2 = vt_base.FakeLatencyVolume(life_cycle=('extending', 'extending',
                                                    'error_extending'))
        self.cinder_fc.volumes.get(fv.id).AndReturn(fv2)

        self.cinder_fc.volumes.extend(fv.id, 2)

        self.m.ReplayAll()

        stack = utils.parse_stack(self.t, stack_name=stack_name)

        rsrc = self.create_volume(self.t, stack, 'volume')
        self.assertEqual('available', fv.status)

        props = copy.deepcopy(rsrc.properties.data)
        props['size'] = 2
        after = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(), props)

        update_task = scheduler.TaskRunner(rsrc.update, after)
        ex = self.assertRaises(exception.ResourceFailure, update_task)
        self.assertIn("Volume resize failed - Unknown status error_extending",
                      six.text_type(ex))

        self.assertEqual((rsrc.UPDATE, rsrc.FAILED), rsrc.state)
        self.m.VerifyAll()
Пример #3
0
    def test_volume_detach_with_latency(self):
        fv = vt_base.FakeVolume('creating', 'available')
        fva = vt_base.FakeVolume('attaching', 'in-use')
        stack_name = 'test_volume_attach_stack'

        self._mock_create_volume(fv, stack_name)
        self._mock_create_server_volume_script(fva)
        self.stub_VolumeConstraint_validate()

        # delete script
        volume_detach_cycle = 'in-use', 'detaching', 'available'
        fva = vt_base.FakeLatencyVolume(life_cycle=volume_detach_cycle)
        self.fc.volumes.get_server_volume(u'WikiDatabase',
                                          'vol-123').AndReturn(fva)
        self.cinder_fc.volumes.get(fva.id).AndReturn(fva)
        self.fc.volumes.delete_server_volume(
            'WikiDatabase', 'vol-123').MultipleTimes().AndReturn(None)
        self.fc.volumes.get_server_volume(u'WikiDatabase',
                                          'vol-123').AndReturn(fva)
        self.fc.volumes.get_server_volume(
            u'WikiDatabase', 'vol-123').AndRaise(fakes_v1_1.fake_exception())

        self.m.ReplayAll()

        stack = utils.parse_stack(self.t, stack_name=stack_name)

        self.create_volume(self.t, stack, 'DataVolume')
        self.assertEqual('available', fv.status)
        rsrc = self.create_attachment(self.t, stack, 'MountPoint')

        scheduler.TaskRunner(rsrc.delete)()

        self.m.VerifyAll()
Пример #4
0
    def test_cinder_volume_extend_attached(self):
        # create script
        fv = vt_base.FakeVolume('creating', 'available')
        stack_name = 'test_volume_stack'
        self.stub_VolumeConstraint_validate()
        self._mock_create_volume(fv, stack_name)

        fva = vt_base.FakeVolume('attaching', 'in-use')
        self._mock_create_server_volume_script(fva)

        # update script
        attachments = [{
            'id': 'vol-123',
            'device': '/dev/vdc',
            'server_id': u'WikiDatabase'
        }]
        fv2 = vt_base.FakeVolume('available',
                                 'available',
                                 attachments=attachments,
                                 size=1)
        self.cinder_fc.volumes.get(fv2.id).AndReturn(fv2)

        # detach script
        fvd = vt_base.FakeVolume('in-use', 'available')
        self.fc.volumes.get_server_volume(u'WikiDatabase',
                                          'vol-123').AndReturn(fvd)
        self.cinder_fc.volumes.get(fvd.id).AndReturn(fvd)
        self.fc.volumes.delete_server_volume('WikiDatabase', 'vol-123')
        self.fc.volumes.get_server_volume(u'WikiDatabase',
                                          'vol-123').AndReturn(fvd)
        self.fc.volumes.get_server_volume(u'WikiDatabase', 'vol-123').AndRaise(
            fakes_v1_1.fake_exception())

        # resize script
        fvr = vt_base.FakeLatencyVolume(life_cycle=('extending', 'extending',
                                                    'available'))
        self.cinder_fc.volumes.get(fvr.id).AndReturn(fvr)

        self.cinder_fc.volumes.extend(fvr.id, 2)

        # attach script
        fva2 = vt_base.FakeVolume('attaching', 'in-use')
        self._mock_create_server_volume_script(fva2, update=True)

        self.m.ReplayAll()

        stack = utils.parse_stack(self.t, stack_name=stack_name)

        rsrc = self.create_volume(self.t, stack, 'volume')
        self.assertEqual('available', fv.status)
        self.create_attachment(self.t, stack, 'attachment')

        props = copy.deepcopy(rsrc.properties.data)
        props['size'] = 2
        after = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(), props)

        update_task = scheduler.TaskRunner(rsrc.update, after)
        self.assertIsNone(update_task())

        self.assertEqual((rsrc.UPDATE, rsrc.COMPLETE), rsrc.state)
        self.m.VerifyAll()