当前位置: 首页>>代码示例>>Python>>正文


Python TestDisk.delete方法代码示例

本文整理汇总了Python中ovs.dal.hybrids.t_testdisk.TestDisk.delete方法的典型用法代码示例。如果您正苦于以下问题:Python TestDisk.delete方法的具体用法?Python TestDisk.delete怎么用?Python TestDisk.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ovs.dal.hybrids.t_testdisk.TestDisk的用法示例。


在下文中一共展示了TestDisk.delete方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _clean_all

# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import delete [as 别名]
 def _clean_all(self):
     """
     Cleans all disks and machines
     """
     machine = TestMachine()
     prefix = '{0}_{1}_'.format(DataObject.NAMESPACE, machine._classname)
     keys = self.persistent.prefix(prefix)
     for key in keys:
         try:
             guid = key.replace(prefix, '')
             machine = TestMachine(guid)
             for disk in machine.disks:
                 disk.delete()
             machine.delete()
         except (ObjectNotFoundException, ValueError):
             pass
     for key in self.persistent.prefix('ovs_reverseindex_{0}'.format(machine._classname)):
         self.persistent.delete(key)
     disk = TestDisk()
     prefix = '{0}_{1}_'.format(DataObject.NAMESPACE, disk._classname)
     keys = self.persistent.prefix(prefix)
     for key in keys:
         try:
             guid = key.replace(prefix, '')
             disk = TestDisk(guid)
             disk.delete()
         except (ObjectNotFoundException, ValueError):
             pass
     for key in self.persistent.prefix('ovs_reverseindex_{0}'.format(disk._classname)):
         self.persistent.delete(key)
开发者ID:grimpy,项目名称:openvstorage,代码行数:32,代码来源:performance_test.py

示例2: test_save_deleted

# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import delete [as 别名]
 def test_save_deleted(self):
     """
     Validates whether saving a previously deleted object raises
     """
     disk = TestDisk()
     disk.name = 'disk'
     disk.save()
     disk.delete()
     self.assertRaises(ObjectNotFoundException, disk.save, 'Cannot resave a deleted object')
开发者ID:BillTheBest,项目名称:openvstorage,代码行数:11,代码来源:test_basic.py

示例3: test_newobject_delete

# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import delete [as 别名]
 def test_newobject_delete(self):
     """
     Validates the behavior on object deletions
     """
     disk = TestDisk()
     disk.name = 'disk'
     disk.save()
     # An object should always have a guid
     guid = disk.guid
     self.assertIsNotNone(guid, 'Guid should not be None')
     # After deleting, the object should not be retreivable
     disk.delete()
     self.assertRaises(Exception, TestDisk, guid, None)
开发者ID:BillTheBest,项目名称:openvstorage,代码行数:15,代码来源:test_basic.py

示例4: test_primarykeys

# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import delete [as 别名]
 def test_primarykeys(self):
     """
     Validates whether the primary keys are kept in sync
     """
     disk = TestDisk()
     disk.name = 'disk'
     keys = DataList.get_pks(disk._namespace, disk._name)
     self.assertEqual(len(keys), 0, 'There should be no primary keys ({0})'.format(len(keys)))
     disk.save()
     keys = DataList.get_pks(disk._namespace, disk._name)
     self.assertEqual(len(keys), 1, 'There should be one primary key ({0})'.format(len(keys)))
     disk.delete()
     keys = DataList.get_pks(disk._namespace, disk._name)
     self.assertEqual(len(keys), 0, 'There should be no primary keys ({0})'.format(len(keys)))
开发者ID:BillTheBest,项目名称:openvstorage,代码行数:16,代码来源:test_basic.py

示例5: _clean_all

# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import delete [as 别名]
 def _clean_all(self):
     """
     Cleans all disks and machines
     """
     machine = TestMachine()
     keys = DataList.get_pks(machine._namespace, machine._classname)
     for guid in keys:
         try:
             machine = TestMachine(guid)
             for disk in machine.disks:
                 disk.delete()
             machine.delete()
         except (ObjectNotFoundException, ValueError):
             pass
     disk = TestDisk()
     keys = DataList.get_pks(disk._namespace, disk._classname)
     for guid in keys:
         try:
             disk = TestDisk(guid)
             disk.delete()
         except (ObjectNotFoundException, ValueError):
             pass
开发者ID:JasperLue,项目名称:openvstorage,代码行数:24,代码来源:test_performance.py

示例6: test_delete_abandoning

# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import delete [as 别名]
 def test_delete_abandoning(self):
     """
     Validates the abandoning behavior of the delete method
     """
     machine = TestMachine()
     machine.name = 'machine'
     machine.save()
     disk_1 = TestDisk()
     disk_1.name = 'disk 1'
     disk_1.machine = machine
     disk_1.save()
     disk_2 = TestDisk()
     disk_2.name = 'disk 2'
     disk_2.machine = machine
     disk_2.save()
     self.assertRaises(LinkedObjectException, machine.delete)
     disk_3 = TestDisk(disk_1.guid)
     self.assertIsNotNone(disk_3.machine, 'The machine should still be linked')
     _ = machine.disks  # Make sure we loaded the list
     disk_2.delete()
     machine.delete(abandon=True)  # Should not raise due to disk_2 being deleted
     disk_4 = TestDisk(disk_1.guid)
     self.assertIsNone(disk_4.machine, 'The machine should be unlinked')
开发者ID:BillTheBest,项目名称:openvstorage,代码行数:25,代码来源:test_basic.py

示例7: test_lotsofobjects

# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import delete [as 别名]
    def test_lotsofobjects(self):
        """
        A test creating, linking and querying a lot of objects
        """
        print ''
        print 'cleaning up'
        self._clean_all()
        print 'start test'
        tstart = time.time()
        if getattr(LotsOfObjects, 'amount_of_machines', None) is None:
            LotsOfObjects.amount_of_machines = 50
        if getattr(LotsOfObjects, 'amount_of_disks', None) is None:
            LotsOfObjects.amount_of_disks = 5
        load_data = True
        mguids = []
        if load_data:
            print '\nstart loading data'
            start = time.time()
            runtimes = []
            for i in xrange(0, int(LotsOfObjects.amount_of_machines)):
                mstart = time.time()
                machine = TestMachine()
                machine.name = 'machine_{0}'.format(i)
                machine.save()
                mguids.append(machine.guid)
                for ii in xrange(0, int(LotsOfObjects.amount_of_disks)):
                    disk = TestDisk()
                    disk.name = 'disk_{0}_{1}'.format(i, ii)
                    disk.size = ii * 100
                    disk.machine = machine
                    disk.save()
                avgitemspersec = ((i + 1) * LotsOfObjects.amount_of_disks) / (time.time() - start)
                itemspersec = LotsOfObjects.amount_of_disks / (time.time() - mstart)
                runtimes.append(itemspersec)
                LotsOfObjects._print_progress('* machine {0}/{1} (run: {2} dps, avg: {3} dps)'.format(i + 1, int(LotsOfObjects.amount_of_machines), round(itemspersec, 2), round(avgitemspersec, 2)))
            runtimes.sort()
            print '\nloading done ({0}s). min: {1} dps, max: {2} dps'.format(round(time.time() - tstart, 2), round(runtimes[1], 2), round(runtimes[-2], 2))

        test_queries = True
        if test_queries:
            print '\nstart queries'
            start = time.time()
            runtimes = []
            for i in xrange(0, int(LotsOfObjects.amount_of_machines)):
                mstart = time.time()
                machine = TestMachine(mguids[i])
                assert len(machine.disks) == LotsOfObjects.amount_of_disks, 'Not all disks were retrieved ({0})'.format(len(machine.disks))
                avgitemspersec = ((i + 1) * LotsOfObjects.amount_of_disks) / (time.time() - start)
                itemspersec = LotsOfObjects.amount_of_disks / (time.time() - mstart)
                runtimes.append(itemspersec)
                LotsOfObjects._print_progress('* machine {0}/{1} (run: {2} dps, avg: {3} dps)'.format(i + 1, int(LotsOfObjects.amount_of_machines), round(itemspersec, 2), round(avgitemspersec, 2)))
            runtimes.sort()
            print '\ncompleted ({0}s). min: {1} dps, max: {2} dps'.format(round(time.time() - tstart, 2), round(runtimes[1], 2), round(runtimes[-2], 2))

            print '\nstart full query on disk property'
            start = time.time()
            dlist = DataList(TestDisk, {'type': DataList.where_operator.AND,
                                        'items': [('size', DataList.operator.GT, 100),
                                                  ('size', DataList.operator.LT, (LotsOfObjects.amount_of_disks - 1) * 100)]})
            amount = len(dlist)
            assert amount == (LotsOfObjects.amount_of_disks - 3) * LotsOfObjects.amount_of_machines, 'Incorrect amount of disks. Found {0} instead of {1}'.format(amount, int((LotsOfObjects.amount_of_disks - 3) * LotsOfObjects.amount_of_machines))
            seconds_passed = (time.time() - start)
            print 'completed ({0}s) in {1} seconds (avg: {2} dps)'.format(round(time.time() - tstart, 2), round(seconds_passed, 2), round(LotsOfObjects.amount_of_machines * LotsOfObjects.amount_of_disks / seconds_passed, 2))

            print '\nloading disks (all)'
            start = time.time()
            for i in xrange(0, int(LotsOfObjects.amount_of_machines)):
                machine = TestMachine(mguids[i])
                _ = [_ for _ in machine.disks]
            seconds_passed = (time.time() - start)
            print 'completed ({0}s) in {1} seconds (avg: {2} dps)'.format(round(time.time() - tstart, 2), round(seconds_passed, 2), round(LotsOfObjects.amount_of_machines * LotsOfObjects.amount_of_disks / seconds_passed, 2))

            print '\nstart full query on disk property (using cached objects)'
            dlist._volatile.delete(dlist._key)
            start = time.time()
            dlist = DataList(TestDisk, {'type': DataList.where_operator.AND,
                                        'items': [('size', DataList.operator.GT, 100),
                                                  ('size', DataList.operator.LT, (LotsOfObjects.amount_of_disks - 1) * 100)]})
            amount = len(dlist)
            assert amount == (LotsOfObjects.amount_of_disks - 3) * LotsOfObjects.amount_of_machines, 'Incorrect amount of disks. Found {0} instead of {1}'.format(amount, int((LotsOfObjects.amount_of_disks - 3) * LotsOfObjects.amount_of_machines))
            seconds_passed = (time.time() - start)
            print 'completed ({0}s) in {1} seconds (avg: {2} dps)'.format(round(time.time() - tstart, 2), round(seconds_passed, 2), round(LotsOfObjects.amount_of_machines * LotsOfObjects.amount_of_disks / seconds_passed, 2))

            print '\nstart property sort'
            dlist = DataList(TestDisk, {'type': DataList.where_operator.AND,
                                        'items': []})
            start = time.time()
            dlist.sort(key=lambda a: Toolbox.extract_key(a, 'size'))
            seconds_passed = (time.time() - start)
            print 'completed ({0}s) in {1} seconds (avg: {2} dps)'.format(round(time.time() - tstart, 2), round(seconds_passed, 2), round(LotsOfObjects.amount_of_machines * LotsOfObjects.amount_of_disks / seconds_passed, 2))

            print '\nstart dynamic sort'
            dlist._volatile.delete(dlist._key)
            dlist = DataList(TestDisk, {'type': DataList.where_operator.AND,
                                        'items': []})
            start = time.time()
            dlist.sort(key=lambda a: Toolbox.extract_key(a, 'predictable'))
            seconds_passed = (time.time() - start)
            print 'completed ({0}s) in {1} seconds (avg: {2} dps)'.format(round(time.time() - tstart, 2), round(seconds_passed, 2), round(LotsOfObjects.amount_of_machines * LotsOfObjects.amount_of_disks / seconds_passed, 2))

#.........这里部分代码省略.........
开发者ID:grimpy,项目名称:openvstorage,代码行数:103,代码来源:performance_test.py

示例8: test_lotsofobjects

# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import delete [as 别名]
    def test_lotsofobjects(self):
        """
        A test creating, linking and querying a lot of objects
        """
        print ''
        print 'cleaning up'
        self._clean_all()
        print 'start test'
        tstart = time.time()
        if getattr(LotsOfObjects, 'amount_of_machines', None) is None:
            LotsOfObjects.amount_of_machines = 50
        if getattr(LotsOfObjects, 'amount_of_disks', None) is None:
            LotsOfObjects.amount_of_disks = 5
        load_data = True
        if load_data:
            print 'start loading data'
            start = time.time()
            mguids = []
            runtimes = []
            for i in xrange(0, int(LotsOfObjects.amount_of_machines)):
                mstart = time.time()
                machine = TestMachine()
                machine.name = 'machine_{0}'.format(i)
                machine.save()
                mguids.append(machine.guid)
                for ii in xrange(0, int(LotsOfObjects.amount_of_disks)):
                    disk = TestDisk()
                    disk.name = 'disk_{0}_{1}'.format(i, ii)
                    disk.size = ii * 100
                    disk.machine = machine
                    disk.save()
                avgitemspersec = ((i + 1) * LotsOfObjects.amount_of_disks) / (time.time() - start)
                itemspersec = LotsOfObjects.amount_of_disks / (time.time() - mstart)
                runtimes.append(itemspersec)
                self._print_progress('* machine {0}/{1} (run: {2} dps, avg: {3} dps)'.format(i + 1, int(LotsOfObjects.amount_of_machines), round(itemspersec, 2), round(avgitemspersec, 2)))
            runtimes.sort()
            print '\nloading done ({0}s). min: {1} dps, max: {2} dps'.format(round(time.time() - tstart, 2), round(runtimes[1], 2), round(runtimes[-2], 2))

        test_queries = True
        if test_queries:
            print 'start queries'
            start = time.time()
            runtimes = []
            for i in xrange(0, int(LotsOfObjects.amount_of_machines)):
                mstart = time.time()
                machine = TestMachine(mguids[i])
                self.assertEqual(len(machine.disks), LotsOfObjects.amount_of_disks, 'Not all disks were retreived ({0})'.format(len(machine.disks)))
                avgitemspersec = ((i + 1) * LotsOfObjects.amount_of_disks) / (time.time() - start)
                itemspersec = LotsOfObjects.amount_of_disks / (time.time() - mstart)
                runtimes.append(itemspersec)
                self._print_progress('* machine {0}/{1} (run: {2} dps, avg: {3} dps)'.format(i + 1, int(LotsOfObjects.amount_of_machines), round(itemspersec, 2), round(avgitemspersec, 2)))
            runtimes.sort()
            print '\ncompleted ({0}s). min: {1} dps, max: {2} dps'.format(round(time.time() - tstart, 2), round(runtimes[1], 2), round(runtimes[-2], 2))

            print 'start full query on disk property'
            start = time.time()
            amount = DataList({'object': TestDisk,
                               'data': DataList.select.COUNT,
                               'query': {'type': DataList.where_operator.AND,
                                         'items': [('size', DataList.operator.GT, 100),
                                                   ('size', DataList.operator.LT, (LotsOfObjects.amount_of_disks - 1) * 100)]}}).data
            self.assertEqual(amount, (LotsOfObjects.amount_of_disks - 3) * LotsOfObjects.amount_of_machines, 'Incorrect amount of disks. Found {0} instead of {1}'.format(amount, int((LotsOfObjects.amount_of_disks - 3) * LotsOfObjects.amount_of_machines)))
            seconds_passed = (time.time() - start)
            print 'completed ({0}s) in {1} seconds (avg: {2} dps)'.format(round(time.time() - tstart, 2), round(seconds_passed, 2), round(LotsOfObjects.amount_of_machines * LotsOfObjects.amount_of_disks / seconds_passed, 2))

        clean_data = True
        if clean_data:
            print 'cleaning up'
            start = time.time()
            runtimes = []
            for i in xrange(0, int(LotsOfObjects.amount_of_machines)):
                mstart = time.time()
                machine = TestMachine(mguids[i])
                for disk in machine.disks:
                    disk.delete()
                machine.delete()
                avgitemspersec = ((i + 1) * LotsOfObjects.amount_of_disks) / (time.time() - start)
                itemspersec = LotsOfObjects.amount_of_disks / (time.time() - mstart)
                runtimes.append(itemspersec)
                self._print_progress('* machine {0}/{1} (run: {2} dps, avg: {3} dps)'.format(i + 1, int(LotsOfObjects.amount_of_machines), round(itemspersec, 2), round(avgitemspersec, 2)))
            runtimes.sort()
            print '\ncompleted ({0}s). min: {1} dps, max: {2} dps'.format(round(time.time() - tstart, 2), round(runtimes[1], 2), round(runtimes[-2], 2))
开发者ID:JasperLue,项目名称:openvstorage,代码行数:84,代码来源:test_performance.py

示例9: test_lotsofobjects

# 需要导入模块: from ovs.dal.hybrids.t_testdisk import TestDisk [as 别名]
# 或者: from ovs.dal.hybrids.t_testdisk.TestDisk import delete [as 别名]

#.........这里部分代码省略.........
                machine.name = "machine_{0}".format(i)
                machine.save()
                mguids.append(machine.guid)
                for ii in xrange(0, int(LotsOfObjects.amount_of_disks)):
                    disk = TestDisk()
                    disk.name = "disk_{0}_{1}".format(i, ii)
                    disk.size = ii * 100
                    disk.machine = machine
                    disk.save()
                avgitemspersec = ((i + 1) * LotsOfObjects.amount_of_disks) / (time.time() - start)
                itemspersec = LotsOfObjects.amount_of_disks / (time.time() - mstart)
                runtimes.append(itemspersec)
                self._print_progress(
                    "* machine {0}/{1} (run: {2} dps, avg: {3} dps)".format(
                        i + 1, int(LotsOfObjects.amount_of_machines), round(itemspersec, 2), round(avgitemspersec, 2)
                    )
                )
            runtimes.sort()
            print "\nloading done ({0}s). min: {1} dps, max: {2} dps".format(
                round(time.time() - tstart, 2), round(runtimes[1], 2), round(runtimes[-2], 2)
            )

        test_queries = True
        if test_queries:
            print "start queries"
            start = time.time()
            runtimes = []
            for i in xrange(0, int(LotsOfObjects.amount_of_machines)):
                mstart = time.time()
                machine = TestMachine(mguids[i])
                self.assertEqual(
                    len(machine.disks),
                    LotsOfObjects.amount_of_disks,
                    "Not all disks were retreived ({0})".format(len(machine.disks)),
                )
                avgitemspersec = ((i + 1) * LotsOfObjects.amount_of_disks) / (time.time() - start)
                itemspersec = LotsOfObjects.amount_of_disks / (time.time() - mstart)
                runtimes.append(itemspersec)
                self._print_progress(
                    "* machine {0}/{1} (run: {2} dps, avg: {3} dps)".format(
                        i + 1, int(LotsOfObjects.amount_of_machines), round(itemspersec, 2), round(avgitemspersec, 2)
                    )
                )
            runtimes.sort()
            print "\ncompleted ({0}s). min: {1} dps, max: {2} dps".format(
                round(time.time() - tstart, 2), round(runtimes[1], 2), round(runtimes[-2], 2)
            )

            print "start full query on disk property"
            start = time.time()
            amount = DataList(
                {
                    "object": TestDisk,
                    "data": DataList.select.COUNT,
                    "query": {
                        "type": DataList.where_operator.AND,
                        "items": [
                            ("size", DataList.operator.GT, 100),
                            ("size", DataList.operator.LT, (LotsOfObjects.amount_of_disks - 1) * 100),
                        ],
                    },
                }
            ).data
            self.assertEqual(
                amount,
                (LotsOfObjects.amount_of_disks - 3) * LotsOfObjects.amount_of_machines,
                "Incorrect amount of disks. Found {0} instead of {1}".format(
                    amount, int((LotsOfObjects.amount_of_disks - 3) * LotsOfObjects.amount_of_machines)
                ),
            )
            seconds_passed = time.time() - start
            print "completed ({0}s) in {1} seconds (avg: {2} dps)".format(
                round(time.time() - tstart, 2),
                round(seconds_passed, 2),
                round(LotsOfObjects.amount_of_machines * LotsOfObjects.amount_of_disks / seconds_passed, 2),
            )

        clean_data = True
        if clean_data:
            print "cleaning up"
            start = time.time()
            runtimes = []
            for i in xrange(0, int(LotsOfObjects.amount_of_machines)):
                mstart = time.time()
                machine = TestMachine(mguids[i])
                for disk in machine.disks:
                    disk.delete()
                machine.delete()
                avgitemspersec = ((i + 1) * LotsOfObjects.amount_of_disks) / (time.time() - start)
                itemspersec = LotsOfObjects.amount_of_disks / (time.time() - mstart)
                runtimes.append(itemspersec)
                self._print_progress(
                    "* machine {0}/{1} (run: {2} dps, avg: {3} dps)".format(
                        i + 1, int(LotsOfObjects.amount_of_machines), round(itemspersec, 2), round(avgitemspersec, 2)
                    )
                )
            runtimes.sort()
            print "\ncompleted ({0}s). min: {1} dps, max: {2} dps".format(
                round(time.time() - tstart, 2), round(runtimes[1], 2), round(runtimes[-2], 2)
            )
开发者ID:BillTheBest,项目名称:openvstorage,代码行数:104,代码来源:test_performance.py


注:本文中的ovs.dal.hybrids.t_testdisk.TestDisk.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。