Debian Codegraph @

testsuite/change-vanish_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # Change-while-transferring: a source file that is DELETED between flist-scan
3 # and send. rsync's documented behaviour is to warn ("file has vanished") and
4 # continue (exit 24), not to abort the whole run. This guards that a vanished
5 # file during a mid-transfer window is still handled gracefully and later files
6 # transfer.
7 #
8 # See mutatefns.py for the pacer/bwlimit reproduction.
9
10 import os
11
12 from mutatefns import TARGET, assert_no_protocol_abort, run_mutating_transfer
13 from rsyncfns import test_fail
14
15
16 def setup(src):
17 with open(src / TARGET, 'wb') as fh:
18 fh.write(os.urandom(256 * 1024))
19
20
21 def mutate(src):
22 os.unlink(src / TARGET)
23
24
25 proc, src, dst = run_mutating_transfer(setup, mutate)
26 assert_no_protocol_abort(proc)
27
28 if (src / TARGET).exists():
29 test_fail("test setup: source file did not vanish")
30
31 # The pacer (transferred before the vanish) and any earlier files must survive.
32 if not (dst / 'aaa_pacer').is_file():
33 test_fail("the pacer file was not transferred after the vanish")
34
35 print(f"change-vanish: source file removed mid-transfer; rsync exit "
36 f"{proc.returncode} (0/24 ok), no protocol abort, later files intact")