Skip to content

Commit

Permalink
resume: fix increment idx only when path is added (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
upa committed Apr 15, 2024
1 parent 6373e24 commit a5bca0e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ int checkpoint_save(const char *pathname, int dir, const char *user, const char
pool_for_each(path_pool, p, i) {
if (p->state == FILE_STATE_DONE)
continue;
if (checkpoint_write_path(fd, p, i) < 0)
if (checkpoint_write_path(fd, p, nr_paths) < 0)
return -1;
nr_paths++;
}
Expand Down Expand Up @@ -349,7 +349,8 @@ static int checkpoint_load_path(struct checkpoint_obj_hdr *hdr, pool *path_pool)
return -1;
}

pr_info("checkpoint:file: %s -> %s", p->path, p->dst_path);
pr_info("checkpoint:file: idx=%u %s -> %s", ntohl(path->idx),
p->path, p->dst_path);

return 0;
}
Expand All @@ -375,7 +376,8 @@ static int checkpoint_load_chunk(struct checkpoint_obj_hdr *hdr, pool *path_pool
return -1;
}

pr_debug("checkpoint:chunk: %s 0x%lx-0x%lx", p->path, c->off, c->off + c->len);
pr_debug("checkpoint:chunk: idx=%u %s 0x%lx-0x%lx", ntohl(chunk->idx),
p->path, c->off, c->off + c->len);

return 0;
}
Expand Down
32 changes: 30 additions & 2 deletions test/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,9 @@ def test_checkpoint_dump_and_resume(mscp, src_prefix, dst_prefix):
dst2.cleanup()
os.remove("checkpoint")

@pytest.mark.parametrize("timeout", [1, 2, 3, 4, 5, 6])
@pytest.mark.parametrize("timeout", [ 1, 2, 3, 4, 5 ])
@pytest.mark.parametrize("src_prefix, dst_prefix", param_remote_prefix)
def test_checkpoint_interrupt_and_resume(mscp, timeout, src_prefix, dst_prefix):
def test_checkpoint_interrupt_large_file(mscp, timeout, src_prefix, dst_prefix):
"""Copy two 100MB files with 200Mbps -> 4 sec + 4 sec """
src1 = File("src1", size = 100 * 1024 * 1024).make()
src2 = File("src2", size = 100 * 1024 * 1024).make()
Expand All @@ -650,3 +650,31 @@ def test_checkpoint_interrupt_and_resume(mscp, timeout, src_prefix, dst_prefix):
dst2.cleanup()
os.remove("checkpoint")

@pytest.mark.parametrize("timeout", [ 1, 2, 3, 4, 5 ])
@pytest.mark.parametrize("src_prefix, dst_prefix", param_remote_prefix)
def test_checkpoint_interrupt_many_files(mscp, timeout, src_prefix, dst_prefix):
"""Copy 100 1-MB files with 4 connections, and interrupt and
resume the transfer
"""

files = []
for x in range(100):
files.append((
File("src/{:03d}".format(x), size = 1024 * 1024).make(),
File("dst/{:03d}".format(x))
))

run2ng([mscp, "-vv", "-W", "checkpoint", "-L", "80m", "-n", 4,
src_prefix + "src", dst_prefix + "dst"],
timeout = timeout)
assert os.path.exists("checkpoint")

run2ok([mscp, "-vv", "-R", "checkpoint"])

for src, dst in files:
assert check_same_md5sum(src, dst)
src.cleanup()
dst.cleanup()

os.remove("checkpoint")

0 comments on commit a5bca0e

Please sign in to comment.