add test cases for resume with checkpoint

Now mscp supports resume (#5) and (#10)
This commit is contained in:
Ryo Nakamura
2024-02-20 22:05:17 +09:00
parent dfdad6bca5
commit f3a24e0047
2 changed files with 47 additions and 3 deletions

View File

@@ -19,4 +19,4 @@ ssh-keyscan 127.0.0.1 >> ${HOME}/.ssh/known_hosts
ssh-keyscan ::1 >> ${HOME}/.ssh/known_hosts
# Run test
python3 -m pytest ../test -v
python3 -m pytest -v ../test

View File

@@ -10,7 +10,7 @@ import time
import os
import shutil
from subprocess import check_call, CalledProcessError, PIPE
from subprocess import check_call, PIPE, CalledProcessError
from util import File, check_same_md5sum
@@ -19,13 +19,16 @@ def run2ok(args, env = None):
print("cmd: {}".format(" ".join(cmd)))
check_call(cmd, env = env)
def run2ng(args, env = None):
def run2ng(args, env = None, timeout = None):
if timeout:
args = ["timeout", "-s", "INT", timeout] + args
cmd = list(map(str, args))
print("cmd: {}".format(" ".join(cmd)))
with pytest.raises(CalledProcessError) as e:
check_call(cmd, env = env)
""" usage test """
def test_usage(mscp):
@@ -509,3 +512,44 @@ def test_10k_files(mscp, src_prefix, dst_prefix):
assert check_same_md5sum(s, d)
shutil.rmtree("src")
shutil.rmtree("dst")
@pytest.mark.parametrize("src_prefix, dst_prefix", param_remote_prefix)
def test_checkpoint_dump_and_resume(mscp, src_prefix, dst_prefix):
src1 = File("src1", size = 512 * 1024 * 1024).make()
src2 = File("src2", size = 512 * 1024 * 1024).make()
dst1 = File("dst/src1")
dst2 = File("dst/src2")
run2ok([mscp, "-H", "-vvv", "-W", "checkpoint", "-D",
src_prefix + "src1", src_prefix + "src2", dst_prefix + "dst"])
assert os.path.exists("checkpoint")
run2ok([mscp, "-H", "-vvv", "-R", "checkpoint"])
assert check_same_md5sum(src1, dst1)
assert check_same_md5sum(src2, dst2)
src1.cleanup()
src2.cleanup()
dst1.cleanup()
dst2.cleanup()
os.remove("checkpoint")
@pytest.mark.parametrize("timeout", [1,2,3])
@pytest.mark.parametrize("src_prefix, dst_prefix", param_remote_prefix)
def test_checkpoint_interrupt_and_resume(mscp, timeout, src_prefix, dst_prefix):
src1 = File("src1", size = 512 * 1024 * 1024).make()
src2 = File("src2", size = 512 * 1024 * 1024).make()
dst1 = File("dst/src1")
dst2 = File("dst/src2")
run2ng([mscp, "-H", "-vv", "-W", "checkpoint",
"-n", 1, "-s", 8192, "-S", 16384,
src_prefix + "src1", src_prefix + "src2", dst_prefix + "dst"],
timeout = timeout)
assert os.path.exists("checkpoint")
run2ok([mscp, "-H", "-vv", "-R", "checkpoint"])
assert check_same_md5sum(src1, dst1)
assert check_same_md5sum(src2, dst2)
src1.cleanup()
src2.cleanup()
dst1.cleanup()
dst2.cleanup()
os.remove("checkpoint")