summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyo Nakamura <upa@haeena.net>2024-02-20 22:05:17 +0900
committerRyo Nakamura <upa@haeena.net>2024-02-20 22:05:17 +0900
commitf3a24e0047b19715b19882b612d98fb864aad808 (patch)
tree6e207347d356c7594327edb80c99ea8ec691e5e1
parentdfdad6bca5f575b651e23370e51d2b8e648e16e8 (diff)
add test cases for resume with checkpoint
Now mscp supports resume (#5) and (#10)
-rwxr-xr-xscripts/test-in-container.sh2
-rw-r--r--test/test_e2e.py48
2 files changed, 47 insertions, 3 deletions
diff --git a/scripts/test-in-container.sh b/scripts/test-in-container.sh
index c71d278..f24bfe4 100755
--- a/scripts/test-in-container.sh
+++ b/scripts/test-in-container.sh
@@ -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
diff --git a/test/test_e2e.py b/test/test_e2e.py
index 96767ab..2398cce 100644
--- a/test/test_e2e.py
+++ b/test/test_e2e.py
@@ -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")