feat(p5-rsh): --rsh/-e, --rsync-path, --blocking-io, --outbuf

This commit is contained in:
2026-09-09 13:41:28 +02:00
parent 90ccf297d7
commit 858af3d63d
12 changed files with 462 additions and 42 deletions
+50
View File
@@ -4604,3 +4604,53 @@ class TestExtendedAttributes:
fields = record.split(":")
assert len(fields) == 5
assert fields[0] == str(uid), f"reserved uid field {fields[0]} != source uid {uid}"
class TestConnectivityClientOptions:
"""Phase 5 connectivity launch options (--outbuf, --blocking-io).
These are client-side launch concerns: --outbuf only restyles stdout/stderr
buffering and --blocking-io only skips the SSH transport socket timeouts.
Over the TCP transport both must parse cleanly and be inert -- a transfer
must still complete and verify byte-for-byte."""
def _source_and_dest(self, name):
source = os.path.join(TEST_DATA_DIR, name + "_src")
dest = os.path.join(TEST_DATA_DIR, name + "_dst")
clean_dir(source)
clean_dir(dest)
return source, dest
@pytest.mark.parametrize("flag", ["--outbuf=N", "--outbuf=L", "--outbuf=B",
"--blocking-io"])
def test_option_does_not_break_transfer(self, shared_server, flag):
source, dest = self._source_and_dest("connopt")
with open(os.path.join(source, "hello.txt"), "wb") as f:
f.write(b"connectivity options\n" * 100)
with open(os.path.join(source, "data.bin"), "wb") as f:
f.write(os.urandom(512 * 1024))
result, _ = run_client(source, dest, flags=[flag], port=shared_server.port)
assert result.returncode == 0, \
f"{flag} failed: {(result.stderr or result.stdout)[:300]}"
mismatches, missing = verify_transfer(source, get_dest_received_dir(dest, source))
assert not mismatches and not missing, \
f"{flag}: mismatches={mismatches[:3]} missing={missing[:3]}"
def test_rejects_invalid_outbuf(self, shared_server):
source, dest = self._source_and_dest("connopt_bad")
with open(os.path.join(source, "x.txt"), "wb") as f:
f.write(b"x")
result, _ = run_client(source, dest, flags=["--outbuf=Z"], port=shared_server.port)
assert result.returncode != 0, "--outbuf=Z must be rejected"
def test_blocking_io_does_not_break_compressed_transfer(self, shared_server):
source, dest = self._source_and_dest("connopt_zlib")
with open(os.path.join(source, "text.txt"), "wb") as f:
f.write(b"compress me\n" * 4096)
result, _ = run_client(source, dest, flags=["--blocking-io", "-c"],
port=shared_server.port)
assert result.returncode == 0, \
f"--blocking-io -c failed: {(result.stderr or result.stdout)[:300]}"
mismatches, missing = verify_transfer(source, get_dest_received_dir(dest, source))
assert not mismatches and not missing
+42 -3
View File
@@ -64,11 +64,12 @@ def setup_test_data():
shutil.rmtree(DEST_DIR, ignore_errors=True)
def _run_ssh_test(name, flags, expected_missing=None):
def _run_ssh_test(name, flags, expected_missing=None, path_args=None):
ssh_dest = f"localhost:{DEST_DIR}"
clean_dir(DEST_DIR)
cmd = CLIENT_CMD + [SOURCE_DIR, ssh_dest, "--save-to-disk",
"--fastsync-server-path", os.path.join(BUILD_DIR, "server")] + flags
if not path_args:
path_args = ["--fastsync-server-path", os.path.join(BUILD_DIR, "server")]
cmd = CLIENT_CMD + [SOURCE_DIR, ssh_dest, "--save-to-disk"] + path_args + flags
start = __import__("time").monotonic()
result = subprocess.run(cmd, text=True, capture_output=True)
duration = __import__("time").monotonic() - start
@@ -142,3 +143,41 @@ class TestSSHFeatures:
def test_preallocate(self):
r = _run_ssh_test("SSH Preallocate (--preallocate)", ["--preallocate"])
assert r["status"] == "Success", r["error"]
class TestSSHConnectivity:
"""Phase 5 connectivity options: -e/--rsh, --rsync-path, --blocking-io,
--outbuf. These are client-side launch concerns, so each must parse and
still drive a real SSH transfer to completion."""
@pytest.fixture(autouse=True)
def require_ssh(self):
if not SSH_AVAILABLE:
pytest.skip(SSH_SKIP_REASON)
def test_rsh_short_form_selects_ssh(self):
r = _run_ssh_test("SSH -e ssh", ["-e", "ssh"])
assert r["status"] == "Success", r["error"]
def test_rsh_long_form_selects_ssh(self):
r = _run_ssh_test("SSH --rsh=ssh", ["--rsh=ssh"])
assert r["status"] == "Success", r["error"]
def test_rsync_path_aliases_server_path(self):
r = _run_ssh_test("SSH --rsync-path",
[],
path_args=["--rsync-path", os.path.join(BUILD_DIR, "server")])
assert r["status"] == "Success", r["error"]
def test_blocking_io(self):
r = _run_ssh_test("SSH --blocking-io", ["--blocking-io"])
assert r["status"] == "Success", r["error"]
@pytest.mark.parametrize("mode", ["N", "L", "B"])
def test_outbuf_mode(self, mode):
r = _run_ssh_test(f"SSH --outbuf={mode}", [f"--outbuf={mode}"])
assert r["status"] == "Success", r["error"]
def test_blocking_io_with_compression(self):
r = _run_ssh_test("SSH --blocking-io -c", ["--blocking-io", "-c"])
assert r["status"] == "Success", r["error"]