Example #1
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)
Example #2
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)
    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)
Example #4
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)
Example #5
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)
Example #6
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)
 def check(allss, toscrubss):
     self.assertEqual(PITReplication.getVolumeSnapshots(target), allss)
     self.assertEqual(
         PITReplication.getScrubSnapshots(target), toscrubss)
Example #8
0
 def check(allss, toscrubss):
     self.assertEqual(PITReplication.getVolumeSnapshots(target), allss)
     self.assertEqual(PITReplication.getScrubSnapshots(target),
                      toscrubss)