コード例 #1
0
ファイル: test_share.py プロジェクト: mbr4v0v/manila
    def test_create_delete_share_snapshot(self):
        """Test share's snapshot can be created and deleted."""
        def _fake_create_snapshot(self, *args, **kwargs):
            snapshot['progress'] = '99%'
            return snapshot

        self.stubs.Set(FakeShareDriver, "create_snapshot",
                       _fake_create_snapshot)

        share = self._create_share()
        share_id = share['id']
        snapshot = self._create_snapshot(share_id=share_id)
        snapshot_id = snapshot['id']

        self.share_manager.create_snapshot(self.context, share_id, snapshot_id)
        self.assertEqual(
            share_id,
            db.share_snapshot_get(context.get_admin_context(),
                                  snapshot_id).share_id)

        snap = db.share_snapshot_get(self.context, snapshot_id)
        self.assertEqual(snap['status'], 'available')

        self.share_manager.delete_snapshot(self.context, snapshot_id)
        self.assertRaises(exception.NotFound, db.share_snapshot_get,
                          self.context, snapshot_id)
コード例 #2
0
ファイル: test_share.py プロジェクト: mbr4v0v/manila
    def test_create_delete_share_snapshot_error(self):
        """Test snapshot can be created and deleted with error."""
        def _fake_create_delete_snapshot(self, *args, **kwargs):
            raise exception.NotFound()

        self.stubs.Set(FakeShareDriver, "create_snapshot",
                       _fake_create_delete_snapshot)
        self.stubs.Set(FakeShareDriver, "delete_snapshot",
                       _fake_create_delete_snapshot)

        share = self._create_share()
        share_id = share['id']
        snapshot = self._create_snapshot(share_id=share_id)
        snapshot_id = snapshot['id']

        self.assertRaises(exception.NotFound,
                          self.share_manager.create_snapshot, self.context,
                          share_id, snapshot_id)

        snap = db.share_snapshot_get(self.context, snapshot_id)
        self.assertEqual(snap['status'], 'error')

        self.assertRaises(exception.NotFound,
                          self.share_manager.delete_snapshot, self.context,
                          snapshot_id)

        self.assertEqual(
            'error_deleting',
            db.share_snapshot_get(self.context, snapshot_id).status)
コード例 #3
0
ファイル: test_share.py プロジェクト: grafuls/manila
    def test_create_delete_share_snapshot_error(self):
        """Test snapshot can be created and deleted with error."""

        def _fake_create_delete_snapshot(self, *args, **kwargs):
            raise exception.NotFound()

        self.stubs.Set(FakeShareDriver, "create_snapshot",
                       _fake_create_delete_snapshot)
        self.stubs.Set(FakeShareDriver, "delete_snapshot",
                       _fake_create_delete_snapshot)

        share = self._create_share()
        share_id = share['id']
        snapshot = self._create_snapshot(share_id=share_id)
        snapshot_id = snapshot['id']

        self.assertRaises(exception.NotFound,
                          self.share_manager.create_snapshot,
                          self.context, share_id, snapshot_id)

        snap = db.share_snapshot_get(self.context, snapshot_id)
        self.assertEqual(snap['status'], 'error')

        self.assertRaises(exception.NotFound,
                          self.share_manager.delete_snapshot,
                          self.context, snapshot_id)

        self.assertEqual('error_deleting', db.share_snapshot_get(
            self.context, snapshot_id).status)
コード例 #4
0
ファイル: test_share.py プロジェクト: grafuls/manila
    def test_create_delete_share_snapshot(self):
        """Test share's snapshot can be created and deleted."""

        def _fake_create_snapshot(self, *args, **kwargs):
            snapshot['progress'] = '99%'
            return snapshot

        self.stubs.Set(FakeShareDriver, "create_snapshot",
                       _fake_create_snapshot)

        share = self._create_share()
        share_id = share['id']
        snapshot = self._create_snapshot(share_id=share_id)
        snapshot_id = snapshot['id']

        self.share_manager.create_snapshot(self.context, share_id, snapshot_id)
        self.assertEqual(share_id,
                         db.share_snapshot_get(context.get_admin_context(),
                                               snapshot_id).share_id)

        snap = db.share_snapshot_get(self.context, snapshot_id)
        self.assertEqual(snap['status'], 'available')

        self.share_manager.delete_snapshot(self.context, snapshot_id)
        self.assertRaises(exception.NotFound,
                          db.share_snapshot_get,
                          self.context,
                          snapshot_id)
コード例 #5
0
ファイル: test_share_api.py プロジェクト: resker/manila
 def test_get_snapshot(self):
     fake_get_snap = {"fake_key": "fake_val"}
     self.mox.StubOutWithMock(share_api.policy, "check_policy")
     share_api.policy.check_policy(self.context, "share", "get_snapshot")
     self.mox.StubOutWithMock(db_driver, "share_snapshot_get")
     db_driver.share_snapshot_get(self.context, "fakeid").AndReturn(fake_get_snap)
     self.mox.ReplayAll()
     rule = self.api.get_snapshot(self.context, "fakeid")
     self.assertEqual(rule, fake_get_snap)
コード例 #6
0
ファイル: test_share_api.py プロジェクト: rpafford/manila
 def test_get_snapshot(self):
     fake_get_snap = {'fake_key': 'fake_val'}
     self.mox.StubOutWithMock(share_api.policy, 'check_policy')
     share_api.policy.check_policy(self.context, 'share', 'get_snapshot')
     self.mox.StubOutWithMock(db_driver, 'share_snapshot_get')
     db_driver.share_snapshot_get(self.context,
                                  'fakeid').AndReturn(fake_get_snap)
     self.mox.ReplayAll()
     rule = self.api.get_snapshot(self.context, 'fakeid')
     self.assertEqual(rule, fake_get_snap)
コード例 #7
0
ファイル: test_manager.py プロジェクト: Hussnain1/manila
    def test_create_delete_share_snapshot_error(self):
        """Test snapshot can be created and deleted with error."""
        def _raise_not_found(self, *args, **kwargs):
            raise exception.NotFound()

        self.stubs.Set(self.share_manager.driver, "create_snapshot",
                       mock.Mock(side_effect=_raise_not_found))
        self.stubs.Set(self.share_manager.driver, "delete_snapshot",
                       mock.Mock(side_effect=_raise_not_found))

        share = self._create_share()
        share_id = share['id']
        snapshot = self._create_snapshot(share_id=share_id)
        snapshot_id = snapshot['id']

        self.assertRaises(exception.NotFound,
                          self.share_manager.create_snapshot, self.context,
                          share_id, snapshot_id)

        snap = db.share_snapshot_get(self.context, snapshot_id)
        self.assertEqual(snap['status'], 'error')

        self.assertRaises(exception.NotFound,
                          self.share_manager.delete_snapshot, self.context,
                          snapshot_id)

        self.assertEqual(
            'error_deleting',
            db.share_snapshot_get(self.context, snapshot_id).status)
        self.share_manager.driver.create_snapshot.assert_called_once_with(
            self.context,
            utils.IsAMatcher(models.ShareSnapshot),
            share_server=None)
        self.share_manager.driver.delete_snapshot.assert_called_once_with(
            utils.IsAMatcher(context.RequestContext),
            utils.IsAMatcher(models.ShareSnapshot),
            share_server=None)
コード例 #8
0
ファイル: test_share.py プロジェクト: mbr4v0v/manila
    def test_delete_share_if_busy(self):
        """Test snapshot could not be deleted if busy."""
        def _fake_delete_snapshot(self, *args, **kwargs):
            raise exception.ShareSnapshotIsBusy(snapshot_name='fakename')

        self.stubs.Set(FakeShareDriver, "delete_snapshot",
                       _fake_delete_snapshot)
        share = self._create_share(status='ACTIVE')
        snapshot = self._create_snapshot(share_id=share['id'])
        snapshot_id = snapshot['id']

        self.share_manager.delete_snapshot(self.context, snapshot_id)

        snap = db.share_snapshot_get(self.context, snapshot_id)
        self.assertEqual(snap['status'], 'available')
コード例 #9
0
ファイル: test_manager.py プロジェクト: bobcallaway/manila
    def test_create_delete_share_snapshot_error(self):
        """Test snapshot can be created and deleted with error."""

        def _raise_not_found(self, *args, **kwargs):
            raise exception.NotFound()

        self.stubs.Set(self.share_manager.driver, "create_snapshot",
                       mock.Mock(side_effect=_raise_not_found))
        self.stubs.Set(self.share_manager.driver, "delete_snapshot",
                       mock.Mock(side_effect=_raise_not_found))

        share = self._create_share()
        share_id = share['id']
        snapshot = self._create_snapshot(share_id=share_id)
        snapshot_id = snapshot['id']

        self.assertRaises(exception.NotFound,
                          self.share_manager.create_snapshot,
                          self.context, share_id, snapshot_id)

        snap = db.share_snapshot_get(self.context, snapshot_id)
        self.assertEqual(snap['status'], 'error')

        self.assertRaises(exception.NotFound,
                          self.share_manager.delete_snapshot,
                          self.context, snapshot_id)

        self.assertEqual('error_deleting', db.share_snapshot_get(
            self.context, snapshot_id).status)
        self.share_manager.driver.create_snapshot.assert_called_once_with(
            self.context, utils.IsAMatcher(models.ShareSnapshot),
            share_server=None)
        self.share_manager.driver.delete_snapshot.assert_called_once_with(
            utils.IsAMatcher(context.RequestContext),
            utils.IsAMatcher(models.ShareSnapshot),
            share_server=None)
コード例 #10
0
ファイル: test_share.py プロジェクト: grafuls/manila
    def test_delete_share_if_busy(self):
        """Test snapshot could not be deleted if busy."""

        def _fake_delete_snapshot(self, *args, **kwargs):
            raise exception.ShareSnapshotIsBusy(snapshot_name='fakename')

        self.stubs.Set(FakeShareDriver, "delete_snapshot",
                       _fake_delete_snapshot)
        share = self._create_share(status='ACTIVE')
        snapshot = self._create_snapshot(share_id=share['id'])
        snapshot_id = snapshot['id']

        self.share_manager.delete_snapshot(self.context, snapshot_id)

        snap = db.share_snapshot_get(self.context, snapshot_id)
        self.assertEqual(snap['status'], 'available')
コード例 #11
0
ファイル: test_admin_actions.py プロジェクト: sajuptpm/manila
 def test_invalid_status_for_snapshot(self):
     # snapshot in 'available'
     share = db_utils.create_share()
     snapshot = db_utils.create_snapshot(status=constants.STATUS_AVAILABLE, share_id=share["id"])
     req = webob.Request.blank("/v1/fake/snapshots/%s/action" % snapshot["id"])
     req.method = "POST"
     req.headers["content-type"] = "application/json"
     # 'attaching' is not a valid status for snapshots
     req.body = six.b(jsonutils.dumps({"os-reset_status": {"status": "attaching"}}))
     # attach admin context to request
     req.environ["manila.context"] = self.admin_context
     resp = req.get_response(app())
     # request is accepted
     self.assertEqual(resp.status_int, 400)
     snapshot = db.share_snapshot_get(self.admin_context, snapshot["id"])
     # status is still 'available'
     self.assertEqual(snapshot["status"], constants.STATUS_AVAILABLE)
コード例 #12
0
ファイル: test_admin_actions.py プロジェクト: sajuptpm/manila
 def test_snapshot_reset_status(self):
     # snapshot in 'error_deleting'
     share = db_utils.create_share()
     snapshot = db_utils.create_snapshot(status=constants.STATUS_ERROR_DELETING, share_id=share["id"])
     req = webob.Request.blank("/v1/fake/snapshots/%s/action" % snapshot["id"])
     req.method = "POST"
     req.headers["content-type"] = "application/json"
     # request status of 'error'
     req.body = six.b(jsonutils.dumps({"os-reset_status": {"status": constants.STATUS_ERROR}}))
     # attach admin context to request
     req.environ["manila.context"] = self.admin_context
     resp = req.get_response(app())
     # request is accepted
     self.assertEqual(resp.status_int, 202)
     snapshot = db.share_snapshot_get(self.admin_context, snapshot["id"])
     # status changed to 'error'
     self.assertEqual(snapshot["status"], constants.STATUS_ERROR)
コード例 #13
0
ファイル: test_manager.py プロジェクト: Hussnain1/manila
    def test_delete_share_if_busy(self):
        """Test snapshot could not be deleted if busy."""
        def _raise_share_snapshot_is_busy(self, *args, **kwargs):
            raise exception.ShareSnapshotIsBusy(snapshot_name='fakename')

        self.stubs.Set(self.share_manager.driver, "delete_snapshot",
                       mock.Mock(side_effect=_raise_share_snapshot_is_busy))
        share = self._create_share(status='ACTIVE')
        snapshot = self._create_snapshot(share_id=share['id'])
        snapshot_id = snapshot['id']

        self.share_manager.delete_snapshot(self.context, snapshot_id)

        snap = db.share_snapshot_get(self.context, snapshot_id)
        self.assertEqual(snap['status'], 'available')
        self.share_manager.driver.delete_snapshot.assert_called_once_with(
            utils.IsAMatcher(context.RequestContext),
            utils.IsAMatcher(models.ShareSnapshot),
            share_server=None)
コード例 #14
0
ファイル: test_admin_actions.py プロジェクト: nkrinner/manila
 def test_snapshot_reset_status(self):
     # snapshot in 'error_deleting'
     share = db.share_create(self.admin_context, {})
     snapshot = db.share_snapshot_create(self.admin_context,
         {'status': 'error_deleting', 'share_id': share['id']})
     req = webob.Request.blank('/v1/fake/snapshots/%s/action' %
                               snapshot['id'])
     req.method = 'POST'
     req.headers['content-type'] = 'application/json'
     # request status of 'error'
     req.body = jsonutils.dumps({'os-reset_status': {'status': 'error'}})
     # attach admin context to request
     req.environ['manila.context'] = self.admin_context
     resp = req.get_response(app())
     # request is accepted
     self.assertEqual(resp.status_int, 202)
     snapshot = db.share_snapshot_get(self.admin_context, snapshot['id'])
     # status changed to 'error'
     self.assertEqual(snapshot['status'], 'error')
コード例 #15
0
ファイル: test_manager.py プロジェクト: bobcallaway/manila
    def test_delete_share_if_busy(self):
        """Test snapshot could not be deleted if busy."""

        def _raise_share_snapshot_is_busy(self, *args, **kwargs):
            raise exception.ShareSnapshotIsBusy(snapshot_name='fakename')

        self.stubs.Set(self.share_manager.driver, "delete_snapshot",
                       mock.Mock(side_effect=_raise_share_snapshot_is_busy))
        share = self._create_share(status='ACTIVE')
        snapshot = self._create_snapshot(share_id=share['id'])
        snapshot_id = snapshot['id']

        self.share_manager.delete_snapshot(self.context, snapshot_id)

        snap = db.share_snapshot_get(self.context, snapshot_id)
        self.assertEqual(snap['status'], 'available')
        self.share_manager.driver.delete_snapshot.assert_called_once_with(
            utils.IsAMatcher(context.RequestContext),
            utils.IsAMatcher(models.ShareSnapshot),
            share_server=None)
コード例 #16
0
ファイル: test_admin_actions.py プロジェクト: nkrinner/manila
 def test_invalid_status_for_snapshot(self):
     # snapshot in 'available'
     share = db.share_create(self.admin_context, {})
     snapshot = db.share_snapshot_create(self.admin_context,
         {'status': 'available', 'share_id': share['id']})
     req = webob.Request.blank('/v1/fake/snapshots/%s/action' %
                               snapshot['id'])
     req.method = 'POST'
     req.headers['content-type'] = 'application/json'
     # 'attaching' is not a valid status for snapshots
     req.body = jsonutils.dumps({'os-reset_status': {'status':
                                                     'attaching'}})
     # attach admin context to request
     req.environ['manila.context'] = self.admin_context
     resp = req.get_response(app())
     # request is accepted
     self.assertEqual(resp.status_int, 400)
     snapshot = db.share_snapshot_get(self.admin_context, snapshot['id'])
     # status is still 'available'
     self.assertEqual(snapshot['status'], 'available')
コード例 #17
0
 def test_snapshot_reset_status(self):
     # snapshot in 'error_deleting'
     share = db.share_create(self.admin_context, {})
     snapshot = db.share_snapshot_create(self.admin_context, {
         'status': 'error_deleting',
         'share_id': share['id']
     })
     req = webob.Request.blank('/v1/fake/snapshots/%s/action' %
                               snapshot['id'])
     req.method = 'POST'
     req.headers['content-type'] = 'application/json'
     # request status of 'error'
     req.body = jsonutils.dumps({'os-reset_status': {'status': 'error'}})
     # attach admin context to request
     req.environ['manila.context'] = self.admin_context
     resp = req.get_response(app())
     # request is accepted
     self.assertEqual(resp.status_int, 202)
     snapshot = db.share_snapshot_get(self.admin_context, snapshot['id'])
     # status changed to 'error'
     self.assertEqual(snapshot['status'], 'error')
コード例 #18
0
 def test_invalid_status_for_snapshot(self):
     # snapshot in 'available'
     share = db.share_create(self.admin_context, {})
     snapshot = db.share_snapshot_create(self.admin_context,
                                         {
                                             'status': 'available',
                                             'share_id': share['id']
                                         })
     req = webob.Request.blank('/v1/fake/snapshots/%s/action' %
                               snapshot['id'])
     req.method = 'POST'
     req.headers['content-type'] = 'application/json'
     # 'attaching' is not a valid status for snapshots
     req.body = jsonutils.dumps({'os-reset_status': {'status':
                                                     'attaching'}})
     # attach admin context to request
     req.environ['manila.context'] = self.admin_context
     resp = req.get_response(app())
     # request is accepted
     self.assertEqual(resp.status_int, 400)
     snapshot = db.share_snapshot_get(self.admin_context, snapshot['id'])
     # status is still 'available'
     self.assertEqual(snapshot['status'], 'available')