private void runTest(AbstractTest test, String name, byte[] conf) { if (true) { // Create the repository directory File dir = new File(new File("target", "repository"), name + "-" + test); dir.mkdirs(); try { // Copy the configuration file into the repository directory File xml = new File(dir, "repository.xml"); OutputStream output = FileUtils.openOutputStream(xml); try { output.write(conf, 0, conf.length); } finally { output.close(); } // Create the repository RepositoryImpl repository = createRepository(dir, xml); try { // Run the test DescriptiveStatistics statistics = runTest(test, repository); if (statistics.getN() > 0) { writeReport(test.toString(), name, statistics); } } finally { repository.shutdown(); } } catch (Throwable t) { System.out.println("Unable to run " + test + ": " + t.getMessage()); t.printStackTrace(); } finally { // FileUtils.deleteQuietly(dir); } } }
private DescriptiveStatistics runTest(AbstractTest test, Repository repository) throws Exception { DescriptiveStatistics statistics = new DescriptiveStatistics(); test.setUp(repository, credentials); try { // Run a few iterations to warm up the system long warmupEnd = System.currentTimeMillis() + warmup * 1000; while (System.currentTimeMillis() < warmupEnd) { test.execute(); } // Run test iterations, and capture the execution times long runtimeEnd = System.currentTimeMillis() + runtime * 1000; while (System.currentTimeMillis() < runtimeEnd) { statistics.addValue(test.execute()); } } finally { test.tearDown(); } return statistics; }