示例#1
0
    def test_location_map_filenames(self):
        """
        test the "backup" and "restore" actions with quoted filenames
        """
        # we backup twice to the same backup repository at different times
        self.assertEqual(
            comtst.rdiff_backup_action(
                False, False, self.from1_path, self.bak_path,
                ("--api-version", "201", "--current-time", "10000",
                 "--chars-to-quote", "A-Z"), b"backup", ()), 0)
        self.assertEqual(
            comtst.rdiff_backup_action(
                False, True, self.from2_path, self.bak_path,
                ("--api-version", "201", "--current-time", "20000",
                 "--chars-to-quote", "A-Z"), b"backup", ()), 0)

        # then we restore the increment and the last mirror to two directories
        self.assertEqual(
            comtst.rdiff_backup_action(True, False, self.bak_path,
                                       self.to1_path, ("--api-version", "201"),
                                       b"restore", ("--at", "1B")), 0)
        self.assertEqual(
            comtst.rdiff_backup_action(True, True, self.bak_path,
                                       self.to2_path, ("--api-version", "201"),
                                       b"restore", ()), 0)

        self.assertFalse(fileset.compare_paths(self.from1_path, self.to1_path))
        self.assertFalse(fileset.compare_paths(self.from2_path, self.to2_path))

        # all tests were successful
        self.success = True
    def test_action_regress(self):
        """test different ways of regressing"""
        # regressing a successful backup doesn't do anything
        self.assertEqual(
            comtst.rdiff_backup_action(False, None, self.bak_path, None,
                                       ("--api-version", "201"), b"regress",
                                       ()), 0)
        # we again simulate a crash
        _repo_shadow.ShadowRepo.touch_current_mirror(
            rpath.RPath(Globals.local_connection, self.bak_path,
                        ("rdiff-backup-data", )), Time.timetostring(20000))
        # the current process (the test) is still running, hence it fails
        self.assertNotEqual(
            comtst.rdiff_backup_action(True, None, self.bak_path, None,
                                       ("--api-version", "201"), b"regress",
                                       ()), 0)
        # but it runs with --force
        self.assertEqual(
            comtst.rdiff_backup_action(True, None, self.bak_path, None,
                                       ("--api-version", "201", "--force"),
                                       b"regress", ()), 0)
        # we restore and compare
        self.assertEqual(
            comtst.rdiff_backup_action(True, True, self.bak_path,
                                       self.to2_path, ("--api-version", "201"),
                                       b"restore", ()), 0)
        self.assertFalse(fileset.compare_paths(self.from2_path, self.to2_path))
        # we again simulate a crash
        _repo_shadow.ShadowRepo.touch_current_mirror(
            rpath.RPath(Globals.local_connection, self.bak_path,
                        ("rdiff-backup-data", )), Time.timetostring(10000))
        # and then try to backup, which fails because without force
        self.assertNotEqual(
            comtst.rdiff_backup_action(
                True, True, self.from4_path, self.bak_path,
                ("--api-version", "201", "--current-time", "40000"), b"backup",
                ()), 0)
        # now with --force, it can't be exactly the same time or it fails
        # on error_log already existing
        self.assertEqual(
            comtst.rdiff_backup_action(
                True, True, self.from4_path, self.bak_path,
                ("--api-version", "201", "--current-time", "40001", "--force"),
                b"backup", ()), 0)
        # we restore and compare
        self.assertEqual(
            comtst.rdiff_backup_action(True, True, self.bak_path,
                                       self.to4_path, ("--api-version", "201"),
                                       b"restore", ()), 0)
        self.assertFalse(fileset.compare_paths(self.from4_path, self.to4_path))

        # all tests were successful
        self.success = True
示例#3
0
    def test_location_map_filenames_change_quotes(self):
        """
        test the "backup" and "restore" actions with quoted filenames
        while changing the quoted characters, which isn't supported
        """
        # we backup twice to the same backup repository at different times
        self.assertEqual(
            comtst.rdiff_backup_action(
                False, False, self.from1_path, self.bak_path,
                ("--api-version", "201", "--current-time", "10000",
                 "--chars-to-quote", "A-P"), b"backup", ()), 0)
        # we try the 2nd time to change the chars-to-quote, which fails
        self.assertNotEqual(
            comtst.rdiff_backup_action(
                False, True, self.from2_path, self.bak_path,
                ("--api-version", "201", "--current-time", "15000",
                 "--chars-to-quote", "H-Z"), b"backup", ()), 0)
        self.assertNotEqual(
            comtst.rdiff_backup_action(
                False, True, self.from2_path, self.bak_path,
                ("--api-version", "201", "--current-time", "20000",
                 "--chars-to-quote", "H-Z", "--force"), b"backup", ()), 0)

        # then we restore the last mirror to a directory without issue
        self.assertEqual(
            comtst.rdiff_backup_action(True, True, self.bak_path,
                                       self.to1_path, ("--api-version", "201"),
                                       b"restore", ()), 0)

        self.assertFalse(fileset.compare_paths(self.from1_path, self.to1_path))

        # all tests were successful
        self.success = True
示例#4
0
    def test_forced_regress(self):
        """test different ways of regressing even if not necessary"""
        # regressing a successful backup with force simply removes it
        self.assertEqual(
            comtst.rdiff_backup_action(False, None, self.bak_path, None,
                                       ("--api-version", "201", "--force"),
                                       b"regress", ()), 0)
        # we do it twice
        self.assertEqual(
            comtst.rdiff_backup_action(True, None, self.bak_path, None,
                                       ("--api-version", "201", "--force"),
                                       b"regress", ()), 0)
        # we restore and compare
        self.assertEqual(
            comtst.rdiff_backup_action(True, True, self.bak_path,
                                       self.to1_path, ("--api-version", "201"),
                                       b"restore", ()), 0)
        self.assertFalse(fileset.compare_paths(self.from1_path, self.to1_path))
        # the last tentative to regress forcefully ends with a warning
        self.assertEqual(
            comtst.rdiff_backup_action(True, None, self.bak_path, None,
                                       ("--api-version", "201", "--force"),
                                       b"regress", ()), 2)

        # all tests were successful
        self.success = True