コード例 #1
0
    def test_list_volume_mappings_with_filters(self):
        volume1 = utils.create_test_volume(id=1,
                                           volume_provider='provider-one',
                                           uuid=uuidutils.generate_uuid(),
                                           context=self.context)
        volume_mapping1 = utils.create_test_volume_mapping(
            id=1,
            volume_id=volume1.id,
            uuid=uuidutils.generate_uuid(),
            context=self.context)
        volume2 = utils.create_test_volume(id=2,
                                           volume_provider='provider-two',
                                           uuid=uuidutils.generate_uuid(),
                                           context=self.context)
        volume_mapping2 = utils.create_test_volume_mapping(
            id=2,
            uuid=uuidutils.generate_uuid(),
            volume_id=volume2.id,
            context=self.context)

        res = dbapi.list_volume_mappings(
            self.context, filters={'volume_provider': 'provider-one'})
        self.assertEqual([volume_mapping1.id], [r.id for r in res])

        res = dbapi.list_volume_mappings(
            self.context, filters={'volume_provider': 'provider-two'})
        self.assertEqual([volume_mapping2.id], [r.id for r in res])

        res = dbapi.list_volume_mappings(
            self.context, filters={'volume_provider': 'bad-provider'})
        self.assertEqual([], [r.id for r in res])

        res = dbapi.list_volume_mappings(
            self.context, filters={'volume_provider': volume1.volume_provider})
        self.assertEqual([volume_mapping1.id], [r.id for r in res])
コード例 #2
0
ファイル: test_volume.py プロジェクト: openstack/higgins
 def test_create_volume_already_exists(self):
     utils.create_test_volume(context=self.context,
                              uuid='123')
     with self.assertRaisesRegex(exception.VolumeAlreadyExists,
                                 'A volume with UUID 123.*'):
         utils.create_test_volume(context=self.context,
                                  uuid='123')
コード例 #3
0
ファイル: test_volume.py プロジェクト: wkite/zun
    def test_update_volume(self):
        volume = utils.create_test_volume(context=self.context)
        old_conn_info = volume.connection_info
        new_conn_info = 'new-conn-info'
        self.assertNotEqual(old_conn_info, new_conn_info)

        res = dbapi.update_volume(self.context, volume.id,
                                  {'connection_info': new_conn_info})
        self.assertEqual(new_conn_info, res.connection_info)
コード例 #4
0
ファイル: test_volume.py プロジェクト: openstack/higgins
    def test_update_volume(self):
        volume = utils.create_test_volume(context=self.context)
        old_conn_info = volume.connection_info
        new_conn_info = 'new-conn-info'
        self.assertNotEqual(old_conn_info, new_conn_info)

        res = dbapi.update_volume(self.context, volume.id,
                                  {'connection_info': new_conn_info})
        self.assertEqual(new_conn_info, res.connection_info)
コード例 #5
0
 def test_list_volume_mappings(self):
     uuids = []
     for i in range(1, 6):
         volume = utils.create_test_volume(uuid=uuidutils.generate_uuid(),
                                           context=self.context)
         volume_mapping = utils.create_test_volume_mapping(
             uuid=uuidutils.generate_uuid(),
             volume_id=volume.id,
             context=self.context)
         uuids.append(six.text_type(volume_mapping['uuid']))
     res = dbapi.list_volume_mappings(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
コード例 #6
0
    def test_list_volume_mappings_with_filters(self):
        volume1 = utils.create_test_volume(
            id=1,
            volume_provider='provider-one',
            uuid=uuidutils.generate_uuid(),
            context=self.context)
        volume_mapping1 = utils.create_test_volume_mapping(
            id=1,
            volume_id=volume1.id,
            uuid=uuidutils.generate_uuid(),
            context=self.context)
        volume2 = utils.create_test_volume(
            id=2,
            volume_provider='provider-two',
            uuid=uuidutils.generate_uuid(),
            context=self.context)
        volume_mapping2 = utils.create_test_volume_mapping(
            id=2,
            uuid=uuidutils.generate_uuid(),
            volume_id=volume2.id,
            context=self.context)

        res = dbapi.list_volume_mappings(
            self.context, filters={'volume_provider': 'provider-one'})
        self.assertEqual([volume_mapping1.id], [r.id for r in res])

        res = dbapi.list_volume_mappings(
            self.context, filters={'volume_provider': 'provider-two'})
        self.assertEqual([volume_mapping2.id], [r.id for r in res])

        res = dbapi.list_volume_mappings(
            self.context, filters={'volume_provider': 'bad-provider'})
        self.assertEqual([], [r.id for r in res])

        res = dbapi.list_volume_mappings(
            self.context,
            filters={'volume_provider': volume1.volume_provider})
        self.assertEqual([volume_mapping1.id], [r.id for r in res])
コード例 #7
0
 def test_list_volume_mappings(self):
     uuids = []
     for i in range(1, 6):
         volume = utils.create_test_volume(
             uuid=uuidutils.generate_uuid(),
             context=self.context)
         volume_mapping = utils.create_test_volume_mapping(
             uuid=uuidutils.generate_uuid(),
             volume_id=volume.id,
             context=self.context)
         uuids.append(six.text_type(volume_mapping['uuid']))
     res = dbapi.list_volume_mappings(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
コード例 #8
0
    def test_list_volume_mappings_sorted(self):
        uuids = []
        for i in range(5):
            volume = utils.create_test_volume(uuid=uuidutils.generate_uuid(),
                                              context=self.context)
            volume_mapping = utils.create_test_volume_mapping(
                uuid=uuidutils.generate_uuid(),
                volume_id=volume.id,
                context=self.context)
            uuids.append(six.text_type(volume_mapping.uuid))
        res = dbapi.list_volume_mappings(self.context, sort_key='uuid')
        res_uuids = [r.uuid for r in res]
        self.assertEqual(sorted(uuids), res_uuids)

        self.assertRaises(exception.InvalidParameterValue,
                          dbapi.list_volume_mappings,
                          self.context,
                          sort_key='foo')
コード例 #9
0
    def test_list_volume_mappings_sorted(self):
        uuids = []
        for i in range(5):
            volume = utils.create_test_volume(
                uuid=uuidutils.generate_uuid(),
                context=self.context)
            volume_mapping = utils.create_test_volume_mapping(
                uuid=uuidutils.generate_uuid(),
                volume_id=volume.id,
                context=self.context)
            uuids.append(six.text_type(volume_mapping.uuid))
        res = dbapi.list_volume_mappings(self.context, sort_key='uuid')
        res_uuids = [r.uuid for r in res]
        self.assertEqual(sorted(uuids), res_uuids)

        self.assertRaises(exception.InvalidParameterValue,
                          dbapi.list_volume_mappings,
                          self.context,
                          sort_key='foo')
コード例 #10
0
ファイル: test_volume.py プロジェクト: wkite/zun
 def test_update_volume_uuid(self):
     volume = utils.create_test_volume(context=self.context)
     self.assertRaises(exception.InvalidParameterValue, dbapi.update_volume,
                       self.context, volume.id, {'uuid': ''})
コード例 #11
0
ファイル: test_volume.py プロジェクト: openstack/higgins
 def test_create_volume(self):
     utils.create_test_volume(context=self.context)
コード例 #12
0
ファイル: test_volume.py プロジェクト: wkite/zun
 def test_destroy_volume(self):
     volume = utils.create_test_volume(context=self.context)
     dbapi.destroy_volume(self.context, volume.id)
     self.assertRaises(exception.VolumeNotFound, dbapi.get_volume_by_id,
                       self.context, volume.id)
コード例 #13
0
ファイル: test_volume.py プロジェクト: wkite/zun
 def test_get_volume_by_id(self):
     volume = utils.create_test_volume(context=self.context)
     res = dbapi.get_volume_by_id(self.context, volume.id)
     self.assertEqual(volume.id, res.id)
     self.assertEqual(volume.uuid, res.uuid)
コード例 #14
0
ファイル: test_volume.py プロジェクト: wkite/zun
 def test_create_volume_already_exists(self):
     utils.create_test_volume(context=self.context, uuid='123')
     with self.assertRaisesRegex(exception.VolumeAlreadyExists,
                                 'A volume with UUID 123.*'):
         utils.create_test_volume(context=self.context, uuid='123')
コード例 #15
0
ファイル: test_volume.py プロジェクト: wkite/zun
 def test_create_volume(self):
     utils.create_test_volume(context=self.context)
コード例 #16
0
ファイル: test_volume.py プロジェクト: openstack/higgins
 def test_get_volume_by_id(self):
     volume = utils.create_test_volume(context=self.context)
     res = dbapi.get_volume_by_id(self.context, volume.id)
     self.assertEqual(volume.id, res.id)
     self.assertEqual(volume.uuid, res.uuid)
コード例 #17
0
ファイル: test_volume.py プロジェクト: openstack/higgins
 def test_update_volume_uuid(self):
     volume = utils.create_test_volume(context=self.context)
     self.assertRaises(exception.InvalidParameterValue,
                       dbapi.update_volume, self.context,
                       volume.id, {'uuid': ''})
コード例 #18
0
ファイル: test_volume.py プロジェクト: openstack/higgins
 def test_destroy_volume(self):
     volume = utils.create_test_volume(context=self.context)
     dbapi.destroy_volume(self.context, volume.id)
     self.assertRaises(exception.VolumeNotFound,
                       dbapi.get_volume_by_id,
                       self.context, volume.id)