From e91e1ca78f3482575692172816a773fb2a111394 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Thu, 12 Sep 2019 09:13:04 +0200 Subject: [PATCH] Test: Disable local discovery parallelism in permission test Adding parallelism broke the test because it depended on the order of discovery. --- src/libsync/discovery.cpp | 1 + test/testpermissions.cpp | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 3406fdf48..275a77036 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -934,6 +934,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( // More complicated. The REMOVE is canceled. Restore will happen next sync. qCInfo(lcDisco) << "Undid remove instruction on source" << originalPath; _discoveryData->_statedb->deleteFileRecord(originalPath, true); + _discoveryData->_statedb->schedulePathForRemoteDiscovery(originalPath); _discoveryData->_anotherSyncNeeded = true; } else { // Signal to future checkPermissions() to forbid the REMOVE and set to restore instead diff --git a/test/testpermissions.cpp b/test/testpermissions.cpp index 6640d50f2..e37049015 100644 --- a/test/testpermissions.cpp +++ b/test/testpermissions.cpp @@ -83,6 +83,13 @@ private slots: FakeFolder fakeFolder{ FileInfo() }; QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + // Some of this test depends on the order of discovery. With threading + // that order becomes effectively random, but we want to make sure to test + // all cases and thus disable threading. + auto syncOpts = fakeFolder.syncEngine().syncOptions(); + syncOpts._parallelNetworkJobs = 1; + fakeFolder.syncEngine().setSyncOptions(syncOpts); + const int cannotBeModifiedSize = 133; const int canBeModifiedSize = 144; @@ -354,6 +361,13 @@ private slots: { FakeFolder fakeFolder{FileInfo{}}; + // Some of this test depends on the order of discovery. With threading + // that order becomes effectively random, but we want to make sure to test + // all cases and thus disable threading. + auto syncOpts = fakeFolder.syncEngine().syncOptions(); + syncOpts._parallelNetworkJobs = 1; + fakeFolder.syncEngine().setSyncOptions(syncOpts); + auto &lm = fakeFolder.localModifier(); auto &rm = fakeFolder.remoteModifier(); rm.mkdir("allowed"); @@ -441,7 +455,7 @@ private slots: QVERIFY(itemInstruction(completeSpy, "zallowed/sub2/file", CSYNC_INSTRUCTION_NEW)); QCOMPARE(fakeFolder.syncEngine().isAnotherSyncNeeded(), ImmediateFollowUp); - // A follow-up sync will restore allowed/file and allowed/sub2 and maintain the createdir/file errors + // A follow-up sync will restore allowed/file and allowed/sub2 and maintain the nocreatedir/file errors completeSpy.clear(); QVERIFY(!fakeFolder.syncOnce()); @@ -453,6 +467,13 @@ private slots: QVERIFY(itemInstruction(completeSpy, "allowed/file", CSYNC_INSTRUCTION_NEW)); QVERIFY(itemInstruction(completeSpy, "allowed/sub2", CSYNC_INSTRUCTION_NEW)); QVERIFY(itemInstruction(completeSpy, "allowed/sub2/file", CSYNC_INSTRUCTION_NEW)); + + auto cls = fakeFolder.currentLocalState(); + QVERIFY(cls.find("allowed/file")); + QVERIFY(cls.find("allowed/sub2")); + QVERIFY(cls.find("zallowed/file")); + QVERIFY(cls.find("zallowed/sub2")); + QVERIFY(cls.find("zallowed/sub2/file")); } }; -- 2.30.2