Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
Adjusting tests for full cleanup (all databaseversions are removed)
Browse files Browse the repository at this point in the history
  • Loading branch information
pimotte committed Aug 8, 2014
1 parent 121fa8b commit 2456885
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Expand Up @@ -361,7 +361,7 @@ private void mergeRemoteFiles() throws IOException, StorageException {
}

for (DatabaseRemoteFile clientDatabaseFile : clientDatabaseFiles) {
if (toDeleteDatabaseFiles.size() < numOfDatabaseFilesToDelete) {
if (toDeleteDatabaseFiles.size() <= numOfDatabaseFilesToDelete) {
toDeleteDatabaseFiles.add(clientDatabaseFile);
}
}
Expand Down
Expand Up @@ -93,8 +93,8 @@ public void testCleanupMergeDatabaseFilesScenario1() throws Exception {
assertFalse(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000001").exists());
assertFalse(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000005").exists());
assertFalse(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000010").exists());
assertFalse(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000014").exists());
assertTrue(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000015").exists());
assertFalse(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000015").exists());
assertTrue(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000016").exists());

// Run
clientC.down(); // <<< Here is/was the issue: Client C failed when downloading
Expand Down Expand Up @@ -290,7 +290,7 @@ public void testIssue58_2() throws Exception {
clientA.changeFile("A-file.jpg");
clientA.up(upOperationOptionsWithCleanupForce); // (A15,B13) + (A16,B13) [PURGE]
clientA.cleanup();
assertTrue(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000015").exists());
assertFalse(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000015").exists());
assertTrue(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000016").exists());
assertFalse(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000017").exists());
assertEquals("0", TestSqlUtil.runSqlSelect("select count(*) from chunk where checksum='"+fileAndChunkChecksumThatRaisesException+"'",
Expand Down
Expand Up @@ -53,54 +53,54 @@ public void testManySyncUpsAndDatabaseFileCleanup() throws Exception {

clientA.cleanup(); // Force cleanup

for (int i=1; i<=10; i++) {
for (int i=1; i<=15; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getRepositoryPath()+"/databases/"+expectedDatabaseRemoteFile.getName());

assertTrue("Database file should NOT exist: "+expectedDatabaseFile, !expectedDatabaseFile.exists());
}

for (int i=11; i<=16; i++) {
for (int i=16; i<=16; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getRepositoryPath()+"/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<=25; i++) {
for (int i=17; i<=30; i++) {
clientA.createNewFile("file"+i, 1);
clientA.up();
}

for (int i=1; i<=10; i++) {
for (int i=1; i<=15; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getRepositoryPath()+"/databases/"+expectedDatabaseRemoteFile.getName());

assertTrue("Database file should NOT exist: "+expectedDatabaseFile, !expectedDatabaseFile.exists());
}

for (int i=11; i<=25; i++) {
for (int i=16; i<=30; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getRepositoryPath()+"/databases/"+expectedDatabaseRemoteFile.getName());

assertTrue("Database file SHOULD exist: "+expectedDatabaseFile, expectedDatabaseFile.exists());
}

// ROUND 4: 1x sync up (cleanup expected!)
clientA.createNewFile("file26", 1);
clientA.createNewFile("file31", 1);
clientA.up();

clientA.cleanup(); // Force cleanup

for (int i=1; i<=20; i++) {
for (int i=1; i<=30; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getRepositoryPath()+"/databases/"+expectedDatabaseRemoteFile.getName());

assertTrue("Database file should NOT exist: "+expectedDatabaseFile, !expectedDatabaseFile.exists());
}

for (int i=21; i<=25; i++) {
for (int i=31; i<=31; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getRepositoryPath()+"/databases/"+expectedDatabaseRemoteFile.getName());

Expand Down

0 comments on commit 2456885

Please sign in to comment.