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 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 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"))
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)
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))
def test_rename(self): testbackend.createNamespace("xxx") target = testbackend.theBackend()("xxx") B.copy(self.source, target) B.renameVolume(target, "new_name")