Exemplo n.º 1
0
 def test_cheapInitialIncremental(self):
     testbackend.createNamespace("foo")
     backupWithMonitoring(self,
                          self.source,
                          testbackend.theBackend()("foo"),
                          startSnapshot="D",
                          endSnapshot="D")
Exemplo n.º 2
0
 def test_cheapInitialIncremental(self):
     testbackend.createNamespace("foo")
     backupWithMonitoring(self,
                          self.source,
                          testbackend.theBackend()("foo"),
                          startSnapshot="D",
                          endSnapshot="D")
Exemplo n.º 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)
    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)
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
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)
Exemplo n.º 9
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)
Exemplo n.º 10
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)
Exemplo n.º 11
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)
Exemplo n.º 12
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)
Exemplo n.º 13
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"])
Exemplo n.º 14
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"])
Exemplo n.º 15
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))
Exemplo n.º 16
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))
Exemplo n.º 17
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)
Exemplo n.º 18
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)
Exemplo n.º 19
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"))
Exemplo n.º 20
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"))
Exemplo n.º 21
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)
Exemplo n.º 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)
Exemplo n.º 23
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)
Exemplo n.º 24
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))
Exemplo n.º 25
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)
Exemplo n.º 26
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))
Exemplo n.º 27
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)
Exemplo n.º 28
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)
Exemplo n.º 29
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     testbackend.setUp()
     ns = "backend-test"
     testbackend.createNamespace(ns)
     self.target = testbackend.theBackend()(ns)
Exemplo n.º 30
0
    def test_rename(self):
        testbackend.createNamespace("xxx")

        target = testbackend.theBackend()("xxx")
        B.copy(self.source, target)
        B.renameVolume(target, "new_name")
Exemplo n.º 31
0
 def test_Idempotency(self):
     testbackend.createNamespace("foo")
     target = testbackend.theBackend()("foo")
     backupWithMonitoring(self, self.source, target)
     backupWithMonitoring(self, self.source, target)
Exemplo n.º 32
0
    def test_rename(self):
        testbackend.createNamespace("xxx")

        target = testbackend.theBackend()("xxx")
        B.copy(self.source, target)
        B.renameVolume(target, "new_name")
Exemplo n.º 33
0
 def test_simple1(self):
     ns = "test-simple1"
     testbackend.createNamespace(ns)
     pid = lockedexecutable.start(testbackend.theBackend()(ns))
     lockedexecutable.stop(pid)
Exemplo n.º 34
0
 def test_Idempotency(self):
     testbackend.createNamespace("foo")
     target = testbackend.theBackend()("foo")
     backupWithMonitoring(self, self.source, target)
     backupWithMonitoring(self, self.source, target)
Exemplo n.º 35
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     testbackend.setUp()
     ns = "backend-test"
     testbackend.createNamespace(ns)
     self.target = testbackend.theBackend()(ns)
Exemplo n.º 36
0
 def test_simple1(self):
     ns = "test-simple1"
     testbackend.createNamespace(ns)
     pid = lockedexecutable.start(testbackend.theBackend()(ns))
     lockedexecutable.stop(pid)