Search in sources :

Example 36 with TestClient

use of org.syncany.tests.util.TestClient in project syncany by syncany.

the class Issue429ScenarioTest method testSameFileDifferentNameFuzzy.

@Ignore
public void testSameFileDifferentNameFuzzy() throws Exception {
    for (int seed = 0; seed < 1000; seed++) {
        LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
        TestClient clientA = new TestClient("A", testConnection);
        TestClient clientB = new TestClient("B", testConnection);
        Random randomA = new Random(2 * seed);
        Random randomB = new Random(2 * seed + 1);
        Queue<String> queue = new ConcurrentLinkedQueue<>();
        activeThread A = new activeThread(randomA, clientA, queue);
        activeThread B = new activeThread(randomB, clientB, queue);
        Thread AThread = new Thread(A, "A");
        Thread BThread = new Thread(B, "B");
        try {
            AThread.start();
            BThread.start();
            for (int i = 0; i < 50; i++) {
                TestClient clientC = new TestClient("C", testConnection);
                clientC.down();
                if (!AThread.isAlive() || !BThread.isAlive()) {
                    throw new RuntimeException("One of the threads died");
                }
                FileUtils.deleteDirectory(clientC.getLocalFile(""));
                Thread.sleep(2000);
            }
            AThread.interrupt();
            BThread.interrupt();
        } catch (Exception e) {
            logger.log(Level.INFO, "Queue:" + queue.toString());
            logger.log(Level.INFO, "Something went wrong at seed: " + seed);
            throw e;
        }
        clientA.deleteTestData();
        clientB.deleteTestData();
    }
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) Random(java.util.Random) TestClient(org.syncany.tests.util.TestClient) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Ignore(org.junit.Ignore)

Example 37 with TestClient

use of org.syncany.tests.util.TestClient in project syncany by syncany.

the class ManySyncUpsAndOtherClientSyncDownScenarioTest method testManySyncUpsAndOtherClientSyncDown.

@Test
public void testManySyncUpsAndOtherClientSyncDown() throws Exception {
    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // ROUND 1: many sync up (cleanups expected)
    for (int i = 1; i <= 50; i++) {
        clientA.createNewFile("file" + i, 1);
        clientA.up();
    }
    // ROUND 2: sync down by B
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) Test(org.junit.Test)

Example 38 with TestClient

use of org.syncany.tests.util.TestClient in project syncany by syncany.

the class MixedUpDownScenarioTest method testMixedScenario1.

@Test
@Ignore
public void testMixedScenario1() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    TestClient clientC = new TestClient("C", testConnection);
    // Run
    clientC.createNewFile("C1");
    clientC.up();
    clientC.createNewFile("C2");
    clientC.up();
    clientC.createNewFile("C3");
    clientC.up();
    // NO CONFLICT
    clientB.down();
    assertFileListEquals("Client B and C should be on the same versions.", clientB.getLocalFilesExcludeLockedAndNoRead(), clientC.getLocalFilesExcludeLockedAndNoRead());
    // up without down! Evil!
    clientC.createNewFile("C4");
    clientC.up();
    // NO CONFLICT
    clientA.down();
    assertFileListEquals("Client A and C should be on the same versions.", clientA.getLocalFilesExcludeLockedAndNoRead(), clientC.getLocalFilesExcludeLockedAndNoRead());
    assertEquals("Client A should have C4, client B should not", clientA.getLocalFilesExcludeLockedAndNoRead().size() - 1, clientB.getLocalFilesExcludeLockedAndNoRead().size());
    clientB.createNewFile("B1,C3");
    clientB.up();
    clientA.createNewFile("A1,C4");
    clientA.up();
    clientA.createNewFile("A2,C4");
    clientA.up();
    clientA.createNewFile("A3,C4");
    clientA.up();
    // CONFLICT 1
    clientB.down();
    fail("Add some asserts");
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    // CONFLICT 2
    clientA.down();
    // CONFLICT 3
    clientC.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertFileListEquals(clientB.getLocalFilesExcludeLockedAndNoRead(), clientC.getLocalFilesExcludeLockedAndNoRead());
    clientA.createNewFile("A4,C4");
    clientA.up();
    clientA.createNewFile("A5,C4");
    clientA.up();
    clientC.createNewFile("A3,C5");
    clientC.up();
    clientC.createNewFile("A3,C6");
    clientC.up();
    clientC.createNewFile("A3,C7");
    clientC.up();
    clientB.createNewFile("A3,B2,C4");
    clientB.up();
    clientB.createNewFile("A3,B3,C4");
    clientB.up();
    clientB.createNewFile("A3,B4,C4");
    clientB.up();
    clientA.createNewFile("A6,C4");
    clientA.up();
    clientB.createNewFile("A3,B5,C4");
    clientB.up();
    clientC.createNewFile("A3,C8");
    clientC.up();
    // CONFLICT 4
    clientB.down();
    // CONFLICT 5
    clientA.down();
    // CONFLICT 6
    clientC.down();
    clientA.up();
    clientA.down();
    clientB.up();
    clientB.down();
    clientC.up();
    clientC.down();
    clientC.up();
    clientB.up();
    // CONFLICT 7
    clientC.down();
    // CONFLICT 8
    clientB.down();
    // CONFLICT 9
    clientA.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertFileListEquals(clientB.getLocalFilesExcludeLockedAndNoRead(), clientC.getLocalFilesExcludeLockedAndNoRead());
    assertEquals("File list count does not match.", 19, clientA.getLocalFilesExcludeLockedAndNoRead().size());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
    clientC.deleteTestData();
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 39 with TestClient

use of org.syncany.tests.util.TestClient in project syncany by syncany.

the class RenameDeleteScenarioTest method testDeleteFileThatHasAlreadyMoved.

@Test
public void testDeleteFileThatHasAlreadyMoved() throws Exception {
    // Scenario: A deletes a file that B has already moved
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // A new/up
    clientA.createNewFile("A-original");
    clientA.up();
    // B down/move/up
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // A moves, and up
    clientA.deleteFile("A-original");
    clientA.up();
    // B deletes, then down; this should not fail or throw exceptions
    clientB.moveFile("A-original", "B-moved");
    clientB.down();
    assertFalse("File A-orginal should not be recreated.", clientB.getLocalFile("A-original").exists());
    // Sync them
    clientB.sync();
    clientA.sync();
    assertFalse("File A-orginal should not be recreated.", clientA.getLocalFile("A-original").exists());
    assertFalse("File A-orginal should not be recreated.", clientB.getLocalFile("A-original").exists());
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Test(org.junit.Test)

Example 40 with TestClient

use of org.syncany.tests.util.TestClient in project syncany by syncany.

the class RenameNoDownloadMultiChunksScenarioTest method testRenameAndCheckIfMultiChunksAreDownloaded.

@Test
public void testRenameAndCheckIfMultiChunksAreDownloaded() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Run
    // Prepare, create file at A, sync it to B
    clientA.createNewFile("A-file1");
    clientA.sync();
    clientB.sync();
    // Now move file, and sync
    clientA.moveFile("A-file1", "A-file-moved1");
    clientA.up();
    DownOperationResult downOperationResult = clientB.down();
    assertEquals("No multichunks should have been downloaded.", 0, downOperationResult.getDownloadedMultiChunks().size());
    assertTrue("Moved files should exist.", clientB.getLocalFile("A-file-moved1").exists());
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : DownOperationResult(org.syncany.operations.down.DownOperationResult) TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Test(org.junit.Test)

Aggregations

TestClient (org.syncany.tests.util.TestClient)126 Test (org.junit.Test)122 TransferSettings (org.syncany.plugins.transfer.TransferSettings)65 LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)53 File (java.io.File)50 CleanupOperationOptions (org.syncany.operations.cleanup.CleanupOperationOptions)31 UnreliableLocalTransferSettings (org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings)28 UpOperationOptions (org.syncany.operations.up.UpOperationOptions)23 CleanupOperationResult (org.syncany.operations.cleanup.CleanupOperationResult)14 FilenameFilter (java.io.FilenameFilter)11 StorageException (org.syncany.plugins.transfer.StorageException)11 StatusOperationOptions (org.syncany.operations.status.StatusOperationOptions)10 MultichunkRemoteFile (org.syncany.plugins.transfer.files.MultichunkRemoteFile)10 DownOperationResult (org.syncany.operations.down.DownOperationResult)9 UpOperationResult (org.syncany.operations.up.UpOperationResult)8 DatabaseRemoteFile (org.syncany.plugins.transfer.files.DatabaseRemoteFile)6 SqlDatabase (org.syncany.database.SqlDatabase)5 TimeUnit (org.syncany.operations.cleanup.CleanupOperationOptions.TimeUnit)5 PluginOperationOptions (org.syncany.operations.plugin.PluginOperationOptions)5 PluginOperationResult (org.syncany.operations.plugin.PluginOperationResult)5