public abstract class AbstractTest<T> extends Benchmark implements CSVResultGenerator
Constructor and Description |
---|
AbstractTest() |
Modifier and Type | Method and Description |
---|---|
protected void |
addBackgroundJob(Runnable job)
Adds a background thread that repeatedly executes the given job
until all the iterations of this test have been executed.
|
protected void |
afterSuite()
Run after all iterations of this test have been executed.
|
protected void |
afterTest() |
protected void |
afterTest(T executionContext) |
protected void |
beforeSuite()
Run before any iterations of this test get executed.
|
protected void |
beforeTest() |
protected void |
beforeTest(T executionContext) |
protected String |
comment() |
protected javax.jcr.Repository[] |
createRepository(RepositoryFixture fixture)
Customize the repository creation process by custom fixture handling
|
protected void |
disposeThreadExecutionContext(T context) |
long |
execute()
Executes a single iteration of this test.
|
protected void |
failOnRepositoryVersions(String... versions) |
protected javax.jcr.Credentials |
getCredentials() |
protected javax.jcr.Repository |
getRepository() |
protected static int |
getScale(int def) |
protected void |
issueHaltChildThreads()
this method will be called during the
tearDown() before the afterSuite() . |
protected void |
issueHaltRequest(String message)
If concurrency level is 1 (
--concurrency 1 , the default) it will issue a request to
halt any future runs of a single benchmark. |
protected javax.jcr.Session |
login(javax.jcr.Credentials credentials)
Returns a new session for the given user
that will be automatically closed once
all the iterations of this test have been executed.
|
protected javax.jcr.Session |
loginAdministrative()
Returns a new admin session that will be automatically closed once
all the iterations of this test have been executed.
|
protected javax.jcr.Session |
loginAnonymous()
Returns a new reader session that will be automatically closed once
all the iterations of this test have been executed.
|
protected javax.jcr.Session |
loginWriter()
Returns a new writer session that will be automatically closed once
all the iterations of this test have been executed.
|
protected void |
logout(javax.jcr.Session session)
Logs out and removes the session from the internal pool.
|
protected T |
prepareThreadExecutionContext()
Invoked before the thread starts.
|
void |
run(Iterable<RepositoryFixture> fixtures)
Runs this benchmark against all the given repository fixtures.
|
void |
run(Iterable<RepositoryFixture> fixtures,
List<Integer> concurrencyLevels) |
protected abstract void |
runTest() |
protected void |
runTest(T executionContext) |
void |
setPrintStream(PrintStream out) |
void |
setUp(javax.jcr.Repository repository,
javax.jcr.Credentials credentials)
Prepares this performance benchmark.
|
protected String[] |
statsFormats()
Format string used for additional stats as per
Formatter
Example [ "%6d" , "%6.0f" ] |
protected String[] |
statsNames()
Names of additional stats which benchmark wants to be reported as part of
default report.
|
protected Object[] |
statsValues()
Stats values which needs to be included in the report
|
void |
tearDown()
Cleans up after this performance benchmark.
|
protected void issueHaltRequest(@Nullable String message)
--concurrency 1
, the default) it will issue a request to
halt any future runs of a single benchmark. Useful when the benchmark makes sense only if run
in conjunction of any other parallel operations.message
- an optional message that can be provided. It will logged at info level.protected void issueHaltChildThreads()
this method will be called during the tearDown()
before the afterSuite()
.
Override it if you have background processes you wish to stop.
For example in case of big imports, the suite could be keep running for as long as the import is running, even if the tests are actually no longer executed.
public void setPrintStream(PrintStream out)
setPrintStream
in interface CSVResultGenerator
protected static int getScale(int def)
public void setUp(javax.jcr.Repository repository, javax.jcr.Credentials credentials) throws Exception
repository
- the repository to usecredentials
- credentials of a user with write accessException
- if the benchmark can not be preparedpublic void run(Iterable<RepositoryFixture> fixtures)
Benchmark
public void run(Iterable<RepositoryFixture> fixtures, List<Integer> concurrencyLevels)
public long execute() throws Exception
Exception
- if an error occurspublic void tearDown() throws Exception
Exception
- if the benchmark can not be cleaned upprotected String[] statsNames()
protected String[] statsFormats()
Formatter
Example [ "%6d" , "%6.0f" ]protected Object[] statsValues()
@CheckForNull protected String comment()
protected void beforeSuite() throws Exception
Exception
- if an error occursprotected void afterSuite() throws Exception
Exception
- if an error occursprotected T prepareThreadExecutionContext() throws Exception
Exception
protected void disposeThreadExecutionContext(T context) throws Exception
Exception
protected void afterTest(T executionContext)
protected void beforeTest(T executionContext)
protected void failOnRepositoryVersions(String... versions) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
protected javax.jcr.Repository getRepository()
protected javax.jcr.Credentials getCredentials()
protected javax.jcr.Session loginAnonymous()
protected javax.jcr.Session loginAdministrative()
protected javax.jcr.Session login(javax.jcr.Credentials credentials)
credentials
- the user credentialsprotected void logout(javax.jcr.Session session)
session
- the session to logoutprotected javax.jcr.Session loginWriter()
protected void addBackgroundJob(Runnable job)
job
- background jobprotected javax.jcr.Repository[] createRepository(RepositoryFixture fixture) throws Exception
Exception
Copyright © 2012-2016 The Apache Software Foundation. All Rights Reserved.