Test: Disable local discovery parallelism in permission test
authorChristian Kamm <mail@ckamm.de>
Thu, 12 Sep 2019 07:13:04 +0000 (09:13 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:00 +0000 (10:59 +0100)
Adding parallelism broke the test because it depended on the order of
discovery.

src/libsync/discovery.cpp
test/testpermissions.cpp

index 3406fdf4806c6880b054aa95388b88414c02bbaf..275a7703617af808566d186e327025a3f16ef213 100644 (file)
@@ -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
index 6640d50f2b2ab9ba7b4b6dddf79f34cc68f92302..e3704901552d0aa11586a1a2822cb277ec458a53 100644 (file)
@@ -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"));
     }
 };