Search in sources :

Example 51 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class Issue143ScenarioTest method testChangeAttributes.

@Test
public void testChangeAttributes() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    java.sql.Connection databaseConnectionA = clientA.getConfig().createDatabaseConnection();
    TestClient clientB = new TestClient("B", testConnection);
    CleanupOperationOptions cleanupOptions = new CleanupOperationOptions();
    cleanupOptions.setMinSecondsBetweenCleanups(0);
    cleanupOptions.setMinKeepSeconds(0);
    // Scenario, see
    // https://github.com/syncany/syncany/issues/143#issuecomment-50964685
    // Run
    clientA.createNewFile("file1.jpg");
    clientA.upWithForceChecksum();
    assertEquals("1", TestSqlUtil.runSqlSelect("select count(*) from databaseversion", databaseConnectionA));
    TestFileUtil.copyFile(clientA.getLocalFile("file1.jpg"), clientA.getLocalFile("file1 (copy).jpg"));
    clientA.upWithForceChecksum();
    assertEquals("2", TestSqlUtil.runSqlSelect("select count(*) from databaseversion", databaseConnectionA));
    clientA.deleteFile("file1 (copy).jpg");
    clientA.upWithForceChecksum();
    assertEquals("3", TestSqlUtil.runSqlSelect("select count(*) from databaseversion", databaseConnectionA));
    // Database versions of deleted file are removed
    clientA.cleanup(cleanupOptions);
    assertEquals("1", TestSqlUtil.runSqlSelect("select count(*) from databaseversion", databaseConnectionA));
    TestFileUtil.copyFile(clientA.getLocalFile("file1.jpg"), clientA.getLocalFile("file1 (copy).jpg"));
    clientA.upWithForceChecksum();
    assertEquals("2", TestSqlUtil.runSqlSelect("select count(*) from databaseversion", databaseConnectionA));
    clientA.deleteFile("file1.jpg");
    clientA.upWithForceChecksum();
    assertEquals("3", TestSqlUtil.runSqlSelect("select count(*) from databaseversion", databaseConnectionA));
    // Database version of deleted file is removed
    clientA.cleanup(cleanupOptions);
    assertEquals("2", TestSqlUtil.runSqlSelect("select count(*) from databaseversion", databaseConnectionA));
    // <<<< This creates the exception in #143
    clientB.down();
    // integrity constraint violation: foreign key no parent; SYS_FK_10173 table: FILEVERSION
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : TestClient(org.syncany.tests.util.TestClient) CleanupOperationOptions(org.syncany.operations.cleanup.CleanupOperationOptions) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Test(org.junit.Test)

Example 52 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class ManyRenamesScenarioTest method testManyRenames.

@Test
public void testManyRenames() throws Exception {
    // 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());
    clientB.moveFile("A-original", "B-moved");
    clientB.up();
    // A down/move/up
    clientA.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    clientA.moveFile("B-moved", "A-moved");
    clientA.up();
    // B down only
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // A down/move/up
    clientA.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    clientA.moveFile("A-moved", "A-moved-again");
    clientA.up();
    // B down/move/up
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // same filename as above!
    clientB.moveFile("A-moved-again", "B-moved");
    clientB.up();
    // A down/move/up
    clientA.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // same filename as above!
    clientA.moveFile("B-moved", "A-moved");
    clientA.up();
    // B down only
    clientB.down();
    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 53 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class LongRunningLargeFileScenarioTest method testLargeFile.

private void testLargeFile(long size) throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    Logging.disableLogging();
    logln("NOTE: This test can take several minutes!");
    logln("Disabling console logging for this test; Too much output/overhead.");
    logln("");
    // A
    logln("Creating large file for scenario (" + (size / 1024L / 1024L) + " MB) ...");
    clientA.createNewFile("A-large-file.zip", size);
    logln("Done creating large file. Now creating checksum ...");
    String checksumFileA = StringUtil.toHex(TestFileUtil.createChecksum(clientA.getLocalFile("A-large-file.zip")));
    logln("Done. Checksum is: " + checksumFileA);
    logln("clientA.up() started.");
    clientA.up();
    logln("clientA.up() completed.");
    logln("Freeing up space, deleting file at client A ...");
    clientA.deleteFile("A-large-file.zip");
    logln("Deleting done.");
    // B
    logln("clientB.down(); started.");
    clientB.down();
    logln("clientB.down(); completed.");
    String checksumFileB = StringUtil.toHex(TestFileUtil.createChecksum(clientB.getLocalFile("A-large-file.zip")));
    logln("Done. Checksum is: " + checksumFileB);
    logln("Freeing up space, deleting file at client B ...");
    clientB.deleteFile("A-large-file.zip");
    logln("Deleting done.");
    try {
        assertEquals("File checksum should be equal. ", checksumFileA, checksumFileB);
        assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    } finally {
        // Tear down
        clientA.deleteTestData();
        clientB.deleteTestData();
    }
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings)

Example 54 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class LongRunningNewAndDeleteScenarioTest method testLongRunningNewAndDeleteFilesNoConflicts.

@Test
public void testLongRunningNewAndDeleteFilesNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Disable logging
    logger.log(Level.INFO, "NOTE: This test can take several minutes!");
    logger.log(Level.INFO, "Disabling console logging for this test; Too much output/overhead.");
    Logging.disableLogging();
    // Run
    for (int round = 1; round < 30; round++) {
        // A
        for (int i = 1; i < 100; i++) {
            clientA.createNewFile("A-file-with-size-" + i + ".jpg", i);
        }
        clientA.up();
        // B
        clientB.down();
        assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
        assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
        for (int i = 1; i < 100; i++) {
            clientB.changeFile("A-file-with-size-" + i + ".jpg");
        }
        clientB.up();
        // A
        clientA.down();
        assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
        assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
        for (int i = 1; i < 100; i++) {
            clientA.deleteFile("A-file-with-size-" + i + ".jpg");
        }
        clientA.up();
        // B
        clientB.down();
        assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
        assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    }
    fail("No asserts yet.");
    // 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 55 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class SingleFileNoConflictsScenarioTest method testSingleFileDeleteNoConflicts.

@Test
public void testSingleFileDeleteNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Create files and upload
    clientA.createNewFile("file");
    clientA.up();
    clientB.down();
    assertFileEquals(clientA.getLocalFile("file"), clientB.getLocalFile("file"));
    clientB.deleteFile("file");
    clientB.up();
    clientA.down();
    assertFalse("Deleted file should not exist.", clientA.getLocalFile("file").exists());
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    // Cleanup
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Test(org.junit.Test)

Aggregations

TransferSettings (org.syncany.plugins.transfer.TransferSettings)78 Test (org.junit.Test)67 TestClient (org.syncany.tests.util.TestClient)65 File (java.io.File)20 LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)10 TransferPlugin (org.syncany.plugins.transfer.TransferPlugin)7 SqlDatabase (org.syncany.database.SqlDatabase)5 DownOperationResult (org.syncany.operations.down.DownOperationResult)4 StatusOperationResult (org.syncany.operations.status.StatusOperationResult)4 UpOperationOptions (org.syncany.operations.up.UpOperationOptions)4 UpOperationResult (org.syncany.operations.up.UpOperationResult)4 CreateFileTree (org.syncany.tests.integration.scenarios.framework.CreateFileTree)4 IOException (java.io.IOException)3 RandomAccessFile (java.io.RandomAccessFile)3 Path (java.nio.file.Path)3 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)3 Config (org.syncany.config.Config)3 ConfigTO (org.syncany.config.to.ConfigTO)3 PartialFileHistory (org.syncany.database.PartialFileHistory)3 FileHistoryId (org.syncany.database.PartialFileHistory.FileHistoryId)3