コード例 #1
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())
コード例 #2
0
    def test_expiringNormalDrop(self):
        with dlm.DataLifecycleManager(checkPeriod=0.5) as manager:
            drop = FileDROP('oid:A', 'uid:A1', expectedSize=1, lifespan=0.5)
            manager.addDrop(drop)

            # Writing moves the DROP to COMPLETE
            self._writeAndClose(drop)

            # Wait now, the DROP should be moved by the DLM to EXPIRED
            time.sleep(1)

            self.assertEqual(DROPStates.EXPIRED, drop.status)
コード例 #3
0
    def test_dropCompleteTriggersReplication(self):
        with dlm.DataLifecycleManager() as manager:
            drop = FileDROP('oid:A', 'uid:A1', expectedSize=1)
            manager.addDrop(drop)
            self._writeAndClose(drop)

            # The call to close() should have turned it into a SOLID object
            # because the DLM replicated it
            self.assertEqual(DROPPhases.SOLID, drop.phase)
            self.assertEqual(2, len(manager.getDropUids(drop)))

            # Try the same with a non-precious data object, it shouldn't be replicated
            drop = FileDROP('oid:B', 'uid:B1', expectedSize=1, precious=False)
            manager.addDrop(drop)
            self._writeAndClose(drop)
            self.assertEqual(DROPPhases.GAS, drop.phase)
            self.assertEqual(1, len(manager.getDropUids(drop)))
コード例 #4
0
ファイル: test_dlm.py プロジェクト: ICRAR/daliuge
    def test_expireAfterUse(self):
        """
        Simple test for the expireAfterUse flag. Two DROPs are created with
        different values, and after they are used we check whether their data
        is still there or not
        """
        with dlm.DataLifecycleManager(check_period=0.5,
                                      cleanup_period=2) as manager:
            a = DirectoryContainer(
                "a",
                "a",
                precious=False,
                expireAfterUse=True,
                dirname=tempfile.mkdtemp(),
            )
            b_dirname = tempfile.mkdtemp()
            b = DirectoryContainer("b",
                                   "b",
                                   precious=False,
                                   expireAfterUse=False,
                                   dirname=b_dirname)
            c = BarrierAppDROP("c", "c")
            d = BarrierAppDROP("d", "d")
            a.addConsumer(c)
            a.addConsumer(d)
            b.addConsumer(c)
            b.addConsumer(d)

            manager.addDrop(a)
            manager.addDrop(b)
            manager.addDrop(b)
            manager.addDrop(c)

            # Make sure all consumers are done
            with DROPWaiterCtx(self, [c, d], 1):
                a.setCompleted()
                b.setCompleted()

            # Both directories should be there, but after cleanup A's shouldn't
            # be there anymore
            self.assertTrue(a.exists())
            self.assertTrue(b.exists())
            time.sleep(2.5)
            self.assertFalse(a.exists())
            self.assertTrue(b.exists())
            b.delete()
コード例 #5
0
    def test_lostDrop(self):
        with dlm.DataLifecycleManager(checkPeriod=0.5) as manager:
            drop = FileDROP('oid:A',
                            'uid:A1',
                            expectedSize=1,
                            lifespan=10,
                            precious=False)
            manager.addDrop(drop)
            self._writeAndClose(drop)

            # "externally" remove the file, its contents now don't exist
            os.unlink(drop.path)

            # Let the DLM do its work
            time.sleep(1)

            # Check that the DROP is marked as LOST
            self.assertEqual(DROPPhases.LOST, drop.phase)
コード例 #6
0
 def test_dropAddition(self):
     with dlm.DataLifecycleManager() as manager:
         drop = FileDROP('oid:A', 'uid:A1', expectedSize=10)
         manager.addDrop(drop)
コード例 #7
0
 def test_basicCreation(self):
     manager = dlm.DataLifecycleManager()
     manager.startup()
     manager.cleanup()