Ejemplo n.º 1
0
def many_files():
    """Time backup and restore of 2000 files"""
    count = 2000
    manyout_dir = re_init_subdir(abs_test_dir, b'many_out')
    restout_dir = re_init_subdir(abs_test_dir, b'rest_out')
    create_many_files(manyout_dir, "a", count)
    backup_cmd = b"rdiff-backup '%b' '%b'" % (manyout_dir, output_desc)
    restore_cmd = b"rdiff-backup --force -r now '%b' '%b'" % \
        (output_desc, restout_dir)

    def update_func():
        create_many_files(manyout_dir, "e", count)

    benchmark(backup_cmd, restore_cmd, "2000 1-byte files", update_func)
Ejemplo n.º 2
0
def many(backup, restore, many_count=MANY_COUNT):
    """Time backup and restore of many_count files"""
    manyout_dir = re_init_subdir(abs_test_dir, b'many_out')
    backout_dir = re_init_subdir(abs_test_dir, b'back_out')
    restout_dir = re_init_subdir(abs_test_dir, b'rest_out')
    create_many(manyout_dir, "a", many_count)
    backup_cmd = backup % (manyout_dir, backout_dir)
    restore_cmd = restore % (backout_dir, restout_dir)

    def update_func():
        create_many(manyout_dir, "e", many_count)

    return benchmark(backup_cmd, restore_cmd, "{count} 1-byte files".format(
        count=many_count), update_func)
Ejemplo n.º 3
0
def nested_files():
    """Time backup and restore of 10000 nested files"""
    depth = 4
    nestedout_dir = re_init_subdir(abs_test_dir, b'nested_out')
    restout_dir = re_init_subdir(abs_test_dir, b'rest_out')
    create_nested(nestedout_dir, "a", depth)
    backup_cmd = b"rdiff-backup '%b' '%b'" % (nestedout_dir, output_desc)
    restore_cmd = b"rdiff-backup --force -r now '%b' '%b'" % \
        (output_desc, restout_dir)

    def update_func():
        create_nested(nestedout_dir, "e", depth)

    benchmark(backup_cmd, restore_cmd, "10000 1-byte nested files",
              update_func)
Ejemplo n.º 4
0
def benchmark(backup_cmd, restore_cmd, desc, update_func=None):
    """Print benchmark using backup_cmd and restore_cmd

    If update_func is given, run it and then do backup a third time.

    """
    print("Initially backing up %s: %ss" % (desc, run_cmd(backup_cmd)))
    print("Updating %s, no change: %ss" % (desc, run_cmd(backup_cmd)))

    if update_func:
        update_func()
        print("Updating %s, all changed: %ss" % (desc, run_cmd(backup_cmd)))

    re_init_subdir(abs_test_dir, b'rest_out')
    print("Restoring %s to empty dir: %ss" % (desc, run_cmd(restore_cmd)))
    print("Restoring %s to unchanged dir: %ss" % (desc, run_cmd(restore_cmd)))
Ejemplo n.º 5
0
def nested(backup, restore, nested_depth=NESTED_DEPTH, nested_factor=NESTED_FACTOR):
    """Time backup and restore of factor**depth nested files"""
    nestedout_dir = re_init_subdir(abs_test_dir, b'nested_out')
    backout_dir = re_init_subdir(abs_test_dir, b'back_out')
    restout_dir = re_init_subdir(abs_test_dir, b'rest_out')
    create_nested(nestedout_dir, "a", nested_depth, nested_factor)
    backup_cmd = backup % (nestedout_dir, backout_dir)
    restore_cmd = restore % (backout_dir, restout_dir)

    def update_func():
        create_nested(nestedout_dir, "e", nested_depth, nested_factor)

    nested_count = nested_factor**nested_depth
    return benchmark(
        backup_cmd, restore_cmd, "{count} 1-byte nested files".format(
            count=nested_count), update_func)
Ejemplo n.º 6
0
def create_nested(dirname, s, depth, branch_factor=10):
    """Create many short files in branching directory"""
    def write(rp):
        fp = rp.open("w")
        fp.write(s)
        assert not fp.close()

    def helper(rp, depth):
        if (not rp.isdir()):
            rp.mkdir()
        sub_rps = [rp.append("file_%d" % i) for i in range(branch_factor)]
        if depth == 1:
            list(map(write, sub_rps))
        else:
            list(map(lambda rp: helper(rp, depth - 1), sub_rps))

    re_init_subdir(abs_test_dir, b'nested_out')
    helper(rpath.RPath(Globals.local_connection, dirname), depth)
Ejemplo n.º 7
0
 def test_check_failed_errorlog(self):
     """
     Validate that one unreadable file doesn't fail the whole backup
     """
     src_dir = os.path.join(comtst.old_test_dir, b"rpath2")
     base_dir = comtst.re_init_subdir(comtst.abs_test_dir, b"robust")
     target_dir = os.path.join(base_dir, b"bak")
     self.assertEqual(comtst.rdiff_backup_action(
         True, True, src_dir, target_dir,
         ("--api-version", "201"), b"backup", ()), 0)
Ejemplo n.º 8
0
def nested_files_rsync():
    """Test rsync on nested files"""
    depth = 4
    nestedout_dir = re_init_subdir(abs_test_dir, b'nested_out')
    create_nested(nestedout_dir, "a", depth)
    rsync_command = b"rsync -e ssh -aH --delete '%b' '%b'" % \
        (nestedout_dir, output_desc)
    print("Initial rsync: %ss" % (run_cmd(rsync_command), ))
    print("rsync update: %ss" % (run_cmd(rsync_command), ))

    create_nested(nestedout_dir, "e", depth)
    print("Update changed rsync: %ss" % (run_cmd(rsync_command), ))
Ejemplo n.º 9
0
def many_files_rsync():
    """Test rsync benchmark"""
    count = 2000
    manyout_dir = re_init_subdir(abs_test_dir, b'many_out')
    create_many_files(manyout_dir, "a", count)
    rsync_command = b"rsync -e ssh -aH --delete '%s' '%s'" % \
        (manyout_dir, output_desc)
    print("Initial rsync: %ss" % (run_cmd(rsync_command), ))
    print("rsync update: %ss" % (run_cmd(rsync_command), ))

    create_many_files(manyout_dir, "e", count)
    print("Update changed rsync: %ss" % (run_cmd(rsync_command), ))
Ejemplo n.º 10
0
class RPathTest(unittest.TestCase):
    lc = Globals.local_connection
    mainprefix = old_test_dir
    prefix = os.path.join(mainprefix, b"various_file_types")
    write_dir = re_init_subdir(abs_test_dir, b"rpathtests")
    rp_prefix = rpath.RPath(lc, prefix, ())
Ejemplo n.º 11
0
 def setUp(self):
     self.outdir = re_init_subdir(abs_test_dir, b"output")
     rdiff_backup(1, 1, old_inc2_dir, self.outdir, current_time=10000)
     rdiff_backup(1, 1, old_inc3_dir, self.outdir, current_time=20000)