ALF-4476 - Make transfer definitions for replication execution read only (locked)

Also improve the testing of cancelling running replication jobs, and the debug output of the action tracking service


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22055 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2010-08-27 16:52:52 +00:00
parent 3c2d037b01
commit 0c0d440329
4 changed files with 62 additions and 20 deletions

View File

@@ -181,7 +181,11 @@ public class ReplicationServiceIntegrationTest extends TestCase
if(folder2 != null) {
nodeService.deleteNode(folder2);
}
// Zap the destination folder, which may well contain
// entries transfered over which are locked
if(destinationFolder != null) {
lockService.unlock(destinationFolder, true);
nodeService.deleteNode(destinationFolder);
}
@@ -598,6 +602,10 @@ public class ReplicationServiceIntegrationTest extends TestCase
* Check that cancelling works.
* Does this by taking a lock on the job, cancelling,
* releasing and seeing it abort.
*
* Tests that when we ask for a replication task to be cancelled,
* that it starts, cancels, and the status is correctly recorded
* for it.
*/
public void testReplicationExectionCancelling() throws Exception
{
@@ -623,16 +631,32 @@ public class ReplicationServiceIntegrationTest extends TestCase
txn.begin();
actionService.executeAction(rd, replicationRoot, false, true);
assertEquals(ActionStatus.Pending, rd.getExecutionStatus());
assertEquals(false, actionTrackingService.isCancellationRequested(rd));
actionTrackingService.requestActionCancellation(rd);
assertEquals(true, actionTrackingService.isCancellationRequested(rd));
txn.commit();
// Let it get going, will be waiting for the lock
// having registered with the action tracking service
Thread.sleep(500);
for(int i=0; i<100; i++) {
// Keep asking for it to be cancelled ASAP
actionTrackingService.requestActionCancellation(rd);
if(rd.getExecutionStatus().equals(ActionStatus.Running)) {
// Good, has started up
// Stop waiting and do the cancel
break;
} else {
// Still pending, wait a bit more
Thread.sleep(10);
}
}
// Ensure it started, and should shortly stop
assertEquals(ActionStatus.Running, rd.getExecutionStatus());
// Now request the cancel
actionTrackingService.requestActionCancellation(rd);
assertEquals(true, actionTrackingService.isCancellationRequested(rd));
// Release our lock, should allow the replication task
// to get going and spot the cancel
@@ -856,7 +880,7 @@ public class ReplicationServiceIntegrationTest extends TestCase
TransferDefinition td = replicationActionExecutor.buildTransferDefinition(rd, nodes);
assertEquals(true, td.isSync());
// assertEquals(true, td.isReadOnly());// TODO Make read only, and fix tests
assertEquals(true, td.isReadOnly());
assertEquals(2, td.getNodes().size());
assertEquals(true, td.getNodes().contains(folder1));
assertEquals(true, td.getNodes().contains(content1_1));
@@ -1012,11 +1036,6 @@ public class ReplicationServiceIntegrationTest extends TestCase
// TODO
}
public void testCancellation() throws Exception
{
// TODO
}
private NodeRef makeNode(NodeRef parent, QName nodeType)
{