Files
rclone/fs/logger/testdata/script/TestBeforeVsAfter.txtar
Nick Craig-Wood eb84a383a3 fs/logger: fix flaky tests by generating test data locally
The TestLogger/TestRepoCompare and TestLogger/TestBeforeVsAfter
testscript scenarios filled src and dst by downloading two old rclone
source archives from GitHub with `rclone copyurl`. Whenever GitHub or
the network hiccuped (eg a 502 Bad Gateway) the downloads failed and
the tests failed with it, making them flaky on CI.

Generate two overlapping trees of files in the test Setup instead.
They cover the same comparison categories the scripts exercise
(matching, differing, src-only and dst-only files) so the tests are
just as meaningful but no longer depend on the network.
2026-06-01 20:47:11 +01:00

42 lines
1.8 KiB
Plaintext

# tests whether an md5sum file generated post-sync matches our pre-sync prediction
# src and dst are filled by the test Setup with two overlapping trees of files.
# generating sumfiles:
exec rclone md5sum $SRC --output-file $WORK/src-before.txt
exec rclone md5sum $DST --output-file $WORK/dst-before.txt
# running sync with output files:
exec rclone sync $SRC $DST --match $WORK/SYNCmatch.txt --combined $WORK/SYNCcombined.txt --missing-on-src $WORK/SYNCmissingonsrc.txt --missing-on-dst $WORK/SYNCmissingondst.txt --error $WORK/SYNCerr.txt --differ $WORK/SYNCdiffer.txt --dest-after $WORK/SYNCdestafter.txt --format 'hp' --separator ' '
# generating sumfiles:
exec rclone md5sum $SRC --output-file $WORK/src-after.txt
exec rclone md5sum $DST --output-file $WORK/dst-after.txt
# sorting them by line and diffing:
exec sort $WORK/src-before.txt -o $WORK/src-before.txt
exec sort $WORK/dst-before.txt -o $WORK/dst-before.txt
exec sort $WORK/src-after.txt -o $WORK/src-after.txt
exec sort $WORK/dst-after.txt -o $WORK/dst-after.txt
exec sort $WORK/SYNCmatch.txt -o $WORK/SYNCmatch.txt
exec sort $WORK/SYNCcombined.txt -o $WORK/SYNCcombined.txt
exec sort $WORK/SYNCmissingonsrc.txt -o $WORK/SYNCmissingonsrc.txt
exec sort $WORK/SYNCmissingondst.txt -o $WORK/SYNCmissingondst.txt
exec sort $WORK/SYNCerr.txt -o $WORK/SYNCerr.txt
exec sort $WORK/SYNCdiffer.txt -o $WORK/SYNCdiffer.txt
exec sort $WORK/SYNCdestafter.txt -o $WORK/SYNCdestafter.txt
# diff src before vs src after:
cmp $WORK/src-before.txt $WORK/src-after.txt
# diff dst before vs dst after:
! cmp $WORK/dst-before.txt $WORK/dst-after.txt
# diff src before vs dst after:
cmp $WORK/src-before.txt $WORK/dst-after.txt
# diff dst before vs src after:
! cmp $WORK/dst-before.txt $WORK/src-after.txt
# diff md5sum dst after vs sync dest-after:
cmp $WORK/dst-after.txt $WORK/SYNCdestafter.txt