| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
import subprocess |
| 9 |
from rsyncfns import ( |
| 10 |
SCRATCHDIR, make_tree, makepath, rmtree, rsync_argv, |
| 11 |
start_test_daemon, test_fail, write_daemon_conf, |
| 12 |
) |
| 13 |
|
| 14 |
DAEMON_PORT = 12894 |
| 15 |
|
| 16 |
mod = SCRATCHDIR / 'csum-mod' |
| 17 |
rmtree(mod) |
| 18 |
makepath(mod) |
| 19 |
make_tree(mod, depth=2, data=True) |
| 20 |
|
| 21 |
conf = write_daemon_conf([ |
| 22 |
('csum', {'path': str(mod), 'read only': 'yes', |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
'transfer logging': 'yes', 'log format': '%o %C %f %l'}), |
| 27 |
]) |
| 28 |
url = start_test_daemon(conf, DAEMON_PORT).rstrip('/') |
| 29 |
|
| 30 |
dest = SCRATCHDIR / 'csum-pull' |
| 31 |
rmtree(dest) |
| 32 |
makepath(dest) |
| 33 |
|
| 34 |
|
| 35 |
r = subprocess.run(rsync_argv('-a', '-c', f'{url}/csum/', f'{dest}/'), |
| 36 |
capture_output=True, text=True) |
| 37 |
if r.returncode < 0 or r.returncode >= 128: |
| 38 |
test_fail(f'daemon-as-sender -c with %C crashed (rc={r.returncode}): ' |
| 39 |
f'{r.stderr.strip()[:200]}') |
| 40 |
if not any(dest.rglob('f*')): |
| 41 |
test_fail(f'pull transferred no files (rc={r.returncode}): {r.stderr.strip()[:200]}') |
| 42 |
print("scanner-daemon-log-checksum: daemon-as-sender -c with %C log format is clean") |