use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class Issue227_2_ScenarioTest method testIssue227_MOM.
@Test
public void testIssue227_MOM() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientIH = new TestClient("iH", testConnection);
TestClient clientMOM = new TestClient("MOM", testConnection);
TestClient clientHSE = new TestClient("hSE", testConnection);
UpOperationOptions upOptionsWithForce = new UpOperationOptions();
upOptionsWithForce.setForceUploadEnabled(true);
clientIH.createNewFile("file1.jpg");
clientIH.up();
clientIH.createNewFile("file2.jpg");
clientIH.up();
clientMOM.down();
clientHSE.down();
// -
clientMOM.createNewFile("file3.jpg");
clientMOM.up();
clientMOM.createNewFile("file4.jpg");
clientMOM.up();
clientIH.down();
clientHSE.down();
// All in sync
/*
* We want to create a time difference situation here between different clients.
*
* In reality:
* - Client "hSE" uploads a new database AFTER client "MOM"
*
* In this test:
* 1. Client "hSE" uploads a new database BEFORE client "MOM"
* 2. We hide "hSE"'s database by moving it to a temp. file
* // ...
* 5. When we do 'down' at client "IH", the databases of client "MOM" are considered DIRTY
*
*/
// 1. Upload new database for hSE
clientHSE.createNewFile("fileHSE-1.jpg");
clientHSE.up(upOptionsWithForce);
File[] hSEDatabaseFiles = new File(testConnection.getPath() + "/databases/").listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.contains("hSE");
}
});
assertEquals(1, hSEDatabaseFiles.length);
// 2. Hide database from other clients
File hSEDatabaseFile = hSEDatabaseFiles[0];
File hSEDatabaseFileHidden = new File(hSEDatabaseFile.getParentFile(), "HIDE_THIS_FILE_" + hSEDatabaseFile.getName());
hSEDatabaseFile.renameTo(hSEDatabaseFileHidden);
// 3. This shouldn't do anything; no new databases!
DownOperationResult downOperationResult = clientIH.down();
assertEquals(0, downOperationResult.getDownloadedUnknownDatabases().size());
// 4. Upload database from client "MOM" (later considered DIRTY)
clientMOM.createNewFile("fileMOM-1.jpg");
clientMOM.up(upOptionsWithForce);
clientMOM.createNewFile("fileMOM-2.jpg");
clientMOM.up(upOptionsWithForce);
// 5. Download changes from "MOM" (apply databases and files that will later be DIRTY)
downOperationResult = clientIH.down();
assertEquals(0, downOperationResult.getDirtyDatabasesCreated().size());
// 6. Rename hidden database (= the later winner!)Now download the changes that
// Databases of client "MOM" will be considered "DIRTY"
hSEDatabaseFileHidden.renameTo(hSEDatabaseFile);
downOperationResult = clientIH.down();
assertEquals(2, downOperationResult.getDirtyDatabasesCreated().size());
// 7. This should remove DIRTY database versions from the database
// and ADD the multichunks from the previous database versions to the new database version (<< this is what kills MOM)
clientIH.up();
// <<<<<<<< This should produce Pim's stack trace from issue #227
clientMOM.down();
// Tear down
clientIH.deleteTestData();
clientMOM.deleteTestData();
clientHSE.deleteTestData();
}
use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class Issue227_2_ScenarioTest method testIssue227_IH.
@Test
public void testIssue227_IH() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientIH = new TestClient("iH", testConnection);
TestClient clientMOM = new TestClient("MOM", testConnection);
TestClient clientHSE = new TestClient("hSE", testConnection);
TestClient clientMee = new TestClient("Mee", testConnection);
UpOperationOptions upOptionsWithForce = new UpOperationOptions();
upOptionsWithForce.setForceUploadEnabled(true);
clientIH.createNewFile("file1.jpg");
clientIH.up();
clientIH.createNewFile("file2.jpg");
clientIH.up();
clientMOM.down();
clientHSE.down();
// -
clientMOM.createNewFile("file3.jpg");
clientMOM.up();
clientMOM.createNewFile("file4.jpg");
clientMOM.up();
clientIH.down();
clientHSE.down();
// All in sync
/*
* We want to create a time difference situation here between different clients.
*
* In reality:
* - Client "hSE" uploads a new database AFTER client "MOM"
*
* In this test:
* 1. Client "hSE" uploads a new database BEFORE client "MOM"
* 2. We hide "hSE"'s database by moving it to a temp. file
* // ...
* 5. When we do 'down' at client "IH", the databases of client "MOM" are considered DIRTY
*
*/
// 1. Upload new database for hSE
clientHSE.createNewFile("fileHSE-1.jpg");
clientHSE.up(upOptionsWithForce);
File[] hSEDatabaseFiles = new File(testConnection.getPath() + "/databases/").listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.contains("hSE");
}
});
assertEquals(1, hSEDatabaseFiles.length);
// 2. Hide database from other clients
File hSEDatabaseFile = hSEDatabaseFiles[0];
File hSEDatabaseFileHidden = new File(hSEDatabaseFile.getParentFile(), "HIDE_THIS_FILE_" + hSEDatabaseFile.getName());
hSEDatabaseFile.renameTo(hSEDatabaseFileHidden);
// 3. This shouldn't do anything; no new databases!
DownOperationResult downOperationResult = clientIH.down();
assertEquals(0, downOperationResult.getDownloadedUnknownDatabases().size());
// 4. Upload database from client "MOM" (later considered DIRTY)
clientMOM.createNewFile("fileMOM-1.jpg");
clientMOM.changeFile("file1.jpg");
clientMOM.up(upOptionsWithForce);
clientMOM.createNewFile("fileMOM-2.jpg");
clientMOM.up(upOptionsWithForce);
// 5. Download changes from "MOM" (apply databases and files that will later be DIRTY)
downOperationResult = clientIH.down();
assertEquals(0, downOperationResult.getDirtyDatabasesCreated().size());
// 6. Rename hidden database (= the later winner!)Now download the changes that
// Databases of client "MOM" will be considered "DIRTY"
hSEDatabaseFileHidden.renameTo(hSEDatabaseFile);
downOperationResult = clientIH.down();
assertEquals(2, downOperationResult.getDirtyDatabasesCreated().size());
// 7. This should remove DIRTY database versions from the database
// and ADD the multichunks from the previous database versions to the new database version (<< this is what kills MOM)
clientIH.up();
clientIH.down();
// <<< This copies a file for which the filecontent has been deleted
clientIH.copyFile("file2.jpg", "file2copy.jpg");
clientIH.up();
// << This should throw Philipp's stack trace in #227
clientMee.down();
// Tear down
clientIH.deleteTestData();
clientMOM.deleteTestData();
clientHSE.deleteTestData();
clientMee.deleteTestData();
}
use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class Issue227_2_ScenarioTest method testIssue227_multiple_resolve.
@Test
public void testIssue227_multiple_resolve() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientIH = new TestClient("iH", testConnection);
TestClient clientMOM = new TestClient("MOM", testConnection);
TestClient clientHSE = new TestClient("hSE", testConnection);
TestClient clientMee = new TestClient("Mee", testConnection);
TestClient clientIHtwo = new TestClient("IHtwo", testConnection);
UpOperationOptions upOptionsWithForce = new UpOperationOptions();
upOptionsWithForce.setForceUploadEnabled(true);
clientIH.createNewFile("file1.jpg");
clientIH.up();
clientIH.createNewFile("file2.jpg");
clientIH.up();
clientMOM.down();
clientHSE.down();
// -
clientMOM.createNewFile("file3.jpg");
clientMOM.up();
clientMOM.createNewFile("file4.jpg");
clientMOM.up();
clientIH.down();
clientIHtwo.down();
clientHSE.down();
// All in sync
/*
* We want to create a time difference situation here between different clients.
*
* In reality:
* - Client "hSE" uploads a new database AFTER client "MOM"
*
* In this test:
* 1. Client "hSE" uploads a new database BEFORE client "MOM"
* 2. We hide "hSE"'s database by moving it to a temp. file
* // ...
* 5. When we do 'down' at client "IH", the databases of client "MOM" are considered DIRTY
*
*/
// 1. Upload new database for hSE
clientHSE.createNewFile("fileHSE-1.jpg");
clientHSE.up(upOptionsWithForce);
File[] hSEDatabaseFiles = new File(testConnection.getPath() + "/databases/").listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.contains("hSE");
}
});
assertEquals(1, hSEDatabaseFiles.length);
// 2. Hide database from other clients
File hSEDatabaseFile = hSEDatabaseFiles[0];
File hSEDatabaseFileHidden = new File(hSEDatabaseFile.getParentFile(), "HIDE_THIS_FILE_" + hSEDatabaseFile.getName());
hSEDatabaseFile.renameTo(hSEDatabaseFileHidden);
// 3. This shouldn't do anything; no new databases!
DownOperationResult downOperationResult = clientIH.down();
assertEquals(0, downOperationResult.getDownloadedUnknownDatabases().size());
// same as IH!
clientIHtwo.down();
// 4. Upload database from client "MOM" (later considered DIRTY)
clientMOM.createNewFile("fileMOM-1.jpg");
clientMOM.changeFile("file1.jpg");
clientMOM.up(upOptionsWithForce);
clientMOM.createNewFile("fileMOM-2.jpg");
clientMOM.up(upOptionsWithForce);
// 5. Download changes from "MOM" (apply databases and files that will later be DIRTY)
downOperationResult = clientIH.down();
assertEquals(0, downOperationResult.getDirtyDatabasesCreated().size());
// same as IH!
clientIHtwo.down();
// 6. Rename hidden database (= the later winner!)Now download the changes that
// Databases of client "MOM" will be considered "DIRTY"
hSEDatabaseFileHidden.renameTo(hSEDatabaseFile);
downOperationResult = clientIH.down();
assertEquals(2, downOperationResult.getDirtyDatabasesCreated().size());
// same as IH!
clientIHtwo.down();
// 7. This should remove DIRTY database versions from the database
// and ADD the multichunks from the previous database versions to the new database version (<< this is what kills MOM)
clientIH.up(upOptionsWithForce);
clientIHtwo.up(upOptionsWithForce);
/*clientIH.down();
clientIH.copyFile("file2.jpg", "file2copy.jpg"); // <<< This copies a file for which the filecontent has been deleted
clientIH.up();*/
// << This should throw Philipp's stack trace in #227
clientMee.down();
// Tear down
clientIH.deleteTestData();
clientMOM.deleteTestData();
clientHSE.deleteTestData();
clientMee.deleteTestData();
clientIHtwo.deleteTestData();
}
use of org.syncany.tests.util.TestClient 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.tests.util.TestClient in project syncany by syncany.
the class Issue429ScenarioTest method testIssue492UploadDuplicateFile.
@Ignore
public void testIssue492UploadDuplicateFile() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
TestClient clientC = new TestClient("C", testConnection);
clientA.createNewFile("file1.txt", 1024);
clientA.upWithForceChecksum();
FileUtils.copyFile(clientA.getLocalFile("file1.txt"), clientB.getLocalFile("file2.txt"));
clientB.down();
clientB.up();
clientA.deleteFile("file1.txt");
clientA.deleteFile("file2.txt");
clientA.upWithForceChecksum();
clientB.cleanup();
clientC.down();
// Tear down
// clientB.deleteTestData();
// clientA.deleteTestData();
}
Aggregations