}
@Test
public void testCleanupAfterFailedUpOperation() throws Exception {
// Setup
UnreliableLocalTransferSettings testConnection = TestConfigUtil.createTestUnreliableLocalConnection(Arrays.asList(new String[] {
// List of failing operations (regex)
// Format: abs=<count> rel=<count> op=<connect|init|upload|...> <operation description>
"rel=[456].+upload.+multichunk" // << 3 retries!
}));
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
StatusOperationOptions forceChecksumStatusOperationOptions = new StatusOperationOptions();
forceChecksumStatusOperationOptions.setForceChecksum(true);
UpOperationOptions noCleanupAndForceUpOperationOptions = new UpOperationOptions();
noCleanupAndForceUpOperationOptions.setForceUploadEnabled(true);
noCleanupAndForceUpOperationOptions.setStatusOptions(forceChecksumStatusOperationOptions);
// Run
// 1. Call A.up(); this fails AFTER the first multichunk
clientA.createNewFile("A-file1", 5 * 1024 * 1024);
boolean operationFailed = false;
try {
clientA.up();
}
catch (Exception e) {
operationFailed = true; // That is supposed to happen!
}
File repoMultiChunkDir = new File(testConnection.getPath() + "/multichunks");
File repoActionsDir = new File(testConnection.getPath() + "/actions");
assertTrue(operationFailed);
// Atomic operation, so multichunk is not yet present at location
assertEquals(0, repoMultiChunkDir.listFiles().length);
assertEquals(1, repoActionsDir.listFiles().length);