mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Add a bit more debugging into the multi threaded tagging test, so if it fails again we'll have a better idea of what is different on bamboo
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@23211 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1176,6 +1176,9 @@ public class TaggingServiceImplTest extends TestCase
|
|||||||
this.taggingService.addTagScope(this.subFolder);
|
this.taggingService.addTagScope(this.subFolder);
|
||||||
tx.commit();
|
tx.commit();
|
||||||
|
|
||||||
|
// Reset the action count
|
||||||
|
asyncOccurs.wantedActionsCount = 0;
|
||||||
|
|
||||||
// Prepare a bunch of threads to do tagging
|
// Prepare a bunch of threads to do tagging
|
||||||
final List<Thread> threads = new ArrayList<Thread>();
|
final List<Thread> threads = new ArrayList<Thread>();
|
||||||
String[] tags = new String[] { TAG_1, TAG_2, TAG_3, TAG_4, TAG_5 };
|
String[] tags = new String[] { TAG_1, TAG_2, TAG_3, TAG_4, TAG_5 };
|
||||||
@@ -1195,7 +1198,7 @@ public class TaggingServiceImplTest extends TestCase
|
|||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
System.out.println(Thread.currentThread() + " - About to start tagging");
|
System.out.println(Thread.currentThread() + " - About to start tagging for " + tag);
|
||||||
|
|
||||||
// Do the updates
|
// Do the updates
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
||||||
@@ -1207,12 +1210,12 @@ public class TaggingServiceImplTest extends TestCase
|
|||||||
taggingService.addTag(folder, tag);
|
taggingService.addTag(folder, tag);
|
||||||
taggingService.addTag(subFolder, tag);
|
taggingService.addTag(subFolder, tag);
|
||||||
taggingService.addTag(subDocument, tag);
|
taggingService.addTag(subDocument, tag);
|
||||||
System.out.println(Thread.currentThread() + " - Tagging");
|
System.out.println(Thread.currentThread() + " - Tagging for " + tag);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}, false, true
|
}, false, true
|
||||||
);
|
);
|
||||||
System.out.println(Thread.currentThread() + " - Done tagging");
|
System.out.println(Thread.currentThread() + " - Done tagging for " + tag);
|
||||||
|
|
||||||
// Wait briefly for thing to catch up, before we
|
// Wait briefly for thing to catch up, before we
|
||||||
// declare ourselves to be done
|
// declare ourselves to be done
|
||||||
@@ -1238,37 +1241,43 @@ public class TaggingServiceImplTest extends TestCase
|
|||||||
{
|
{
|
||||||
t.join();
|
t.join();
|
||||||
}
|
}
|
||||||
|
System.out.println("All threads should have finished");
|
||||||
|
|
||||||
// Have a brief pause, while we wait for their related
|
// Have a brief pause, while we wait for their related
|
||||||
// async actions to kick off
|
// async actions to kick off
|
||||||
Thread.sleep(150);
|
Thread.sleep(150);
|
||||||
|
|
||||||
// At this point, the action tracking service should see
|
// Wait until we've had 5 async tagging actions run (One per Thread)
|
||||||
// anything that will run as running, so we can use that
|
// Not all of the actions will do something, but we just need to
|
||||||
// to wait for everything to finish as needed
|
// wait for all of them!
|
||||||
|
// As a backup check, also ensure that the action tracking service
|
||||||
// Now we wait for the asynchronous tag execution to finish
|
// shows none of them running either
|
||||||
// Wait a maximum of 60 seconds
|
|
||||||
for (int i = 0; i < 600; i++)
|
for (int i = 0; i < 600; i++)
|
||||||
{
|
|
||||||
if (actionTrackingService.getAllExecutingActions().size() > 0)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
if(asyncOccurs.wantedActionsCount < 5)
|
||||||
{
|
{
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (actionTrackingService.getAllExecutingActions().size() > 0)
|
||||||
|
{
|
||||||
|
Thread.sleep(100);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extra sleep just to be sure things are quiet before we continue
|
// Extra sleep just to be sure things are quiet before we continue
|
||||||
|
// (Allows anything that runs after the async actions commit to
|
||||||
|
// finish up for example)
|
||||||
Thread.sleep(175);
|
Thread.sleep(175);
|
||||||
|
System.out.println("Done waiting for tagging, now checking");
|
||||||
|
|
||||||
// Now check that things ended up as planned
|
// Now check that things ended up as planned
|
||||||
tx = this.transactionService.getUserTransaction();
|
tx = this.transactionService.getUserTransaction();
|
||||||
@@ -1303,11 +1312,14 @@ public class TaggingServiceImplTest extends TestCase
|
|||||||
private static final long waitTime = 3500;
|
private static final long waitTime = 3500;
|
||||||
private static final String ACTION_TYPE = UpdateTagScopesActionExecuter.NAME;
|
private static final String ACTION_TYPE = UpdateTagScopesActionExecuter.NAME;
|
||||||
|
|
||||||
|
private int wantedActionsCount = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAsyncActionExecute(Action action, NodeRef actionedUponNodeRef)
|
public void onAsyncActionExecute(Action action, NodeRef actionedUponNodeRef)
|
||||||
{
|
{
|
||||||
if(action.getActionDefinitionName().equals(ACTION_TYPE))
|
if(action.getActionDefinitionName().equals(ACTION_TYPE))
|
||||||
{
|
{
|
||||||
|
wantedActionsCount++;
|
||||||
synchronized (waitForExecutionLock) {
|
synchronized (waitForExecutionLock) {
|
||||||
try {
|
try {
|
||||||
waitForExecutionLock.notify();
|
waitForExecutionLock.notify();
|
||||||
|
Reference in New Issue
Block a user