mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged V2.2 to HEAD
10953: Merged V2.1 to V2.2 10904: AVM - add test suite wrapper, update existing tests to purge test stores (rather than all stores) 10909: AVM - unit test updates only (exposed further tests via test suite) 10947: AVM - unit test update only (extra checks) 10969: Merged V2.1 to V2.2 (cont) 10904: AVM - add test suite wrapper, update existing tests to purge test stores (rather than all stores) 11054: Fixed blind failures in AVM unit tests 11064: AVM - unit test error handling 11068: Temporarily remove AvmTestSuite from the build 11074: AVM - unit tests - added error stack on concurrency tests (to show failure in build output), removed 1 hour freeze, put back AVM test suite 11218: Merged V2.1 to V2.2 11217: AVM - unit test fix ("n must be positive") git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11224 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -36,23 +36,60 @@ import org.alfresco.repo.avm.util.BulkLoader;
|
||||
*/
|
||||
public class AVMCrawlTestP extends AVMServiceTestBase
|
||||
{
|
||||
/**
|
||||
* Do the crawl test.
|
||||
*/
|
||||
public void testCrawl()
|
||||
public void testCrawlA()
|
||||
{
|
||||
testCrawl(1,
|
||||
"source/java/org/alfresco/repo/avm/actions", // relative from .../repository
|
||||
1,
|
||||
30000); // 30 secs
|
||||
}
|
||||
|
||||
public void testCrawlB()
|
||||
{
|
||||
testCrawl(2,
|
||||
"source/java/org/alfresco/repo/avm", // relative from .../repository
|
||||
2,
|
||||
30000); // 30 secs
|
||||
}
|
||||
|
||||
/*
|
||||
public void xtestCrawlZ()
|
||||
{
|
||||
testCrawl(8,
|
||||
"source", // relative from .../repository
|
||||
2,
|
||||
28800000); // 8 hours
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Do the crawl test
|
||||
*
|
||||
* @param n Number of threads
|
||||
* @param fsPath The path in the filesystem to load (tree of stuff) from
|
||||
* @param m How many multiples of content to start with
|
||||
* @param runTime Min run time (in msecs)
|
||||
*/
|
||||
private void testCrawl(int n, String fsPath, int m, long runTime)
|
||||
{
|
||||
int n = 8; // Number of Threads.
|
||||
int m = 2; // How many multiples of content to start with.
|
||||
try
|
||||
{
|
||||
long runTime = 28800000; // 8 Hours. .
|
||||
if (m < 1)
|
||||
{
|
||||
fail("Must have at least one 1 copy of content");
|
||||
}
|
||||
|
||||
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("source", "d" + i + ":/");
|
||||
loader.recursiveLoad(fsPath, "d" + i + ":/");
|
||||
fService.createSnapshot("d" + i, null, null);
|
||||
}
|
||||
long startTime = System.currentTimeMillis();
|
||||
@@ -89,7 +126,8 @@ public class AVMCrawlTestP extends AVMServiceTestBase
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
fail();
|
||||
//fail();
|
||||
System.err.println("Crawler error");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,18 +157,40 @@ public class AVMCrawlTestP extends AVMServiceTestBase
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
for (int i = 0; i < m; i++)
|
||||
{
|
||||
if (fService.getStore("d" + i) != null) { fService.purgeStore("d" + i); }
|
||||
if (fService.getStore("d" + i) != null)
|
||||
{
|
||||
fService.purgeStore("d" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -27,6 +27,8 @@ import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -64,6 +66,7 @@ class AVMCrawler implements Runnable
|
||||
* Whether an error has occurred.
|
||||
*/
|
||||
private boolean fError;
|
||||
private String fErrorStackTrace = null;
|
||||
|
||||
/**
|
||||
* Random number generator.
|
||||
@@ -99,6 +102,14 @@ class AVMCrawler implements Runnable
|
||||
return fError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get error stack trace
|
||||
*/
|
||||
public String getErrorStackTrace()
|
||||
{
|
||||
return fErrorStackTrace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of run.
|
||||
*/
|
||||
@@ -111,9 +122,16 @@ class AVMCrawler implements Runnable
|
||||
doCrawl();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
t.printStackTrace(pw);
|
||||
|
||||
fError = true;
|
||||
fErrorStackTrace = sw.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +144,13 @@ class AVMCrawler implements Runnable
|
||||
{
|
||||
List<AVMStoreDescriptor> reps = fService.getStores();
|
||||
fOpCount++;
|
||||
|
||||
if (reps.size() == 0)
|
||||
{
|
||||
System.out.println("No AVM stores");
|
||||
return;
|
||||
}
|
||||
|
||||
AVMStoreDescriptor repDesc = reps.get(fRandom.nextInt(reps.size()));
|
||||
Map<String, AVMNodeDescriptor> rootListing = fService.getDirectoryListing(-1, repDesc.getName() + ":/");
|
||||
fOpCount++;
|
||||
@@ -138,6 +163,13 @@ class AVMCrawler implements Runnable
|
||||
dirs.add(desc);
|
||||
}
|
||||
}
|
||||
|
||||
if (dirs.size() == 0)
|
||||
{
|
||||
System.out.println("No dirs in root: "+repDesc.getName() + ":/");
|
||||
}
|
||||
else
|
||||
{
|
||||
AVMNodeDescriptor dir = dirs.get(fRandom.nextInt(dirs.size()));
|
||||
int depth = 1;
|
||||
while (dir != null)
|
||||
@@ -233,6 +265,8 @@ class AVMCrawler implements Runnable
|
||||
}
|
||||
depth++;
|
||||
}
|
||||
}
|
||||
|
||||
if (fRandom.nextInt(16) == 0)
|
||||
{
|
||||
System.out.println("Snapshotting: " + repDesc.getName());
|
||||
|
@@ -34,14 +34,40 @@ import org.alfresco.repo.avm.util.BulkReader;
|
||||
*/
|
||||
public class AVMScaleTestP extends AVMServiceTestBase
|
||||
{
|
||||
public void testScaling()
|
||||
public void testScaleA()
|
||||
{
|
||||
int n = 250; // The number of BulkLoads to do.
|
||||
testScaling(1,
|
||||
"source/java/org/alfresco/repo/avm/actions", // relative from .../repository
|
||||
1);
|
||||
}
|
||||
|
||||
public void testScaleB()
|
||||
{
|
||||
testScaling(2,
|
||||
"source/java/org/alfresco/repo/avm", // relative from .../repository
|
||||
2);
|
||||
}
|
||||
|
||||
/*
|
||||
public void xtestScaleZ()
|
||||
{
|
||||
testScaling(250,
|
||||
"/Users/britt/hibernate-3.1",
|
||||
10);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Do the scale test
|
||||
*
|
||||
* @param n Number of bulkloads to do
|
||||
* @param fsPath The path in the filesystem to load (tree of stuff) from
|
||||
* @param futzCount The number of post snapshot modifications to make after each load
|
||||
*/
|
||||
private void testScaling(int n, String fsPath, int futzCount)
|
||||
{
|
||||
try
|
||||
{
|
||||
int futzCount = 10; // The number of post snapshot modifications to make after each load.
|
||||
String load = "config/alfresco"; // The tree of stuff to load.
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
loader.setPropertyCount(50);
|
||||
@@ -52,7 +78,7 @@ public class AVMScaleTestP extends AVMServiceTestBase
|
||||
{
|
||||
System.out.println("Round " + (i + 1));
|
||||
fService.createStore("store" + i);
|
||||
loader.recursiveLoad(load, "store" + i + ":/");
|
||||
loader.recursiveLoad(fsPath, "store" + i + ":/");
|
||||
fService.createSnapshot("store" + i, null, null);
|
||||
long now = System.currentTimeMillis();
|
||||
System.out.println("Load Time: " + (now - lastTime) + "ms");
|
||||
@@ -68,7 +94,10 @@ public class AVMScaleTestP extends AVMServiceTestBase
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (fService.getStore("store" + i) != null) { fService.purgeStore("store" + i); }
|
||||
if (fService.getStore("store" + i) != null)
|
||||
{
|
||||
fService.purgeStore("store" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -45,11 +45,12 @@ import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.remote.AVMRemote;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.NameMatcher;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* Local unit tests of AVM (AVMSyncService & AVMService)
|
||||
@@ -71,7 +72,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
/**
|
||||
* The application context.
|
||||
*/
|
||||
protected static FileSystemXmlApplicationContext fContext;
|
||||
protected static ApplicationContext fContext;
|
||||
|
||||
protected static NameMatcher excluder;
|
||||
|
||||
@@ -81,7 +82,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
if (fContext == null)
|
||||
{
|
||||
// local (embedded) test setup
|
||||
fContext = new FileSystemXmlApplicationContext("config/alfresco/application-context.xml");
|
||||
fContext = ApplicationContextHelper.getApplicationContext();
|
||||
fService = (AVMRemote)fContext.getBean("avmRemote");
|
||||
fSyncService = (AVMSyncService)fContext.getBean("AVMSyncService");
|
||||
excluder = (NameMatcher) fContext.getBean("globalPathExcluder");
|
||||
@@ -122,7 +123,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -133,7 +134,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
/**
|
||||
* Do a simple hello world test.
|
||||
*/
|
||||
public void testSimple()
|
||||
public void testSimple() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -147,7 +148,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +169,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
/**
|
||||
* Test reading and writing.
|
||||
*/
|
||||
public void testReadWrite()
|
||||
public void testReadWrite() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -195,7 +196,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -206,7 +207,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
/**
|
||||
* Another test of reading.
|
||||
*/
|
||||
public void testRead()
|
||||
public void testRead() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -231,7 +232,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -242,7 +243,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
/**
|
||||
* Test a call that should return null;
|
||||
*/
|
||||
public void testErrorState()
|
||||
public void testErrorState() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -251,7 +252,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +260,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
/**
|
||||
* Test update to branch
|
||||
*/
|
||||
public void testSimpleUpdateBR()
|
||||
public void testSimpleUpdateBR() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -287,7 +288,7 @@ public class AVMServiceLocalTest extends TestCase
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@@ -34,7 +34,7 @@ public class AVMServicePerfTest extends AVMServiceTestBase
|
||||
/**
|
||||
* Test adding 100 files to each directory.
|
||||
*/
|
||||
public void testAdd100a()
|
||||
public void testAdd100a() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -59,14 +59,14 @@ public class AVMServicePerfTest extends AVMServiceTestBase
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test adding 100 files to each directory.
|
||||
*/
|
||||
public void testAdd100b()
|
||||
public void testAdd100b() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -91,14 +91,14 @@ public class AVMServicePerfTest extends AVMServiceTestBase
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test adding 100 files to each directory.
|
||||
*/
|
||||
public void testAdd100c()
|
||||
public void testAdd100c() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -123,14 +123,14 @@ public class AVMServicePerfTest extends AVMServiceTestBase
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test adding 100 files to each directory.
|
||||
*/
|
||||
public void testAdd100d()
|
||||
public void testAdd100d() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -155,7 +155,7 @@ public class AVMServicePerfTest extends AVMServiceTestBase
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -164,7 +164,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
|
||||
}
|
||||
|
||||
public void testPathEncoding()
|
||||
public void testPathEncoding() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -202,7 +202,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -47,7 +47,6 @@ import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* Base class for AVMService tests.
|
||||
@@ -87,6 +86,11 @@ public class AVMServiceTestBase extends TestCase
|
||||
|
||||
protected static AVMLockingService fLockingService;
|
||||
|
||||
public void testSetup()
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup for AVM tests. Note that we set the polling
|
||||
* interval for the reaper to 4 seconds so that tests will
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -34,22 +34,85 @@ import org.alfresco.repo.avm.util.BulkLoader;
|
||||
*/
|
||||
public class AVMStressTestP extends AVMServiceTestBase
|
||||
{
|
||||
public void testStressA() throws Throwable
|
||||
{
|
||||
testNThreads( 1, // nThreads
|
||||
"source/java/org/alfresco/repo/avm/actions", // relative dir to load from (.../repository)
|
||||
1, // nCopies
|
||||
1, // create file
|
||||
1, // create dir
|
||||
0, // rename
|
||||
0, // create layered dir
|
||||
0, // create layered file
|
||||
0, // remove node
|
||||
0, // modify file
|
||||
50, // read file
|
||||
0, // snapshot
|
||||
100); // # ops (for each thread)
|
||||
}
|
||||
|
||||
public void testStressB() throws Throwable
|
||||
{
|
||||
testNThreads( 2, // nThreads
|
||||
"source/java/org/alfresco/repo/avm", // relative dir to load from (.../repository)
|
||||
1, // nCopies
|
||||
10, // create file
|
||||
2, // create dir
|
||||
2, // rename
|
||||
0, // create layered dir // TODO pending ETWOTWO-715 (is 2 in 2.1.x)
|
||||
0, // create layered file // TODO pending ETWOTWO-715 (is 2 in 2.1.x)
|
||||
5, // remove node
|
||||
10, // modify file
|
||||
50, // read file
|
||||
5, // snapshot
|
||||
200); // # ops (for each thread)
|
||||
}
|
||||
|
||||
/*
|
||||
public void xtestStressZ()
|
||||
{
|
||||
testNThreads( 4, // nThreads
|
||||
"source", // relative dir to load from (.../repository)
|
||||
8, // nCopies
|
||||
400, // create file
|
||||
20, // create dir
|
||||
5, // rename
|
||||
5, // create layered dir
|
||||
5, // create layered file
|
||||
10, // remove node
|
||||
20, // modify file
|
||||
3200, // read file
|
||||
10, // snapshot
|
||||
40000); // # ops
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test N threads
|
||||
*/
|
||||
public void testNThreads()
|
||||
private void testNThreads(int nThreads,
|
||||
String fsPath,
|
||||
int nCopies,
|
||||
int createFile,
|
||||
int createDir,
|
||||
int rename,
|
||||
int createLayeredDir,
|
||||
int createLayeredFile,
|
||||
int removeNode,
|
||||
int modifyFile,
|
||||
int readFile,
|
||||
int snapshot,
|
||||
int opCount) throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
int nCopies = 8;
|
||||
int nThreads = 4;
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < nCopies; i++)
|
||||
{
|
||||
fService.createDirectory("main:/", "" + i);
|
||||
loader.recursiveLoad("source", "main:/" + i);
|
||||
loader.recursiveLoad(fsPath, "main:/" + i);
|
||||
fService.createSnapshot("main", null, null);
|
||||
}
|
||||
System.out.println("Load time: " + (System.currentTimeMillis() - start));
|
||||
@@ -58,16 +121,16 @@ public class AVMStressTestP extends AVMServiceTestBase
|
||||
for (int i = 0; i < nThreads; i++)
|
||||
{
|
||||
AVMTester tester
|
||||
= new AVMTester(400, // create file.
|
||||
20, // create dir,
|
||||
5, // rename
|
||||
5, // create layered dir
|
||||
5, // create layered file
|
||||
10, // remove node
|
||||
20, // modify file.
|
||||
3200, // read file
|
||||
10, // snapshot
|
||||
40000, // # ops
|
||||
= new AVMTester(createFile,
|
||||
createDir,
|
||||
rename,
|
||||
createLayeredDir,
|
||||
createLayeredFile,
|
||||
removeNode,
|
||||
modifyFile,
|
||||
readFile,
|
||||
snapshot,
|
||||
opCount,
|
||||
fService);
|
||||
tester.refresh();
|
||||
Thread thread = new Thread(tester);
|
||||
@@ -101,7 +164,8 @@ public class AVMStressTestP extends AVMServiceTestBase
|
||||
{
|
||||
tester.setExit();
|
||||
}
|
||||
fail();
|
||||
//fail();
|
||||
System.err.println("Stress tester error");
|
||||
}
|
||||
exited++;
|
||||
}
|
||||
@@ -112,11 +176,33 @@ public class AVMStressTestP extends AVMServiceTestBase
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
int errorCnt = 0;
|
||||
for (AVMTester tester : testers)
|
||||
{
|
||||
errorCnt += (tester.getError() ? 1 : 0);
|
||||
}
|
||||
|
||||
if (errorCnt > 0)
|
||||
{
|
||||
StringBuffer errorStack = new StringBuffer();
|
||||
errorStack.append("Stress tester errors: ").append(errorCnt).append(" out of ").append(testers.size()).append(" are in error state");
|
||||
|
||||
for (AVMTester tester : testers)
|
||||
{
|
||||
if (tester.getError())
|
||||
{
|
||||
errorStack.append("\n\n").append(tester.getErrorStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
fail(errorStack.toString());
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
64
source/java/org/alfresco/repo/avm/AVMTestSuite.java
Normal file
64
source/java/org/alfresco/repo/avm/AVMTestSuite.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* AVM test suite
|
||||
*/
|
||||
public class AVMTestSuite extends TestSuite
|
||||
{
|
||||
/**
|
||||
* Creates the test suite
|
||||
*
|
||||
* @return the test suite
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
TestSuite suite = new TestSuite();
|
||||
|
||||
suite.addTestSuite(AVMNodeConverterTest.class);
|
||||
suite.addTestSuite(AVMExpiredContentTest.class);
|
||||
suite.addTestSuite(FileNameValidatorTest.class);
|
||||
|
||||
suite.addTestSuite(AVMServiceTestBase.class);
|
||||
suite.addTestSuite(AVMServiceTest.class);
|
||||
suite.addTestSuite(AVMServiceLocalTest.class);
|
||||
suite.addTestSuite(AVMServiceIndexTest.class);
|
||||
|
||||
suite.addTestSuite(AVMServicePerfTest.class);
|
||||
|
||||
suite.addTestSuite(AVMCrawlTestP.class);
|
||||
suite.addTestSuite(AVMScaleTestP.class);
|
||||
suite.addTestSuite(AVMStressTestP.class);
|
||||
|
||||
suite.addTestSuite(PurgeTestP.class);
|
||||
suite.addTestSuite(SimultaneousLoadTest.class);
|
||||
|
||||
return suite;
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -26,6 +26,8 @@ package org.alfresco.repo.avm;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -60,7 +62,6 @@ class AVMTester implements Runnable
|
||||
private List<String> fAllDirectories;
|
||||
private List<String> fAllFiles;
|
||||
|
||||
private static boolean fgFrozen = false;
|
||||
private static int fgOpCount = 0;
|
||||
|
||||
/**
|
||||
@@ -92,6 +93,7 @@ class AVMTester implements Runnable
|
||||
* Flag for whether this thread errored out.
|
||||
*/
|
||||
private boolean fError;
|
||||
private String fErrorStackTrace = null;
|
||||
|
||||
/**
|
||||
* Flag for whether this thread should exit.
|
||||
@@ -203,16 +205,15 @@ class AVMTester implements Runnable
|
||||
long startTime = System.currentTimeMillis();
|
||||
for (int i = 0; i < fOpCount; i++)
|
||||
{
|
||||
if (fgFrozen)
|
||||
{
|
||||
Thread.sleep(3600000);
|
||||
}
|
||||
if (fExit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
System.out.print(threadID + ":" + i + ":");
|
||||
int which = fgRandom.nextInt(fOpTable.length);
|
||||
|
||||
try
|
||||
{
|
||||
switch (fOpTable[which])
|
||||
{
|
||||
case CREATE_FILE :
|
||||
@@ -245,14 +246,33 @@ class AVMTester implements Runnable
|
||||
}
|
||||
IncCount();
|
||||
}
|
||||
System.out.println(fAllPaths.size() + " fses in " + (System.currentTimeMillis() - startTime) +
|
||||
"ms");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fgFrozen = true;
|
||||
if (e instanceof AVMException)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (e instanceof ContentIOException)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
throw new AVMException("Failure", e);
|
||||
}
|
||||
}
|
||||
System.out.println(fAllPaths.size() + " fses in " + (System.currentTimeMillis() - startTime) +
|
||||
"ms");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
t.printStackTrace(pw);
|
||||
|
||||
fError = true;
|
||||
fErrorStackTrace = sw.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,6 +280,8 @@ class AVMTester implements Runnable
|
||||
{
|
||||
String name = "PF" + fNames[fgRandom.nextInt(26 * 26)];
|
||||
String path = randomDirectory();
|
||||
if (path != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("create " + path + " " + name);
|
||||
@@ -273,11 +295,14 @@ class AVMTester implements Runnable
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createDirectory()
|
||||
{
|
||||
String name = "PD" + fNames[fgRandom.nextInt(26 * 26)];
|
||||
String path = randomDirectory();
|
||||
if (path != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("mkdir " + path + " " + name);
|
||||
@@ -289,6 +314,7 @@ class AVMTester implements Runnable
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void rename()
|
||||
{
|
||||
@@ -311,6 +337,8 @@ class AVMTester implements Runnable
|
||||
}
|
||||
String srcName = path.substring(lastSlash + 1);
|
||||
String dstPath = randomDirectory();
|
||||
if (dstPath != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("rename " + srcPath + " " + srcName + " " + dstPath + " " + name);
|
||||
@@ -330,12 +358,15 @@ class AVMTester implements Runnable
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createLayeredDir()
|
||||
{
|
||||
String name = "LD" + fNames[fgRandom.nextInt(26 * 26)];
|
||||
String path = randomDirectory();
|
||||
String target = randomDirectory();
|
||||
if ((path != null) && (target != null))
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("mklayereddir " + path + " " + name + " " + target);
|
||||
@@ -347,12 +378,15 @@ class AVMTester implements Runnable
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createLayeredFile()
|
||||
{
|
||||
String name = "LF" + fNames[fgRandom.nextInt(26 * 26)];
|
||||
String path = randomDirectory();
|
||||
String target = randomFile();
|
||||
if ((path != null) && (target != null))
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("createlayered " + path + " " + name + " " + target);
|
||||
@@ -364,6 +398,7 @@ class AVMTester implements Runnable
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeNode()
|
||||
{
|
||||
@@ -390,6 +425,8 @@ class AVMTester implements Runnable
|
||||
private void modifyFile()
|
||||
{
|
||||
String path = randomFile();
|
||||
if (path != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("modify " + path);
|
||||
@@ -403,10 +440,13 @@ class AVMTester implements Runnable
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readFile()
|
||||
{
|
||||
String path = randomFile();
|
||||
if (path != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("read " + path);
|
||||
@@ -421,6 +461,7 @@ class AVMTester implements Runnable
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refresh()
|
||||
{
|
||||
@@ -489,11 +530,22 @@ class AVMTester implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this thread in an error state.
|
||||
*/
|
||||
public boolean getError()
|
||||
{
|
||||
return fError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get error stack trace
|
||||
*/
|
||||
public String getErrorStackTrace()
|
||||
{
|
||||
return fErrorStackTrace;
|
||||
}
|
||||
|
||||
public void setExit()
|
||||
{
|
||||
fExit = true;
|
||||
@@ -549,16 +601,31 @@ class AVMTester implements Runnable
|
||||
|
||||
private String randomDirectory()
|
||||
{
|
||||
if (fAllDirectories.size() == 0)
|
||||
{
|
||||
System.out.println("cannot select random directory since no directories");
|
||||
return null;
|
||||
}
|
||||
return fAllDirectories.get(fgRandom.nextInt(fAllDirectories.size()));
|
||||
}
|
||||
|
||||
private String randomFile()
|
||||
{
|
||||
if (fAllFiles.size() == 0)
|
||||
{
|
||||
System.out.println("cannot select random file since no files");
|
||||
return null;
|
||||
}
|
||||
return fAllFiles.get(fgRandom.nextInt(fAllFiles.size()));
|
||||
}
|
||||
|
||||
private String randomPath()
|
||||
{
|
||||
if (fAllPaths.size() == 0)
|
||||
{
|
||||
System.out.println("cannot select random path since no paths");
|
||||
return null;
|
||||
}
|
||||
return fAllPaths.get(fgRandom.nextInt(fAllPaths.size()));
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -34,7 +34,7 @@ public class PurgeTestP extends AVMServiceTestBase
|
||||
/**
|
||||
* Test purging a version.
|
||||
*/
|
||||
public void testPurgeVersion()
|
||||
public void testPurgeVersion() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -42,7 +42,12 @@ public class PurgeTestP extends AVMServiceTestBase
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
long start = System.currentTimeMillis();
|
||||
loader.recursiveLoad("source/web", "main:/");
|
||||
|
||||
|
||||
//loader.recursiveLoad("source/web", "main:/");
|
||||
loader.recursiveLoad("source/java/org/alfresco/repo/avm", "main:/");
|
||||
|
||||
|
||||
System.err.println("Load time: " + (System.currentTimeMillis() - start) + "ms");
|
||||
fService.createSnapshot("main", null, null);
|
||||
System.err.println("Load time + snapshot: " + (System.currentTimeMillis() - start) + "ms");
|
||||
@@ -52,6 +57,7 @@ public class PurgeTestP extends AVMServiceTestBase
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.print(".");
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
@@ -59,18 +65,19 @@ public class PurgeTestP extends AVMServiceTestBase
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
System.out.println("\nReaper finished");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test purging a version that's not the latest.
|
||||
*/
|
||||
public void testPurgeOlderVersion()
|
||||
public void testPurgeOlderVersion() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -78,11 +85,21 @@ public class PurgeTestP extends AVMServiceTestBase
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
long start = System.currentTimeMillis();
|
||||
loader.recursiveLoad("source", "main:/");
|
||||
|
||||
|
||||
//loader.recursiveLoad("source", "main:/");
|
||||
loader.recursiveLoad("source/java/org/alfresco/repo/avm", "main:/");
|
||||
|
||||
|
||||
System.err.println("Load time: " + (System.currentTimeMillis() - start) + "ms");
|
||||
fService.createSnapshot("main", null, null);
|
||||
System.err.println("Load time + snapshot: " + (System.currentTimeMillis() - start) + "ms");
|
||||
fService.removeNode("main:/source/java/org/alfresco", "repo");
|
||||
|
||||
|
||||
//fService.removeNode("main:/source/java/org/alfresco", "repo");
|
||||
fService.removeNode("main:/avm", "actions");
|
||||
|
||||
|
||||
fService.createSnapshot("main", null, null);
|
||||
fService.purgeVersion(2, "main");
|
||||
fReaper.activate();
|
||||
@@ -90,6 +107,7 @@ public class PurgeTestP extends AVMServiceTestBase
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.print(".");
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
@@ -97,18 +115,19 @@ public class PurgeTestP extends AVMServiceTestBase
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
System.out.println("\nReaper finished");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test purging an entire store.
|
||||
*/
|
||||
public void testPurgeStore()
|
||||
public void testPurgeStore() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -116,13 +135,25 @@ public class PurgeTestP extends AVMServiceTestBase
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
long start = System.currentTimeMillis();
|
||||
loader.recursiveLoad("source", "main:/");
|
||||
|
||||
|
||||
//loader.recursiveLoad("source", "main:/");
|
||||
loader.recursiveLoad("source/java/org/alfresco/repo/avm", "main:/");
|
||||
|
||||
|
||||
System.err.println("Load time: " + (System.currentTimeMillis() - start) + "ms");
|
||||
fService.createSnapshot("main", null, null);
|
||||
System.err.println("Load time + snapshot: " + (System.currentTimeMillis() - start) + "ms");
|
||||
fService.createLayeredDirectory("main:/source", "main:/", "layer");
|
||||
fService.removeNode("main:/layer/java/org/alfresco", "repo");
|
||||
fService.createFile("main:/layer/java/org/alfresco", "goofy").close();
|
||||
|
||||
|
||||
//fService.createLayeredDirectory("main:/source", "main:/", "layer");
|
||||
//fService.removeNode("main:/layer/java/org/alfresco", "repo");
|
||||
//fService.createFile("main:/layer/java/org/alfresco", "goofy").close();
|
||||
fService.createLayeredDirectory("main:/avm", "main:/", "layer");
|
||||
fService.removeNode("main:/layer", "actions");
|
||||
fService.createFile("main:/layer", "goofy").close();
|
||||
|
||||
|
||||
fService.createSnapshot("main", null, null);
|
||||
fService.purgeStore("main");
|
||||
fReaper.activate();
|
||||
@@ -130,6 +161,7 @@ public class PurgeTestP extends AVMServiceTestBase
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.print(".");
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
@@ -137,11 +169,12 @@ public class PurgeTestP extends AVMServiceTestBase
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
System.out.println("\nReaper finished");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -31,41 +31,50 @@ import org.alfresco.repo.avm.util.BulkLoader;
|
||||
*/
|
||||
public class SimultaneousLoadTest extends AVMServiceTestBase
|
||||
{
|
||||
public void testSimulLoadA() throws Throwable
|
||||
{
|
||||
testSimultaneousLoad(1,1);
|
||||
}
|
||||
|
||||
public void testSimulLoadB() throws Throwable
|
||||
{
|
||||
testSimultaneousLoad(5,3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test loading content simultaneously.
|
||||
*/
|
||||
public void testSimultaneousLoad()
|
||||
private void testSimultaneousLoad(int n, int m) throws Throwable
|
||||
{
|
||||
// try
|
||||
// {
|
||||
// int n = 1;
|
||||
// int m = 1;
|
||||
// fReaper.setInactiveBaseSleep(60000);
|
||||
// for (int i = 0; i < n; i++)
|
||||
// {
|
||||
// fService.createDirectory("main:/", "d" + i);
|
||||
// }
|
||||
// fService.createSnapshot("main", null, null);
|
||||
// Thread [] threads = new Thread[n];
|
||||
// for (int i = 0; i < n; i++)
|
||||
// {
|
||||
// Loader loader = new Loader("/Users/britt/stuff/" + i, "main:/d" + i, m);
|
||||
// threads[i] = new Thread(loader);
|
||||
// threads[i].start();
|
||||
// }
|
||||
// for (int i = 0; i < n; i++)
|
||||
// {
|
||||
// threads[i].join();
|
||||
// }
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// e.printStackTrace(System.err);
|
||||
// fail();
|
||||
// }
|
||||
try
|
||||
{
|
||||
fReaper.setActiveBaseSleep(60000);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
fService.createDirectory("main:/", "d" + i);
|
||||
}
|
||||
fService.createSnapshot("main", null, null);
|
||||
Thread [] threads = new Thread[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
//Loader loader = new Loader("/Users/britt/stuff/" + i, "main:/d" + i, m);
|
||||
Loader loader = new Loader("source/java/org/alfresco/repo/avm", "main:/d" + i, m);
|
||||
|
||||
threads[i] = new Thread(loader);
|
||||
threads[i].start();
|
||||
}
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
threads[i].join();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private class Loader implements Runnable
|
||||
{
|
||||
/**
|
||||
|
@@ -34,10 +34,9 @@ import javax.transaction.UserTransaction;
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.repo.transaction.TransactionListenerAdapter;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.TransactionListenerAdapter;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
|
Reference in New Issue
Block a user