|
| 1 | + |
| 2 | +__doc__ = """ |
| 3 | +
|
| 4 | +This test is testing that moving files server multiple do not get uploaded |
| 5 | +too much. Even if the files are moved when the sync is running. |
| 6 | +[https://github.com/owncloud/client/issues/4370] |
| 7 | +
|
| 8 | +""" |
| 9 | + |
| 10 | +from smashbox.utilities import * |
| 11 | +import subprocess |
| 12 | + |
| 13 | +nfiles = 20 |
| 14 | +TEST_FILES = ['test%02d.dat'%i for i in range(nfiles)] |
| 15 | + |
| 16 | +def getFileId(syncdir, fileName): |
| 17 | + return subprocess.check_output(["sqlite3" , syncdir + "/.csync_journal.db", |
| 18 | + "select fileid from metadata where path = \"" + fileName + "\""]) |
| 19 | + |
| 20 | +@add_worker |
| 21 | +def workerA(step): |
| 22 | + if compare_client_version('2.1.0', '<='): |
| 23 | + logger.warning('Skipping test, because the client version is known to behave incorrectly') |
| 24 | + return |
| 25 | + |
| 26 | + #cleanup remote and local test environment - this should be run once by one worker only |
| 27 | + reset_owncloud_account() |
| 28 | + reset_rundir() |
| 29 | + |
| 30 | + syncdir = make_workdir("workdir") |
| 31 | + d1 = os.path.join(syncdir,"dir1") |
| 32 | + d2 = os.path.join(syncdir,"dir2") |
| 33 | + d_final = os.path.join(syncdir,"dirFinal") |
| 34 | + |
| 35 | + step(0,'create initial content and sync') |
| 36 | + |
| 37 | + |
| 38 | + # create a folder and some files in it |
| 39 | + mkdir(d1) |
| 40 | + |
| 41 | + for f in TEST_FILES: |
| 42 | + fn = os.path.join(d1,f) |
| 43 | + createfile(fn,'0',count=1000,bs=1000) |
| 44 | + |
| 45 | + run_ocsync(syncdir) |
| 46 | + |
| 47 | + fileIds = list(map((lambda f:getFileId(syncdir, 'dir1/' + f)), TEST_FILES)) |
| 48 | + |
| 49 | + step(1,'move the folder') |
| 50 | + |
| 51 | + mkdir(d2) |
| 52 | + mv(d1+"/*",d2) |
| 53 | + |
| 54 | + step(2, 'sync') |
| 55 | + run_ocsync(syncdir) |
| 56 | + |
| 57 | + step(3,'final sync') |
| 58 | + |
| 59 | + run_ocsync(syncdir) |
| 60 | + |
| 61 | + final_fileIds = list(map((lambda f:getFileId(syncdir, 'dirFinal/' + f)), TEST_FILES)) |
| 62 | + |
| 63 | + #The file ids needs to stay the same for every files, since they only got moved and not re-uploaded |
| 64 | + error_check(fileIds == final_fileIds, "File id differ (%s != %s)" % (fileIds, final_fileIds)) |
| 65 | + |
| 66 | + |
| 67 | +@add_worker |
| 68 | +def workerB(step): |
| 69 | + |
| 70 | + if compare_client_version('2.1.0', '<='): |
| 71 | + logger.warning('Skipping test, because the client version is known to behave incorrectly') |
| 72 | + return |
| 73 | + |
| 74 | + step(2,'move the folder during the sync') |
| 75 | + |
| 76 | + syncdir = make_workdir("workdir") |
| 77 | + d1 = os.path.join(syncdir,"dir1") |
| 78 | + d2 = os.path.join(syncdir,"dir2") |
| 79 | + d3 = os.path.join(syncdir,"dir3") |
| 80 | + d4 = os.path.join(syncdir,"dir4") |
| 81 | + d5 = os.path.join(syncdir,"dir5") |
| 82 | + d6 = os.path.join(syncdir,"dir6") |
| 83 | + d_final = os.path.join(syncdir,"dirFinal") |
| 84 | + |
| 85 | + #Do it several time with one second interval to be sure we do it at lease once |
| 86 | + # during the propagation phase |
| 87 | + sleep(1) |
| 88 | + mkdir(d3) |
| 89 | + mv(d2+"/*",d3) |
| 90 | + |
| 91 | + sleep(1) |
| 92 | + mkdir(d4) |
| 93 | + mv(d3+"/*",d4) |
| 94 | + |
| 95 | + sleep(1) |
| 96 | + mkdir(d5) |
| 97 | + mv(d4+"/*",d5) |
| 98 | + |
| 99 | + sleep(1) |
| 100 | + mkdir(d6) |
| 101 | + mv(d5+"/*",d6) |
| 102 | + |
| 103 | + sleep(1) |
| 104 | + mkdir(d_final) |
| 105 | + mv(d6+"/*",d_final) |
| 106 | + |
0 commit comments