use of org.syncany.operations.cleanup.CleanupOperationOptions in project syncany by syncany.
the class Issue316ScenarioTest method testIssue316CleanupThenDeleteFile.
@Test
public void testIssue316CleanupThenDeleteFile() throws Exception {
/*
* This is a test for issue #316. It creates a situation in which a 'down'
* fails after a cleanup. In that first down, the local database is deleted
* entirely, so that all databases are downloaded again, so all remote file
* versions are compared to "null". In this bug, comparing a deleted file version
* to a local existing file failed, because this case was thought to not happen
* ever.
*/
// Setup
UnreliableLocalTransferSettings testConnection = TestConfigUtil.createTestUnreliableLocalConnection(Arrays.asList(new String[] { // << 3 retries!
"rel=(5|6|7) .+download.+multichunk" }));
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
java.sql.Connection databaseConnectionB = clientB.getConfig().createDatabaseConnection();
CleanupOperationOptions cleanupOptionsKeepOne = new CleanupOperationOptions();
cleanupOptionsKeepOne.setMaxDatabaseFiles(1);
cleanupOptionsKeepOne.setForce(true);
clientA.createNewFile("Kazam_screencast_00010.mp4");
clientA.upWithForceChecksum();
clientB.down();
assertTrue(clientB.getLocalFile("Kazam_screencast_00010.mp4").exists());
clientA.createNewFile("SomeFileTOIncreaseTheDatabaseFileCount");
clientA.upWithForceChecksum();
CleanupOperationResult cleanupResult = clientA.cleanup(cleanupOptionsKeepOne);
assertEquals(CleanupResultCode.OK, cleanupResult.getResultCode());
clientA.deleteFile("Kazam_screencast_00010.mp4");
clientA.upWithForceChecksum();
// First 'down' of client B after the cleanup.
// This fails AFTER the local database was wiped.
boolean downFailedAtB = false;
try {
clientB.down();
} catch (Exception e) {
downFailedAtB = true;
}
assertTrue("Down operation should have failed.", downFailedAtB);
assertEquals("0", TestSqlUtil.runSqlSelect("select count(*) from databaseversion", databaseConnectionB));
assertEquals("0", TestSqlUtil.runSqlSelect("select count(*) from fileversion", databaseConnectionB));
assertEquals("0", TestSqlUtil.runSqlSelect("select count(*) from known_databases", databaseConnectionB));
// Second 'down' of client B; This should delete the file 'Kazam_screencast_00010.mp4',
// because it matches the checksum of the 'DELETED' entry
clientB.down();
assertConflictingFileNotExists("Kazam_screencast_00010.mp4", clientB.getLocalFiles());
assertFalse(clientB.getLocalFile("Kazam_screencast_00010.mp4").exists());
// Tear down
clientB.deleteTestData();
clientA.deleteTestData();
}
use of org.syncany.operations.cleanup.CleanupOperationOptions in project syncany by syncany.
the class Issue429ScenarioTest method performAction.
public static void performAction(TestClient client, int choice) throws Exception {
switch(choice) {
case 0:
logger.log(Level.INFO, "0. Creating file with content");
if (!client.getLocalFile(client.getConfig().getDisplayName()).exists()) {
client.createFileWithContent(client.getConfig().getDisplayName(), "content");
}
break;
case 1:
logger.log(Level.INFO, "1. Deleting my file.");
client.deleteFile(client.getConfig().getDisplayName());
break;
case 2:
logger.log(Level.INFO, "2. Deleting all files");
for (String file : client.getLocalFiles().keySet()) {
client.deleteFile(file);
}
break;
case 3:
logger.log(Level.INFO, "3. Performing Up");
client.upWithForceChecksum();
break;
case 4:
logger.log(Level.INFO, "4. Performing Down");
client.down();
break;
case 5:
logger.log(Level.INFO, "5. Performing Cleanup");
CleanupOperationOptions options = new CleanupOperationOptions();
options.setForce(true);
client.cleanup(options);
break;
case 6:
logger.log(Level.INFO, "6. Syncing.");
client.sync();
break;
case 7:
logger.log(Level.INFO, "7. Creating file with content (2)");
if (!client.getLocalFile(client.getConfig().getDisplayName() + "2").exists()) {
client.createFileWithContent(client.getConfig().getDisplayName() + "2", "content");
}
break;
default:
break;
}
}
use of org.syncany.operations.cleanup.CleanupOperationOptions 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.operations.cleanup.CleanupOperationOptions in project syncany by syncany.
the class Issue247ScenarioTest method testIssue247.
@Test
public void testIssue247() throws Exception {
// Setup
File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientDzHome = new TestClient("Dz", testConnection);
TestClient clientUxWork = new TestClient("Ux", testConnection);
UpOperationOptions upOptionsWithForce = new UpOperationOptions();
upOptionsWithForce.setForceUploadEnabled(true);
// home -- generate some database versions so that the cleanup/merge will have something to merge
clientDzHome.createNewFile("someotherfile0.xml");
clientDzHome.upWithForceChecksum();
for (int i = 0; i < 30; i++) {
clientDzHome.changeFile("someotherfile0.xml");
clientDzHome.upWithForceChecksum();
}
// home
// <<<<< This is the file/checksum causing the issue
clientDzHome.createNewFile("config.xml");
clientDzHome.upWithForceChecksum();
// Make a copy (for later)
TestFileUtil.copyFile(clientDzHome.getLocalFile("config.xml"), new File(tempDir, "config.xml"));
// work
clientUxWork.down();
clientUxWork.changeFile("config.xml");
clientUxWork.upWithForceChecksum();
clientUxWork.createNewFile("someotherfile1.xml");
clientUxWork.upWithForceChecksum();
clientUxWork.createNewFile("someotherfile2.xml");
clientUxWork.upWithForceChecksum();
clientUxWork.createNewFile("someotherfile3.xml");
clientUxWork.upWithForceChecksum();
// home
clientDzHome.down();
clientDzHome.changeFile("config.xml");
clientDzHome.upWithForceChecksum();
clientDzHome.changeFile("config.xml");
clientDzHome.upWithForceChecksum();
// work
clientUxWork.down();
CleanupOperationOptions cleanupOptions = new CleanupOperationOptions();
clientUxWork.cleanup(cleanupOptions);
// home
clientDzHome.down();
// Recreate problematic config.xml/checksum
clientDzHome.deleteFile("config.xml");
TestFileUtil.copyFile(new File(tempDir, "config.xml"), clientDzHome.getLocalFile("config.xml"));
clientDzHome.upWithForceChecksum();
// work
clientUxWork.down();
// Tear down
TestFileUtil.deleteDirectory(tempDir);
clientUxWork.deleteTestData();
clientDzHome.deleteTestData();
}
Aggregations