mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
AVM - build/test fix (follow on from 11225)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11233 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -75,127 +75,129 @@ public class AVMCrawlTestP extends AVMServiceTestBase
|
|||||||
*/
|
*/
|
||||||
private void testCrawl(int n, String fsPath, int m, long runTime)
|
private void testCrawl(int n, String fsPath, int m, long runTime)
|
||||||
{
|
{
|
||||||
Authentication authentication = AuthenticationUtil.setCurrentUser(AuthenticationUtil.SYSTEM_USER_NAME);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (m < 1)
|
Authentication authentication = AuthenticationUtil.setCurrentUser(AuthenticationUtil.SYSTEM_USER_NAME);
|
||||||
|
try
|
||||||
{
|
{
|
||||||
fail("Must have at least one 1 copy of content");
|
if (m < 1)
|
||||||
}
|
|
||||||
|
|
||||||
if (fService.getStore("main") != null)
|
|
||||||
{
|
|
||||||
fService.purgeStore("main");
|
|
||||||
}
|
|
||||||
|
|
||||||
BulkLoader loader = new BulkLoader();
|
|
||||||
loader.setAvmService(fService);
|
|
||||||
for (int i = 0; i < m; i++)
|
|
||||||
{
|
|
||||||
fService.createStore("d" + i);
|
|
||||||
loader.recursiveLoad(fsPath, "d" + i + ":/");
|
|
||||||
fService.createSnapshot("d" + i, null, null);
|
|
||||||
}
|
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
List<AVMCrawler> crawlers = new ArrayList<AVMCrawler>();
|
|
||||||
List<Thread> threads = new ArrayList<Thread>();
|
|
||||||
for (int i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
crawlers.add(new AVMCrawler(fService, authentication));
|
|
||||||
threads.add(new Thread(crawlers.get(i)));
|
|
||||||
threads.get(i).start();
|
|
||||||
}
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
Thread.sleep(5000);
|
fail("Must have at least one 1 copy of content");
|
||||||
// Check that none of the crawlers has errored out.
|
}
|
||||||
for (AVMCrawler crawler : crawlers)
|
|
||||||
|
BulkLoader loader = new BulkLoader();
|
||||||
|
loader.setAvmService(fService);
|
||||||
|
for (int i = 0; i < m; i++)
|
||||||
|
{
|
||||||
|
fService.createStore("d" + i);
|
||||||
|
loader.recursiveLoad(fsPath, "d" + i + ":/");
|
||||||
|
fService.createSnapshot("d" + i, null, null);
|
||||||
|
}
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
List<AVMCrawler> crawlers = new ArrayList<AVMCrawler>();
|
||||||
|
List<Thread> threads = new ArrayList<Thread>();
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
crawlers.add(new AVMCrawler(fService, authentication));
|
||||||
|
threads.add(new Thread(crawlers.get(i)));
|
||||||
|
threads.get(i).start();
|
||||||
|
}
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (crawler.getError())
|
Thread.sleep(5000);
|
||||||
|
// Check that none of the crawlers has errored out.
|
||||||
|
for (AVMCrawler crawler : crawlers)
|
||||||
{
|
{
|
||||||
for (AVMCrawler craw : crawlers)
|
if (crawler.getError())
|
||||||
{
|
{
|
||||||
craw.setDone();
|
for (AVMCrawler craw : crawlers)
|
||||||
}
|
|
||||||
for (Thread thread : threads)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
thread.join();
|
craw.setDone();
|
||||||
}
|
}
|
||||||
catch (InterruptedException ie)
|
for (Thread thread : threads)
|
||||||
{
|
{
|
||||||
// Do nothing.
|
try
|
||||||
|
{
|
||||||
|
thread.join();
|
||||||
|
}
|
||||||
|
catch (InterruptedException ie)
|
||||||
|
{
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//fail();
|
||||||
|
System.err.println("Crawler error");
|
||||||
}
|
}
|
||||||
//fail();
|
|
||||||
System.err.println("Crawler error");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (InterruptedException ie)
|
||||||
|
{
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
if (now - startTime > runTime)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (InterruptedException ie)
|
for (AVMCrawler crawler : crawlers)
|
||||||
{
|
{
|
||||||
// Do nothing.
|
crawler.setDone();
|
||||||
}
|
}
|
||||||
long now = System.currentTimeMillis();
|
for (Thread thread : threads)
|
||||||
if (now - startTime > runTime)
|
|
||||||
{
|
{
|
||||||
break;
|
try
|
||||||
|
{
|
||||||
|
thread.join();
|
||||||
|
}
|
||||||
|
catch (InterruptedException ie)
|
||||||
|
{
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
long ops = 0L;
|
||||||
|
int errorCnt = 0;
|
||||||
|
for (AVMCrawler crawler : crawlers)
|
||||||
|
{
|
||||||
|
ops += crawler.getOpCount();
|
||||||
|
errorCnt += (crawler.getError() ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
long time = System.currentTimeMillis() - startTime;
|
||||||
|
System.out.println("Ops/Sec: " + (ops * 1000L / time));
|
||||||
|
|
||||||
|
if (errorCnt > 0)
|
||||||
|
{
|
||||||
|
StringBuffer errorStack = new StringBuffer();
|
||||||
|
errorStack.append("Crawler errors: ").append(errorCnt).append(" out of ").append(crawlers.size()).append(" are in error state");
|
||||||
|
|
||||||
|
for (AVMCrawler crawler : crawlers)
|
||||||
|
{
|
||||||
|
if (crawler.getError())
|
||||||
|
{
|
||||||
|
errorStack.append("\n\n").append(crawler.getErrorStackTrace());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fail(errorStack.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (AVMCrawler crawler : crawlers)
|
finally
|
||||||
{
|
{
|
||||||
crawler.setDone();
|
for (int i = 0; i < m; i++)
|
||||||
}
|
|
||||||
for (Thread thread : threads)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
thread.join();
|
if (fService.getStore("d" + i) != null)
|
||||||
|
{
|
||||||
|
fService.purgeStore("d" + i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (InterruptedException ie)
|
|
||||||
{
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
long ops = 0L;
|
|
||||||
int errorCnt = 0;
|
|
||||||
for (AVMCrawler crawler : crawlers)
|
|
||||||
{
|
|
||||||
ops += crawler.getOpCount();
|
|
||||||
errorCnt += (crawler.getError() ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
long time = System.currentTimeMillis() - startTime;
|
|
||||||
System.out.println("Ops/Sec: " + (ops * 1000L / time));
|
|
||||||
|
|
||||||
if (errorCnt > 0)
|
|
||||||
{
|
|
||||||
StringBuffer errorStack = new StringBuffer();
|
|
||||||
errorStack.append("Crawler errors: ").append(errorCnt).append(" out of ").append(crawlers.size()).append(" are in error state");
|
|
||||||
|
|
||||||
for (AVMCrawler crawler : crawlers)
|
|
||||||
{
|
|
||||||
if (crawler.getError())
|
|
||||||
{
|
|
||||||
errorStack.append("\n\n").append(crawler.getErrorStackTrace());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fail(errorStack.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m; i++)
|
AuthenticationUtil.clearCurrentSecurityContext();
|
||||||
{
|
|
||||||
if (fService.getStore("d" + i) != null)
|
|
||||||
{
|
|
||||||
fService.purgeStore("d" + i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -86,6 +86,8 @@ public class AVMServiceTestBase extends TestCase
|
|||||||
|
|
||||||
protected static AVMLockingService fLockingService;
|
protected static AVMLockingService fLockingService;
|
||||||
|
|
||||||
|
protected static AuthenticationService fAuthService;
|
||||||
|
|
||||||
public void testSetup()
|
public void testSetup()
|
||||||
{
|
{
|
||||||
// NOOP
|
// NOOP
|
||||||
@@ -109,9 +111,8 @@ public class AVMServiceTestBase extends TestCase
|
|||||||
fTransactionService = (TransactionService)fContext.getBean("transactionComponent");
|
fTransactionService = (TransactionService)fContext.getBean("transactionComponent");
|
||||||
fLockingService = (AVMLockingService)fContext.getBean("AVMLockingService");
|
fLockingService = (AVMLockingService)fContext.getBean("AVMLockingService");
|
||||||
fIndexingInterceptor = (AVMSnapShotTriggeredIndexingMethodInterceptor)fContext.getBean("avmSnapShotTriggeredIndexingMethodInterceptor");
|
fIndexingInterceptor = (AVMSnapShotTriggeredIndexingMethodInterceptor)fContext.getBean("avmSnapShotTriggeredIndexingMethodInterceptor");
|
||||||
|
fAuthService = (AuthenticationService)fContext.getBean("AuthenticationService");
|
||||||
|
|
||||||
AuthenticationService authService = (AuthenticationService)fContext.getBean("AuthenticationService");
|
|
||||||
authService.authenticate("admin", "admin".toCharArray());
|
|
||||||
CreateStoreTxnListener cstl = (CreateStoreTxnListener)fContext.getBean("createStoreTxnListener");
|
CreateStoreTxnListener cstl = (CreateStoreTxnListener)fContext.getBean("createStoreTxnListener");
|
||||||
cstl.addCallback(
|
cstl.addCallback(
|
||||||
new CreateStoreCallback()
|
new CreateStoreCallback()
|
||||||
@@ -153,6 +154,9 @@ public class AVMServiceTestBase extends TestCase
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fAuthService.authenticate("admin", "admin".toCharArray());
|
||||||
|
|
||||||
if (fService.getStore("main") == null)
|
if (fService.getStore("main") == null)
|
||||||
{
|
{
|
||||||
fService.createStore("main");
|
fService.createStore("main");
|
||||||
|
Reference in New Issue
Block a user