Debian Codegraph @

testsuite/daemon-delete-stats_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 """Daemon upload delete stats report deleted files."""
3
4 import subprocess
5
6 from rsyncfns import (
7 FROMDIR, TODIR,
8 build_rsyncd_conf, forced_protocol, makepath, rmtree, rsync_argv,
9 start_test_daemon, test_fail,
10 )
11
12
13 DAEMON_PORT = 12899
14
15 src = FROMDIR
16 dst = TODIR
17
18 rmtree(src)
19 rmtree(dst)
20 makepath(src, dst)
21
22 (src / 'keep.txt').write_text("keep\n")
23 (dst / 'keep.txt').write_text("keep\n")
24 (dst / 'delete.txt').write_text("delete\n")
25
26 url = start_test_daemon(build_rsyncd_conf(), DAEMON_PORT)
27
28 proc = subprocess.run(
29 rsync_argv('-a', '--delete', '-i', '--stats', f'{src}/', f'{url}test-to/'),
30 capture_output=True,
31 text=True,
32 )
33 out = proc.stdout + proc.stderr
34 print(out)
35
36 if proc.returncode != 0:
37 test_fail(f"daemon upload delete run exited {proc.returncode}")
38
39 if '*deleting delete.txt' not in out:
40 test_fail(f"daemon upload did not itemize the deleted file:\n{out}")
41
42 # The delete-stats summary line is only sent to the client at protocol >= 31
43 # (the NDX_DEL_STATS message); an older client can't receive the count, so
44 # only assert it when the protocol isn't pinned below 31.
45 pv = forced_protocol()
46 if pv is None or pv >= 31:
47 if 'Number of deleted files: 1 (reg: 1)' not in out:
48 test_fail(f"daemon upload did not report the deleted file in stats:\n{out}")