Beispiel #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])
Beispiel #2
0
 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')
Beispiel #3
0
    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)
Beispiel #4
0
    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)
Beispiel #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))
    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])
 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))
Beispiel #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')
    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')
Beispiel #10
0
 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': ''})
Beispiel #11
0
 def test_create_volume(self):
     utils.create_test_volume(context=self.context)
Beispiel #12
0
 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)
Beispiel #13
0
 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)
Beispiel #14
0
 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')
Beispiel #15
0
 def test_create_volume(self):
     utils.create_test_volume(context=self.context)
Beispiel #16
0
 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)
Beispiel #17
0
 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': ''})
Beispiel #18
0
 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)