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();
}
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();
}
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();
}
}
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();
}
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();
}
Aggregations