Esempio n. 1
0
 def assertFiles(delete_parent_directory, parentDirExists, tempDir=None):
     tempDir = tempDir or tempfile.mkdtemp()
     a = FileDROP("a", "a", dirname=tempDir, delete_parent_directory=delete_parent_directory)
     a.write(" ")
     a.setCompleted()
     self.assertTrue(a.exists())
     self.assertTrue(os.path.isdir(tempDir))
     a.delete()
     self.assertFalse(a.exists())
     self.assertEquals(parentDirExists, os.path.isdir(tempDir))
     if parentDirExists:
         shutil.rmtree(tempDir)
Esempio n. 2
0
 def assertFiles(delete_parent_directory, parentDirExists, tempDir=None):
     tempDir = tempDir or tempfile.mkdtemp()
     a = FileDROP('a', 'a', dirname=tempDir, delete_parent_directory=delete_parent_directory)
     a.write(' ')
     a.setCompleted()
     self.assertTrue(a.exists())
     self.assertTrue(os.path.isdir(tempDir))
     a.delete()
     self.assertFalse(a.exists())
     self.assertEqual(parentDirExists, os.path.isdir(tempDir))
     if parentDirExists:
         shutil.rmtree(tempDir)
Esempio n. 3
0
    def test_cleanupExpiredDrops(self):
        with dlm.DataLifecycleManager(checkPeriod=0.5, cleanupPeriod=2) as manager:
            drop = FileDROP('oid:A', 'uid:A1', expectedSize=1, lifespan=1, precious=False)
            manager.addDrop(drop)
            self._writeAndClose(drop)

            # Wait 2 seconds, the DROP is still COMPLETED
            time.sleep(0.5)
            self.assertEquals(DROPStates.COMPLETED, drop.status)
            self.assertTrue(drop.exists())

            # Wait 5 more second, now it should be expired but still there
            time.sleep(1)
            self.assertEquals(DROPStates.EXPIRED, drop.status)
            self.assertTrue(drop.exists())

            # Wait 2 more seconds, now it should have been deleted
            time.sleep(1)
            self.assertEquals(DROPStates.DELETED, drop.status)
            self.assertFalse(drop.exists())
Esempio n. 4
0
    def test_cleanupExpiredDrops(self):
        with dlm.DataLifecycleManager(checkPeriod=0.5, cleanupPeriod=2) as manager:
            drop = FileDROP('oid:A', 'uid:A1', expectedSize=1, lifespan=1, precious=False)
            manager.addDrop(drop)
            self._writeAndClose(drop)

            # Wait 2 seconds, the DROP is still COMPLETED
            time.sleep(0.5)
            self.assertEqual(DROPStates.COMPLETED, drop.status)
            self.assertTrue(drop.exists())

            # Wait 5 more second, now it should be expired but still there
            time.sleep(1)
            self.assertEqual(DROPStates.EXPIRED, drop.status)
            self.assertTrue(drop.exists())

            # Wait 2 more seconds, now it should have been deleted
            time.sleep(1)
            self.assertEqual(DROPStates.DELETED, drop.status)
            self.assertFalse(drop.exists())