コード例 #1
0
 def test_simple2(self):
     #        """ Take a lock in 2 different namespaces and release again
     #        """
     ns1 = "test-simple2-ns1"
     ns2 = "test-simple2-ns2"
     testbackend.createNamespace(ns1)
     testbackend.createNamespace(ns2)
     pid1 = lockedexecutable.start(testbackend.theBackend()(ns1))
     pid2 = lockedexecutable.start(testbackend.theBackend()(ns2))
     lockedexecutable.stop(pid1)
     lockedexecutable.stop(pid2)
コード例 #2
0
 def test_simple2(self):
     #        """ Take a lock in 2 different namespaces and release again
     #        """
     ns1 = "test-simple2-ns1"
     ns2 = "test-simple2-ns2"
     testbackend.createNamespace(ns1)
     testbackend.createNamespace(ns2)
     pid1 = lockedexecutable.start(testbackend.theBackend()(ns1))
     pid2 = lockedexecutable.start(testbackend.theBackend()(ns2))
     lockedexecutable.stop(pid1)
     lockedexecutable.stop(pid2)
コード例 #3
0
    def failscrub_test(self):
        #        """ create a namespace
        #            prepare it with at least 2 snapshots for scrubbing (cfr. backup_test -> testScrubbingAndSnapshotMgmtTarget)
        #            scrub 1 snapshot -> should succeed
        #            take a lock on the namespace
        #            scrub the other snapshot -> should fail
        #        """
        PITReplication.testConfiguration()
        ns = "failscrub-test"
        testbackend.createNamespace(ns)
        target = testbackend.theBackend()(ns)

        def check(allss, toscrubss):
            self.assertEqual(PITReplication.getVolumeSnapshots(target), allss)
            self.assertEqual(
                PITReplication.getScrubSnapshots(target), toscrubss)

        for ss in PITReplication.getVolumeSnapshots(self.source):
            PITReplication.backup(self.source, target, endSnapshot=ss)

        check(['A', 'B', 'C', 'D', 'E', 'F'], [])

        PITReplication.deleteSnapshots(target, "B")
        check(['A', 'C', 'D', 'E', 'F'], ["C"])
        pid = lockedexecutable.start(target)
        # self.assertRaises(Exception,
        #                   PITReplication.scrubSnapshot,
        #                   target,
        #                   "C",
        #                   'scrub the other snapshot should fail')
        lockedexecutable.stop(pid)
コード例 #4
0
ファイル: backup_test.py プロジェクト: bigclouds/volumedriver
 def test_cheapInitialIncremental(self):
     testbackend.createNamespace("foo")
     backupWithMonitoring(self,
                          self.source,
                          testbackend.theBackend()("foo"),
                          startSnapshot="D",
                          endSnapshot="D")
コード例 #5
0
    def failscrub_test(self):
        #        """ create a namespace
        #            prepare it with at least 2 snapshots for scrubbing (cfr. backup_test -> testScrubbingAndSnapshotMgmtTarget)
        #            scrub 1 snapshot -> should succeed
        #            take a lock on the namespace
        #            scrub the other snapshot -> should fail
        #        """
        PITReplication.testConfiguration()
        ns = "failscrub-test"
        testbackend.createNamespace(ns)
        target = testbackend.theBackend()(ns)

        def check(allss, toscrubss):
            self.assertEqual(PITReplication.getVolumeSnapshots(target), allss)
            self.assertEqual(PITReplication.getScrubSnapshots(target),
                             toscrubss)

        for ss in PITReplication.getVolumeSnapshots(self.source):
            PITReplication.backup(self.source, target, endSnapshot=ss)

        check(['A', 'B', 'C', 'D', 'E', 'F'], [])

        PITReplication.deleteSnapshots(target, "B")
        check(['A', 'C', 'D', 'E', 'F'], ["C"])
        pid = lockedexecutable.start(target)
        # self.assertRaises(Exception,
        #                   PITReplication.scrubSnapshot,
        #                   target,
        #                   "C",
        #                   'scrub the other snapshot should fail')
        lockedexecutable.stop(pid)
コード例 #6
0
 def test_cheapInitialIncremental(self):
     testbackend.createNamespace("foo")
     backupWithMonitoring(self,
                          self.source,
                          testbackend.theBackend()("foo"),
                          startSnapshot="D",
                          endSnapshot="D")
コード例 #7
0
 def test_recover(self):
     #        """ Take a lock and kill it
     #            Try to take the lock again, this should succeed
     #            The previous step should take at least 5 sec
     #        """
     ns = "test-recover"
     testbackend.createNamespace(ns)
     session = 1
     pid = lockedexecutable.start(testbackend.theBackend()(ns), session)
     lockedexecutable.kill(pid)
     timestamp = time.time()
     pid = lockedexecutable.start(testbackend.theBackend()(ns))
     execution_time = time.time() - timestamp
     self.assertTrue(execution_time >= 3 * session,
                     'The previous step should take at least 3 x sessiontimeout (%s) but they take %s s'
                     % (session, execution_time))
     lockedexecutable.stop(pid)
コード例 #8
0
 def test_recover(self):
     #        """ Take a lock and kill it
     #            Try to take the lock again, this should succeed
     #            The previous step should take at least 5 sec
     #        """
     ns = "test-recover"
     testbackend.createNamespace(ns)
     session = 1
     pid = lockedexecutable.start(testbackend.theBackend()(ns), session)
     lockedexecutable.kill(pid)
     timestamp = time.time()
     pid = lockedexecutable.start(testbackend.theBackend()(ns))
     execution_time = time.time() - timestamp
     self.assertTrue(execution_time >= 3 * session,
                     'The previous step should take at least 3 x sessiontimeout (%s) but they take %s s'
                     % (session, execution_time))
     lockedexecutable.stop(pid)
コード例 #9
0
 def test_mutex(self):
     #        """ why don't we put the name of the of the test on the first line? Take a lock
     #            Try to take the lock again, this should fail (throws exception)
     #            The previous step should take at least 5 sec
     #        """
     ns = "test-mutex"
     testbackend.createNamespace(ns)
     session = 1
     pid = lockedexecutable.start(
         testbackend.theBackend()(ns), lock_session_timeout=session)
     timestamp = time.time()
     self.assertRaises(lockedexecutable.LockNotTakenException,
                       lockedexecutable.start, testbackend.theBackend()(ns))
     execution_time = time.time() - timestamp
     self.assertTrue(execution_time >= 3 * session,
                     'The previous step should take at least 3 x sessiontimeout (%s) but they take %s s'
                     % (session, execution_time))
     lockedexecutable.stop(pid)
コード例 #10
0
ファイル: backup_test.py プロジェクト: bigclouds/volumedriver
    def test_Basic(self):
        B.testConfiguration()
        testbackend.createNamespace("basebackup")
        target = testbackend.theBackend()("basebackup")

        backupWithMonitoring(self, self.source, target, endSnapshot="A")
        backupWithMonitoring(self, self.source, target, endSnapshot="C")
        backupWithMonitoring(self, self.source, target, endSnapshot="E")
        backupWithMonitoring(self, self.source, target)
コード例 #11
0
 def test_sequential(self):
     #        """Or just remove any documentation about which test is running and what it's supposed to do
     #        so the next guy can spend half a day fixing it.
     #        """
     timestamp = time.time()
     ns = "test-sequential"
     testbackend.createNamespace(ns)
     session = 1
     pid = lockedexecutable.start(
         testbackend.theBackend()(ns), lock_session_timeout=session)
     lockedexecutable.stop(pid)
     pid = lockedexecutable.start(
         testbackend.theBackend()(ns), lock_session_timeout=session)
     lockedexecutable.stop(pid)
     execution_time = time.time() - timestamp
     self.assertTrue(execution_time <= session,
                     'All previous steps together should be finished within the sessiontimeout (%s) but they take %s s'
                     % (session, execution_time))
コード例 #12
0
 def test_sequential(self):
     #        """Or just remove any documentation about which test is running and what it's supposed to do
     #        so the next guy can spend half a day fixing it.
     #        """
     timestamp = time.time()
     ns = "test-sequential"
     testbackend.createNamespace(ns)
     session = 1
     pid = lockedexecutable.start(
         testbackend.theBackend()(ns), lock_session_timeout=session)
     lockedexecutable.stop(pid)
     pid = lockedexecutable.start(
         testbackend.theBackend()(ns), lock_session_timeout=session)
     lockedexecutable.stop(pid)
     execution_time = time.time() - timestamp
     self.assertTrue(execution_time <= session,
                     'All previous steps together should be finished within the sessiontimeout (%s) but they take %s s'
                     % (session, execution_time))
コード例 #13
0
    def test_Basic(self):
        B.testConfiguration()
        testbackend.createNamespace("basebackup")
        target = testbackend.theBackend()("basebackup")

        backupWithMonitoring(self, self.source, target, endSnapshot="A")
        backupWithMonitoring(self, self.source, target, endSnapshot="C")
        backupWithMonitoring(self, self.source, target, endSnapshot="E")
        backupWithMonitoring(self, self.source, target)
コード例 #14
0
 def test_mutex(self):
     #        """ why don't we put the name of the of the test on the first line? Take a lock
     #            Try to take the lock again, this should fail (throws exception)
     #            The previous step should take at least 5 sec
     #        """
     ns = "test-mutex"
     testbackend.createNamespace(ns)
     session = 1
     pid = lockedexecutable.start(
         testbackend.theBackend()(ns), lock_session_timeout=session)
     timestamp = time.time()
     self.assertRaises(lockedexecutable.LockNotTakenException,
                       lockedexecutable.start, testbackend.theBackend()(ns))
     execution_time = time.time() - timestamp
     self.assertTrue(execution_time >= 3 * session,
                     'The previous step should take at least 3 x sessiontimeout (%s) but they take %s s'
                     % (session, execution_time))
     lockedexecutable.stop(pid)
コード例 #15
0
    def test_ScrubbingAndSnapshotMgmtTarget(self):
        testbackend.createNamespace("toscrub")
        target = testbackend.theBackend()("toscrub")

        # def check(allss, toscrubss):
        #     self.assertEqual(B.getVolumeSnapshots(target), allss)
        #     self.assertEqual(B.getScrubSnapshots(target), toscrubss)

        for ss in B.getVolumeSnapshots(self.source):
            backupWithMonitoring(self, self.source, target, endSnapshot=ss)
コード例 #16
0
ファイル: backup_test.py プロジェクト: bigclouds/volumedriver
    def test_ScrubbingAndSnapshotMgmtTarget(self):
        testbackend.createNamespace("toscrub")
        target = testbackend.theBackend()("toscrub")

        # def check(allss, toscrubss):
        #     self.assertEqual(B.getVolumeSnapshots(target), allss)
        #     self.assertEqual(B.getScrubSnapshots(target), toscrubss)

        for ss in B.getVolumeSnapshots(self.source):
            backupWithMonitoring(self, self.source, target, endSnapshot=ss)
コード例 #17
0
ファイル: backup_test.py プロジェクト: bigclouds/volumedriver
    def test_restore(self):
        ns1 = "xxx"
        ns2 = "yyy"
        for ns in [ns1, ns2]:
            testbackend.createNamespace(ns)

        self.makeDirs("DC2", ns2)

        DC1 = testbackend.theBackend()
        DC2 = Backend.LocalBackend(self.pathTo("DC2"))

        B.copy(self.source, DC1(ns1))
        B.copy(DC1(ns1), DC1(ns2))
        B.copy(DC1(ns2), DC2(ns2))
コード例 #18
0
    def test_Monitoring(self):
        B.testConfiguration()
        ns = "monitortest"
        testbackend.createNamespace(ns)
        target = testbackend.theBackend()(ns)

        self.assertEqual(B.getProgressInfo(target), None)
        backupWithMonitoring(self, self.source, target)

        info = B.getProgressInfo(target)
        self.assertTrue(type(info), dict)
        self.assertEqual(info["total_size"], info["seen"])
        self.assertEqual(info["still_to_be_examined"], 0)
        self.assertTrue(info["sent_to_backend"] <= info["total_size"])
コード例 #19
0
    def test_restore(self):
        ns1 = "xxx"
        ns2 = "yyy"
        for ns in [ns1, ns2]:
            testbackend.createNamespace(ns)

        self.makeDirs("DC2", ns2)

        DC1 = testbackend.theBackend()
        DC2 = Backend.LocalBackend(self.pathTo("DC2"))

        B.copy(self.source, DC1(ns1))
        B.copy(DC1(ns1), DC1(ns2))
        B.copy(DC1(ns2), DC2(ns2))
コード例 #20
0
ファイル: backup_test.py プロジェクト: bigclouds/volumedriver
    def test_Monitoring(self):
        B.testConfiguration()
        ns = "monitortest"
        testbackend.createNamespace(ns)
        target = testbackend.theBackend()(ns)

        self.assertEqual(B.getProgressInfo(target), None)
        backupWithMonitoring(self, self.source, target)

        info = B.getProgressInfo(target)
        self.assertTrue(type(info), dict)
        self.assertEqual(info["total_size"], info["seen"])
        self.assertEqual(info["still_to_be_examined"], 0)
        self.assertTrue(info["sent_to_backend"] <= info["total_size"])
コード例 #21
0
 def failrestore_test(self):
     #        """ create a namespace
     #            copy a volume to it
     #            rename the volume
     #            take a lock on the namespace
     #            try to rename the volume again -> should fail
     #        """
     PITReplication.testConfiguration()
     ns = "failrestore-test"
     testbackend.createNamespace(ns)
     target = testbackend.theBackend()(ns)
     PITReplication.copy(self.source, target)
     PITReplication.renameVolume(target, "new_name1")
     pid = lockedexecutable.start(target)
     self.assertRaises(Exception, PITReplication.renameVolume, target,
                       "new_name2", 'rename the volume again should fail')
     lockedexecutable.stop(pid)
コード例 #22
0
 def failbackup_test(self):
     #        """ create a namespace
     #            backup to certain snapshot -> should succeed
     #            take a lock on the namespace
     #            try to backup to the end of the volume -> this should fail
     #        """
     PITReplication.testConfiguration()
     ns = "failbackup-test"
     testbackend.createNamespace(ns)
     target = testbackend.theBackend()(ns)
     PITReplication.backup(self.source, target, startSnapshot="A")
     pid = lockedexecutable.start(target)
     self.assertRaises(Exception,
                       PITReplication.backup,
                       self.source,
                       target,
                       endSnapshot="C")
     lockedexecutable.stop(pid)
コード例 #23
0
 def failbackup_test(self):
     #        """ create a namespace
     #            backup to certain snapshot -> should succeed
     #            take a lock on the namespace
     #            try to backup to the end of the volume -> this should fail
     #        """
     PITReplication.testConfiguration()
     ns = "failbackup-test"
     testbackend.createNamespace(ns)
     target = testbackend.theBackend()(ns)
     PITReplication.backup(self.source, target, startSnapshot="A")
     pid = lockedexecutable.start(target)
     self.assertRaises(Exception,
                       PITReplication.backup,
                       self.source,
                       target,
                       endSnapshot="C")
     lockedexecutable.stop(pid)
コード例 #24
0
 def failrestore_test(self):
     #        """ create a namespace
     #            copy a volume to it
     #            rename the volume
     #            take a lock on the namespace
     #            try to rename the volume again -> should fail
     #        """
     PITReplication.testConfiguration()
     ns = "failrestore-test"
     testbackend.createNamespace(ns)
     target = testbackend.theBackend()(ns)
     PITReplication.copy(self.source, target)
     PITReplication.renameVolume(target, "new_name1")
     pid = lockedexecutable.start(target)
     self.assertRaises(Exception,
                       PITReplication.renameVolume,
                       target,
                       "new_name2",
                       'rename the volume again should fail')
     lockedexecutable.stop(pid)
コード例 #25
0
    def test_OutOfOrder(self):
        for ns in ["incremental", "final", "usb"]:
            testbackend.createNamespace(ns)

        backupWithMonitoring(self,
                             self.source,
                             testbackend.theBackend()("usb"),
                             endSnapshot="C")
        backupWithMonitoring(self,
                             self.source,
                             testbackend.theBackend()("incremental"),
                             startSnapshot="C")
        B.copy(testbackend.theBackend()("usb"),
               testbackend.theBackend()("final"))
        backupWithMonitoring(self,
                             testbackend.theBackend()("incremental"),
                             testbackend.theBackend()("final"))
コード例 #26
0
ファイル: backup_test.py プロジェクト: bigclouds/volumedriver
    def test_OutOfOrder(self):
        for ns in ["incremental", "final", "usb"]:
            testbackend.createNamespace(ns)

        backupWithMonitoring(self,
                             self.source,
                             testbackend.theBackend()("usb"),
                             endSnapshot="C")
        backupWithMonitoring(self,
                             self.source,
                             testbackend.theBackend()("incremental"),
                             startSnapshot="C")
        B.copy(testbackend.theBackend()("usb"),
               testbackend.theBackend()("final"))
        backupWithMonitoring(self,
                             testbackend.theBackend()("incremental"),
                             testbackend.theBackend()("final"))
コード例 #27
0
    def test_VolumeRoles(self):
        for ns in ["base", "inc"]:
            testbackend.createNamespace(ns)

        self.assertEqual(
            B.getVolumeInfo(self.source)["volume_role"],
            ToolCut.WanBackupVolumeRole.Normal)

        for s in ["B", "C", "D"]:
            backupWithMonitoring(self,
                                 self.source,
                                 testbackend.theBackend()("base"),
                                 endSnapshot=s)
            self.assertEqual(
                B.getVolumeInfo(
                    testbackend.theBackend()("base"))["volume_role"],
                ToolCut.WanBackupVolumeRole.BackupBase)

        self.assertEqual(
            B.getVolumeSnapshots(testbackend.theBackend()("base")),
            ["B", "C", "D"])

        backupWithMonitoring(self,
                             self.source,
                             testbackend.theBackend()("inc"),
                             startSnapshot="B",
                             endSnapshot="C")
        self.assertEqual(
            B.getVolumeInfo(testbackend.theBackend()("inc"))["volume_role"],
            ToolCut.WanBackupVolumeRole.BackupIncremental)
        self.assertEqual(B.getVolumeSnapshots(testbackend.theBackend()("inc")),
                         ["B", "C"])

        backupWithMonitoring(self, self.source,
                             testbackend.theBackend()("inc"))
        self.assertEqual(
            B.getVolumeInfo(testbackend.theBackend()("inc"))["volume_role"],
            ToolCut.WanBackupVolumeRole.BackupIncremental)
        self.assertEqual(B.getVolumeSnapshots(testbackend.theBackend()("inc")),
                         ["B", "C", "F"])

        self.assertRaises(Exception, B.promote,
                          testbackend.theBackend()("inc"))

        B.promote(testbackend.theBackend()("base"))
        self.assertEqual(
            B.getVolumeInfo(testbackend.theBackend()("base"))["volume_role"],
            ToolCut.WanBackupVolumeRole.Normal)

        self.makeDirs("copy")
        cpy = Backend.LocalBackend(self.getDir())("copy")
        B.copy(self.source, cpy)
        self.assertEqual(
            B.getVolumeInfo(cpy)["volume_role"],
            ToolCut.WanBackupVolumeRole.Normal)
コード例 #28
0
    def test_rename(self):
        testbackend.createNamespace("xxx")

        target = testbackend.theBackend()("xxx")
        B.copy(self.source, target)
        B.renameVolume(target, "new_name")
コード例 #29
0
 def test_Idempotency(self):
     testbackend.createNamespace("foo")
     target = testbackend.theBackend()("foo")
     backupWithMonitoring(self, self.source, target)
     backupWithMonitoring(self, self.source, target)
コード例 #30
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     testbackend.setUp()
     ns = "backend-test"
     testbackend.createNamespace(ns)
     self.target = testbackend.theBackend()(ns)
コード例 #31
0
ファイル: backup_test.py プロジェクト: bigclouds/volumedriver
    def test_VolumeRoles(self):
        for ns in ["base", "inc"]:
            testbackend.createNamespace(ns)

        self.assertEqual(B.getVolumeInfo(self.source)["volume_role"],
                         ToolCut.WanBackupVolumeRole.Normal)

        for s in ["B", "C", "D"]:
            backupWithMonitoring(self,
                                 self.source,
                                 testbackend.theBackend()("base"),
                                 endSnapshot=s)
            self.assertEqual(
                B.getVolumeInfo(
                    testbackend.theBackend()("base"))["volume_role"],
                ToolCut.WanBackupVolumeRole.BackupBase)

        self.assertEqual(
            B.getVolumeSnapshots(testbackend.theBackend()("base")),
            ["B", "C", "D"])

        backupWithMonitoring(self,
                             self.source,
                             testbackend.theBackend()("inc"),
                             startSnapshot="B",
                             endSnapshot="C")
        self.assertEqual(
            B.getVolumeInfo(testbackend.theBackend()("inc"))["volume_role"],
            ToolCut.WanBackupVolumeRole.BackupIncremental)
        self.assertEqual(B.getVolumeSnapshots(testbackend.theBackend()("inc")),
                         ["B", "C"])

        backupWithMonitoring(self,
                             self.source,
                             testbackend.theBackend()("inc"))
        self.assertEqual(
            B.getVolumeInfo(testbackend.theBackend()("inc"))["volume_role"],
            ToolCut.WanBackupVolumeRole.BackupIncremental)
        self.assertEqual(B.getVolumeSnapshots(testbackend.theBackend()("inc")),
                         ["B", "C", "F"])

        self.assertRaises(Exception,
                          B.promote, testbackend.theBackend()("inc"))

        B.promote(testbackend.theBackend()("base"))
        self.assertEqual(
            B.getVolumeInfo(testbackend.theBackend()("base"))["volume_role"],
            ToolCut.WanBackupVolumeRole.Normal)

        self.makeDirs("copy")
        cpy = Backend.LocalBackend(self.getDir())("copy")
        B.copy(self.source, cpy)
        self.assertEqual(B.getVolumeInfo(cpy)["volume_role"],
                         ToolCut.WanBackupVolumeRole.Normal)
コード例 #32
0
 def test_simple1(self):
     ns = "test-simple1"
     testbackend.createNamespace(ns)
     pid = lockedexecutable.start(testbackend.theBackend()(ns))
     lockedexecutable.stop(pid)
コード例 #33
0
ファイル: backup_test.py プロジェクト: bigclouds/volumedriver
 def test_Idempotency(self):
     testbackend.createNamespace("foo")
     target = testbackend.theBackend()("foo")
     backupWithMonitoring(self, self.source, target)
     backupWithMonitoring(self, self.source, target)
コード例 #34
0
 def test_simple1(self):
     ns = "test-simple1"
     testbackend.createNamespace(ns)
     pid = lockedexecutable.start(testbackend.theBackend()(ns))
     lockedexecutable.stop(pid)
コード例 #35
0
ファイル: backup_test.py プロジェクト: bigclouds/volumedriver
    def test_rename(self):
        testbackend.createNamespace("xxx")

        target = testbackend.theBackend()("xxx")
        B.copy(self.source, target)
        B.renameVolume(target, "new_name")
コード例 #36
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     testbackend.setUp()
     ns = "backend-test"
     testbackend.createNamespace(ns)
     self.target = testbackend.theBackend()(ns)