Search in sources :

Example 1 with LocalTransferSettings

use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.

the class Issue374Pre1965DateScenarioTest method testIssue316CleanupThenDeleteFile.

@Test
public void testIssue316CleanupThenDeleteFile() throws Exception {
    /*
		 * This test simulates files with a timestamp before 1965 (unix time < 0).  
		 */
    // Setup 
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    clientA.createNewFile("pre1965.txt");
    Date dateBefore1965 = new SimpleDateFormat("dd-MM-yyyy").parse("31-12-1964");
    Files.setLastModifiedTime(clientA.getLocalFile("pre1965.txt").toPath(), FileTime.fromMillis(dateBefore1965.getTime()));
    clientA.upWithForceChecksum();
    // This was throwing an exception in FileSystemAction.setLastModified()
    clientB.down();
    // Tear down
    clientB.deleteTestData();
    clientA.deleteTestData();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 2 with LocalTransferSettings

use of org.syncany.plugins.local.LocalTransferSettings 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 3 with LocalTransferSettings

use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.

the class Issue429ScenarioTest method testSpecificQueue.

@Ignore
public void testSpecificQueue() throws Exception {
    String[] commands = new String[] { "A5", "B5", "B0", "B0", "A7", "A3", "B6", "B1", "A7", "A6", "A7", "B5", "A1", "A0", "B6", "A5", "B0", "B6", "A7", "A0", "B7", "A5", "B1", "B7", "A6", "B7", "A0", "A3", "B4", "B7", "A2", "A7", "A4", "B1", "B4", "A3", "B0", "A0", "A4", "A6", "B3", "B3", "B2", "A1", "B1", "B3", "A1", "A7", "B7", "B7", "A1", "B4", "A4", "A4", "A1", "B4", "A6", "B2", "B5", "B7", "A5", "B2", "B2", "B3", "B1", "B5", "B3", "B1", "B3", "B2", "B4" };
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    for (String command : commands) {
        int choice = Integer.parseInt(command.substring(1));
        if (command.contains("A")) {
            performAction(clientA, choice);
        } else {
            performAction(clientB, choice);
        }
    }
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) Ignore(org.junit.Ignore)

Example 4 with LocalTransferSettings

use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.

the class ManySyncUpsAndDatabaseFileCleanupScenarioTest method testManySyncUpsAndDatabaseFileCleanup.

@Test
public void testManySyncUpsAndDatabaseFileCleanup() throws Exception {
    // Setup 
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    // ROUND 1: many sync up (no cleanup expected here)		
    for (int i = 1; i <= 15; i++) {
        clientA.createNewFile("file" + i, 1);
        clientA.up();
    }
    for (int i = 1; i <= 15; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file SHOULD exist: " + expectedDatabaseFile, expectedDatabaseFile.exists());
    }
    // ROUND 2: 1x sync up (cleanup expected!)
    clientA.createNewFile("file16", 1);
    clientA.up();
    // Force cleanup
    clientA.cleanup();
    for (int i = 1; i <= 15; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file should NOT exist: " + expectedDatabaseFile, !expectedDatabaseFile.exists());
    }
    for (int i = 17; i <= 17; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file SHOULD exist: " + expectedDatabaseFile, expectedDatabaseFile.exists());
    }
    // ROUND 3: many sync up (no cleanup expected here)		
    for (int i = 17; i <= 30; i++) {
        clientA.createNewFile("file" + i, 1);
        clientA.up();
    }
    for (int i = 1; i <= 16; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file should NOT exist: " + expectedDatabaseFile, !expectedDatabaseFile.exists());
    }
    for (int i = 17; i <= 31; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file SHOULD exist: " + expectedDatabaseFile, expectedDatabaseFile.exists());
    }
    // ROUND 4: 1x sync up (cleanup expected!)
    clientA.createNewFile("file31", 1);
    clientA.up();
    CleanupOperationOptions options = new CleanupOperationOptions();
    options.setForce(true);
    // Force cleanup 
    clientA.cleanup(options);
    for (int i = 1; i <= 32; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file should NOT exist: " + expectedDatabaseFile, !expectedDatabaseFile.exists());
    }
    for (int i = 33; i <= 33; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file SHOULD exist: " + expectedDatabaseFile, expectedDatabaseFile.exists());
    }
    // Tear down
    TestClient clientB = new TestClient("B", testConnection);
    clientB.down();
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) DatabaseRemoteFile(org.syncany.plugins.transfer.files.DatabaseRemoteFile) CleanupOperationOptions(org.syncany.operations.cleanup.CleanupOperationOptions) DatabaseRemoteFile(org.syncany.plugins.transfer.files.DatabaseRemoteFile) File(java.io.File) Test(org.junit.Test)

Example 5 with LocalTransferSettings

use of org.syncany.plugins.local.LocalTransferSettings 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)

Aggregations

LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)61 Test (org.junit.Test)50 TestClient (org.syncany.tests.util.TestClient)46 File (java.io.File)33 CleanupOperationOptions (org.syncany.operations.cleanup.CleanupOperationOptions)21 UnreliableLocalTransferSettings (org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings)17 UpOperationOptions (org.syncany.operations.up.UpOperationOptions)13 CleanupOperationResult (org.syncany.operations.cleanup.CleanupOperationResult)8 FilenameFilter (java.io.FilenameFilter)7 InitOperationOptions (org.syncany.operations.init.InitOperationOptions)7 UpOperationResult (org.syncany.operations.up.UpOperationResult)7 Random (java.util.Random)6 ConfigTO (org.syncany.config.to.ConfigTO)6 StatusOperationOptions (org.syncany.operations.status.StatusOperationOptions)6 SqlDatabase (org.syncany.database.SqlDatabase)5 PluginOperationOptions (org.syncany.operations.plugin.PluginOperationOptions)5 PluginOperationResult (org.syncany.operations.plugin.PluginOperationResult)5 TimeUnit (org.syncany.operations.cleanup.CleanupOperationOptions.TimeUnit)4 DownOperationResult (org.syncany.operations.down.DownOperationResult)4 InitOperation (org.syncany.operations.init.InitOperation)4