summaryrefslogtreecommitdiff
path: root/java/perftests
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2012-08-29 21:53:02 +0000
committerKeith Wall <kwall@apache.org>2012-08-29 21:53:02 +0000
commited55426f56b6820915d642a52dc451e78f70ceb6 (patch)
treef9ce249dac26631bccc8c702edc621d76de6c5e8 /java/perftests
parent9ef4fcc7b7b12118f76c2fcbfcf1b24a065c0434 (diff)
downloadqpid-python-ed55426f56b6820915d642a52dc451e78f70ceb6.tar.gz
QPID-4143 now producing test-summary.csv to make viewing all the 'all participants' test results more convenient. Re-ordered columns so that the important stuff appears first.
Applied patch from Philip Harvey <phil@philharveyonline.com> git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1378751 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/perftests')
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java11
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java59
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/ResultsFileWriter.java112
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java21
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java39
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java2
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java23
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormatter.java (renamed from java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormater.java)6
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java8
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java86
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java35
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java (renamed from java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java)9
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv4
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java8
14 files changed, 346 insertions, 77 deletions
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java b/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java
index fb4c1b700b..ee374e180d 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java
@@ -60,15 +60,4 @@ public class ConfigFileHelper
return testConfigFile;
}
-
- /**
- * generateOutputCsvNameFrom("/config/testConfigFile.js", "/output") returns /output/testConfigFile.csv
- */
- public String generateOutputCsvNameFrom(String testConfigFile, String outputDir)
- {
- final String filenameOnlyWithExtension = new File(testConfigFile).getName();
- final String cvsFile = filenameOnlyWithExtension.replaceFirst(".?\\w*$", ".csv");
-
- return new File(outputDir, cvsFile).getAbsolutePath();
- }
}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java b/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java
index aea0ea301a..a0e949bddc 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java
@@ -19,9 +19,9 @@
*/
package org.apache.qpid.disttest;
+import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import javax.naming.Context;
@@ -32,7 +32,6 @@ import org.apache.qpid.disttest.controller.config.Config;
import org.apache.qpid.disttest.controller.config.ConfigReader;
import org.apache.qpid.disttest.jms.ControllerJmsDelegate;
import org.apache.qpid.disttest.results.aggregation.Aggregator;
-import org.apache.qpid.disttest.results.formatting.CSVFormater;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,6 +51,8 @@ public class ControllerRunner extends AbstractRunner
private final ConfigFileHelper _configFileHelper = new ConfigFileHelper();
+ private ResultsFileWriter _resuResultsFileWriter;
+
public ControllerRunner()
{
getCliOptions().put(TEST_CONFIG_PROP, TEST_CONFIG_DEFAULT);
@@ -69,6 +70,7 @@ public class ControllerRunner extends AbstractRunner
public void runController() throws Exception
{
Context context = getContext();
+ setUpResultsWriter();
ControllerJmsDelegate jmsDelegate = new ControllerJmsDelegate(context);
@@ -82,6 +84,13 @@ public class ControllerRunner extends AbstractRunner
}
}
+ void setUpResultsWriter()
+ {
+ String outputDirString = getCliOptions().get(ControllerRunner.OUTPUT_DIR_PROP);
+ File outputDir = new File(outputDirString);
+ _resuResultsFileWriter = new ResultsFileWriter(outputDir);
+ }
+
private void runTests(ControllerJmsDelegate jmsDelegate)
{
Controller controller = new Controller(jmsDelegate, DistributedTestConstants.REGISTRATION_TIMEOUT, DistributedTestConstants.COMMAND_RESPONSE_TIMEOUT);
@@ -92,6 +101,8 @@ public class ControllerRunner extends AbstractRunner
try
{
+ List<ResultsForAllTests> results = new ArrayList<ResultsForAllTests>();
+
for (String testConfigFile : testConfigFiles)
{
final Config testConfig = buildTestConfigFrom(testConfigFile);
@@ -100,8 +111,11 @@ public class ControllerRunner extends AbstractRunner
controller.awaitClientRegistrations();
LOGGER.info("Running test : " + testConfigFile);
- runTest(controller, testConfigFile);
+ ResultsForAllTests testResult = runTest(controller, testConfigFile);
+ results.add(testResult);
}
+
+ _resuResultsFileWriter.writeResultsSummary(results);
}
catch(Exception e)
{
@@ -113,7 +127,7 @@ public class ControllerRunner extends AbstractRunner
}
}
- private void runTest(Controller controller, String testConfigFile)
+ private ResultsForAllTests runTest(Controller controller, String testConfigFile)
{
final Config testConfig = buildTestConfigFrom(testConfigFile);
controller.setConfig(testConfig);
@@ -121,9 +135,8 @@ public class ControllerRunner extends AbstractRunner
ResultsForAllTests rawResultsForAllTests = controller.runAllTests();
ResultsForAllTests resultsForAllTests = _aggregator.aggregateResults(rawResultsForAllTests);
- String outputDir = getCliOptions().get(ControllerRunner.OUTPUT_DIR_PROP);
- final String outputFile = _configFileHelper.generateOutputCsvNameFrom(testConfigFile, outputDir);
- writeResultsToFile(resultsForAllTests, outputFile);
+ _resuResultsFileWriter.writeResultsToFile(resultsForAllTests, testConfigFile);
+ return resultsForAllTests;
}
private void createClientsIfNotDistributed(final List<String> testConfigFiles)
@@ -148,36 +161,6 @@ public class ControllerRunner extends AbstractRunner
}
}
- private void writeResultsToFile(ResultsForAllTests resultsForAllTests, String outputFile)
- {
- FileWriter writer = null;
- try
- {
- final String outputCsv = new CSVFormater().format(resultsForAllTests);
- writer = new FileWriter(outputFile);
- writer.write(outputCsv);
- LOGGER.info("Wrote " + resultsForAllTests.getTestResults().size() + " test result(s) to output file " + outputFile);
- }
- catch (IOException e)
- {
- throw new DistributedTestException("Unable to write output file " + outputFile, e);
- }
- finally
- {
- if (writer != null)
- {
- try
- {
- writer.close();
- }
- catch (IOException e)
- {
- LOGGER.error("Failed to close stream for file " + outputFile, e);
- }
- }
- }
- }
-
private Config buildTestConfigFrom(String testConfigFile)
{
ConfigReader configReader = new ConfigReader();
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/ResultsFileWriter.java b/java/perftests/src/main/java/org/apache/qpid/disttest/ResultsFileWriter.java
new file mode 100644
index 0000000000..81b717403d
--- /dev/null
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/ResultsFileWriter.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.qpid.disttest;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.qpid.disttest.controller.ResultsForAllTests;
+import org.apache.qpid.disttest.results.aggregation.TestResultAggregator;
+import org.apache.qpid.disttest.results.formatting.CSVFormatter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ResultsFileWriter
+{
+ private static final Logger LOGGER = LoggerFactory.getLogger(ResultsFileWriter.class);
+
+ static final String TEST_SUMMARY_FILE_NAME = "test-summary.csv";
+
+ private final File _outputDir;
+
+ private CSVFormatter _csvFormater = new CSVFormatter();
+
+ private TestResultAggregator _testResultAggregator = new TestResultAggregator();
+
+ public ResultsFileWriter(File outputDir)
+ {
+ _outputDir = outputDir;
+ }
+
+ public void writeResultsToFile(ResultsForAllTests resultsForAllTests, String testConfigFile)
+ {
+ final String outputFile = generateOutputCsvNameFrom(testConfigFile);
+ writeResultsToOutputFile(resultsForAllTests, outputFile);
+ }
+
+ public void writeResultsSummary(List<ResultsForAllTests> allResultsList)
+ {
+ ResultsForAllTests combinedResults = _testResultAggregator.aggregateTestResults(allResultsList);
+ writeResultsToOutputFile(combinedResults, new File(_outputDir, TEST_SUMMARY_FILE_NAME).getAbsolutePath());
+ }
+
+ /**
+ * generateOutputCsvNameFrom("/config/testConfigFile.js", "/output") returns /output/testConfigFile.csv
+ */
+ private String generateOutputCsvNameFrom(String testConfigFile)
+ {
+ final String filenameOnlyWithExtension = new File(testConfigFile).getName();
+ final String cvsFile = filenameOnlyWithExtension.replaceFirst(".?\\w*$", ".csv");
+
+ return new File(_outputDir, cvsFile).getAbsolutePath();
+ }
+
+ private void writeResultsToOutputFile(ResultsForAllTests resultsForAllTests, String outputFile)
+ {
+ FileWriter writer = null;
+ try
+ {
+ final String outputCsv = _csvFormater.format(resultsForAllTests);
+ writer = new FileWriter(outputFile);
+ writer.write(outputCsv);
+ LOGGER.info("Wrote " + resultsForAllTests.getTestResults().size() + " test result(s) to output file " + outputFile);
+ }
+ catch (IOException e)
+ {
+ throw new DistributedTestException("Unable to write output file " + outputFile, e);
+ }
+ finally
+ {
+ if (writer != null)
+ {
+ try
+ {
+ writer.close();
+ }
+ catch (IOException e)
+ {
+ LOGGER.error("Failed to close stream for file " + outputFile, e);
+ }
+ }
+ }
+ }
+
+ void setCsvFormater(CSVFormatter csvFormater)
+ {
+ _csvFormater = csvFormater;
+ }
+
+ void setTestResultAggregator(TestResultAggregator testResultAggregator)
+ {
+ _testResultAggregator = testResultAggregator;
+ }
+
+}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java
index 6c5ff3450c..d4474e2c12 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java
@@ -21,7 +21,9 @@ package org.apache.qpid.disttest.controller;
import java.util.ArrayList;
import java.util.List;
+import org.apache.qpid.disttest.message.ParticipantResult;
import org.apache.qpid.disttest.results.aggregation.ITestResult;
+import org.apache.qpid.disttest.results.aggregation.TestResultAggregator;
public class ResultsForAllTests
{
@@ -46,4 +48,23 @@ public class ResultsForAllTests
{
return _hasErrors;
}
+
+ public ResultsForAllTests getAllParticipantsResult()
+ {
+ ResultsForAllTests summaryResultsForAllTests = new ResultsForAllTests();
+
+ for (ITestResult testResult : _results)
+ {
+ for(ParticipantResult participantResult : testResult.getParticipantResults())
+ {
+ if(TestResultAggregator.ALL_CONSUMER_PARTICIPANTS_NAME.equals(participantResult.getParticipantName()))
+ {
+ TestResult summaryTestResult = new TestResult(testResult.getName());
+ summaryTestResult.addParticipantResult(participantResult);
+ summaryResultsForAllTests.add(summaryTestResult);
+ }
+ }
+ }
+ return summaryResultsForAllTests;
+ }
}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java
index 0418562a2d..ea1a633f21 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java
@@ -18,6 +18,8 @@
*/
package org.apache.qpid.disttest.message;
+import java.text.DecimalFormat;
+
import org.apache.qpid.disttest.client.Participant;
/**
@@ -31,6 +33,8 @@ public enum ParticipantAttribute
{
TEST_NAME("testName"),
ITERATION_NUMBER("iterationNumber"),
+ THROUGHPUT("throughputKbPerS", "#"),
+ AVERAGE_LATENCY("averageLatency", "#"),
CONFIGURED_CLIENT_NAME("clientName"),
PARTICIPANT_NAME("participantName"),
NUMBER_OF_MESSAGES_PROCESSED("numberOfMessages"),
@@ -52,24 +56,55 @@ public enum ParticipantAttribute
TOTAL_NUMBER_OF_CONSUMERS("totalNumberOfConsumers"),
TOTAL_NUMBER_OF_PRODUCERS("totalNumberOfProducers"),
TOTAL_PAYLOAD_PROCESSED("totalPayloadProcessedB"),
- THROUGHPUT("throughputKbPerS"),
TIME_TAKEN("timeTakenMs"),
ERROR_MESSAGE("errorMessage"),
MIN_LATENCY("minLatency"),
MAX_LATENCY("maxLatency"),
- AVERAGE_LATENCY("averageLatency"),
LATENCY_STANDARD_DEVIATION("latencyStandardDeviation")
;
private String _displayName;
+ private String _decimalFormat;
ParticipantAttribute(String displayName)
{
_displayName = displayName;
}
+ ParticipantAttribute(String displayName, String decimalFormat)
+ {
+ _displayName = displayName;
+ _decimalFormat = decimalFormat;
+ }
+
+ public String getDecimalFormat()
+ {
+ return _decimalFormat;
+ }
+
public String getDisplayName()
{
return _displayName;
}
+
+ public String format(Object attributeValue)
+ {
+ if(attributeValue == null)
+ {
+ return null;
+ }
+
+ String attributeAsString = String.valueOf(attributeValue);
+
+ if(_decimalFormat != null)
+ {
+ DecimalFormat decimalFormat = new DecimalFormat(_decimalFormat);
+ double attributeAsDoule = Double.valueOf(attributeAsString);
+ return decimalFormat.format(attributeAsDoule);
+ }
+ else
+ {
+ return attributeAsString;
+ }
+ }
}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java b/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java
index 3f9cdff69d..6230067486 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java
@@ -22,10 +22,8 @@ import java.util.List;
import org.apache.qpid.disttest.message.ParticipantResult;
-// TODO rename me!!
public interface ITestResult
{
-
// TODO should weaken to Collection
List<ParticipantResult> getParticipantResults();
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java b/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java
index 5934e0e997..954f796d21 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java
@@ -18,6 +18,9 @@
*/
package org.apache.qpid.disttest.results.aggregation;
+import java.util.List;
+
+import org.apache.qpid.disttest.controller.ResultsForAllTests;
import org.apache.qpid.disttest.message.ConsumerParticipantResult;
import org.apache.qpid.disttest.message.ParticipantResult;
import org.apache.qpid.disttest.message.ProducerParticipantResult;
@@ -103,4 +106,24 @@ public class TestResultAggregator
aggregatedAllResult.setTotalPayloadProcessed(aggregatedConsumerResult.getTotalPayloadProcessed());
aggregatedAllResult.setThroughput(aggregatedConsumerResult.getThroughput());
}
+
+ /**
+ * Produces a single {@link ResultsForAllTests} from the supplied list, only containing
+ * the "All participants" results.
+ */
+ public ResultsForAllTests aggregateTestResults(List<ResultsForAllTests> allResultsList)
+ {
+ ResultsForAllTests retVal = new ResultsForAllTests();
+
+ for (ResultsForAllTests resultsForAllTests : allResultsList)
+ {
+ ResultsForAllTests allParticipantsResult = resultsForAllTests.getAllParticipantsResult();
+ for (ITestResult testResult : allParticipantsResult.getTestResults())
+ {
+ retVal.add(testResult);
+ }
+ }
+
+ return retVal;
+ }
}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormater.java b/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormatter.java
index 52e53ca624..ea7a3f78c7 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormater.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormatter.java
@@ -32,7 +32,7 @@ import org.apache.qpid.disttest.results.aggregation.ITestResult;
/**
* produces CSV output using the ordered enums in {@link ParticipantAttribute}
*/
-public class CSVFormater
+public class CSVFormatter
{
public String format(ResultsForAllTests results)
{
@@ -66,7 +66,9 @@ public class CSVFormater
List<Object> attributeValues = new ArrayList<Object>();
for (ParticipantAttribute attribute : ParticipantAttribute.values())
{
- attributeValues.add(attributeValueMap.get(attribute));
+ Object attributeValue = attributeValueMap.get(attribute);
+ String attributeValueFormatted = attribute.format(attributeValue);
+ attributeValues.add(attributeValueFormatted);
}
String row = StringUtils.join(attributeValues.toArray(), ",");
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java
index a10b3b359e..629442d86c 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java
@@ -39,14 +39,6 @@ public class ConfigFileHelperTest extends QpidTestCase
_testDir = TestFileUtils.createTestDirectory();
}
- public void testGenerateOutputCsvNameFrom()
- {
- String outputDir = "/tmp/outputDir";
-
- assertEquals("/tmp/outputDir/my.json.file.csv", _configFileHelper.generateOutputCsvNameFrom("/tmp/my.json.file.json", outputDir));
- assertEquals("/tmp/outputDir/my.js.file.csv", _configFileHelper.generateOutputCsvNameFrom("/tmp/my.js.file.js", outputDir));
- }
-
public void testGetTestConfigFilesForDirectory() throws Exception
{
String jsFile = createFile("file1.js");
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java
new file mode 100644
index 0000000000..abe000f072
--- /dev/null
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.qpid.disttest;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.apache.qpid.disttest.controller.ResultsForAllTests;
+import org.apache.qpid.disttest.results.aggregation.TestResultAggregator;
+import org.apache.qpid.disttest.results.formatting.CSVFormatter;
+import org.apache.qpid.test.utils.TestFileUtils;
+import org.apache.qpid.util.FileUtils;
+
+public class ResultsFileWriterTest extends TestCase
+{
+ private CSVFormatter _csvFormater = mock(CSVFormatter.class);
+ private TestResultAggregator _testResultAggregator = mock(TestResultAggregator.class);
+
+ private File _outputDir = TestFileUtils.createTestDirectory();
+
+ private ResultsFileWriter _resultsFileWriter = new ResultsFileWriter(_outputDir);
+
+ @Override
+ public void setUp()
+ {
+ _resultsFileWriter.setCsvFormater(_csvFormater);
+ _resultsFileWriter.setTestResultAggregator(_testResultAggregator);
+ }
+
+ public void testWriteResultsToFile()
+ {
+ ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class);
+
+ String expectedCsvContents = "expected-csv-contents";
+ when(_csvFormater.format(resultsForAllTests)).thenReturn(expectedCsvContents);
+
+ _resultsFileWriter.writeResultsToFile(resultsForAllTests, "config.json");
+
+ File resultsFile = new File(_outputDir, "config.csv");
+
+ assertEquals(expectedCsvContents, FileUtils.readFileAsString(resultsFile));
+ }
+
+ public void testWriteResultsSummary()
+ {
+ ResultsForAllTests results1 = mock(ResultsForAllTests.class);
+ ResultsForAllTests results2 = mock(ResultsForAllTests.class);
+ ResultsForAllTests summaryResults = mock(ResultsForAllTests.class);
+
+ when(_testResultAggregator.aggregateTestResults(Arrays.asList(results1, results2)))
+ .thenReturn(summaryResults);
+
+ String expectedSummaryFileContents = "expected-summary-file";
+
+ when(_csvFormater.format(summaryResults))
+ .thenReturn(expectedSummaryFileContents);
+
+ _resultsFileWriter.writeResultsSummary(Arrays.asList(results1, results2));
+
+ File summaryFile = new File(_outputDir, ResultsFileWriter.TEST_SUMMARY_FILE_NAME);
+
+ assertEquals(expectedSummaryFileContents, FileUtils.readFileAsString(summaryFile));
+ }
+
+}
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java
index 9c00e7cf1c..7cb9ebed5e 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java
@@ -18,11 +18,15 @@
*/
package org.apache.qpid.disttest.results.aggregation;
+import static org.mockito.Mockito.*;
+
+import java.util.Arrays;
import java.util.Date;
import java.util.List;
import junit.framework.TestCase;
+import org.apache.qpid.disttest.controller.ResultsForAllTests;
import org.apache.qpid.disttest.controller.TestResult;
import org.apache.qpid.disttest.message.ConsumerParticipantResult;
import org.apache.qpid.disttest.message.ParticipantResult;
@@ -30,17 +34,14 @@ import org.apache.qpid.disttest.message.ProducerParticipantResult;
public class TestResultAggregatorTest extends TestCase
{
-
private static final String TEST1_NAME = "TEST1_NAME";
private static final int TEST1_ITERATION_NUMBER = 1;
-
private static final String CONSUMER_PARTICIPANT_NAME1 = "CONSUMER_PARTICIPANT_NAME1";
private static final String CONSUMER_PARTICIPANT_NAME2 = "CONSUMER_PARTICIPANT_NAME2";
private static final String PRODUCER_PARTICIPANT_NAME = "PRODUCER_PARTICIPANT_NAME";
-
private static final long CONSUMER1_STARTDATE = 50;
private static final long CONSUMER1_ENDDATE = 20000;
@@ -64,6 +65,33 @@ public class TestResultAggregatorTest extends TestCase
private TestResultAggregator _aggregator = new TestResultAggregator();
+ public void testAggregateTestResults()
+ {
+ ResultsForAllTests resultsForAllTests1 = mock(ResultsForAllTests.class);
+ ResultsForAllTests resultsForAllTests2 = mock(ResultsForAllTests.class);
+
+ ResultsForAllTests summaryResult1 = mock(ResultsForAllTests.class);
+ ResultsForAllTests summaryResult2 = mock(ResultsForAllTests.class);
+
+ when(resultsForAllTests1.getAllParticipantsResult()).thenReturn(summaryResult1);
+ when(resultsForAllTests2.getAllParticipantsResult()).thenReturn(summaryResult2);
+
+ ITestResult testResult1 = mock(ITestResult.class);
+ ITestResult testResult2 = mock(ITestResult.class);
+
+ when(summaryResult1.getTestResults()).thenReturn(Arrays.asList(testResult1));
+ when(summaryResult2.getTestResults()).thenReturn(Arrays.asList(testResult2));
+
+ ResultsForAllTests actualSummaryResults = _aggregator.aggregateTestResults(Arrays.asList(
+ resultsForAllTests1,
+ resultsForAllTests2));
+
+ assertEquals(
+ "Summary results should contain the all the 'all participants' test results",
+ Arrays.asList(testResult1, testResult2),
+ actualSummaryResults.getTestResults());
+ }
+
public void testAggregateResultsForTwoConsumerAndOneProducer() throws Exception
{
TestResult originalTestResult = createResultsFromTest();
@@ -197,4 +225,5 @@ public class TestResultAggregatorTest extends TestCase
participantResult.setEndDate(new Date(end));
participantResult.setBatchSize(batchSize);
}
+
}
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java
index 565f59d25b..0d66c7ffb5 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java
@@ -59,13 +59,13 @@ import org.apache.qpid.disttest.controller.TestResult;
import org.apache.qpid.disttest.message.ParticipantAttribute;
import org.apache.qpid.disttest.message.ParticipantResult;
-public class CSVFormaterTest extends TestCase
+public class CSVFormatterTest extends TestCase
{
private static final String TEST1 = "TEST1";
private static final String PARTICIPANT = "PARTICIPANT";
private static final String CONFIGURED_CLIENT1 = "CONFIGURED_CLIENT1";
- private CSVFormater _formatter = new CSVFormater();
+ private CSVFormatter _formatter = new CSVFormatter();
public void testResultsFileWithWithOneRow() throws Exception
{
@@ -115,12 +115,12 @@ public class CSVFormaterTest extends TestCase
participantAttributes.put(TOTAL_NUMBER_OF_CONSUMERS, 1);
participantAttributes.put(TOTAL_NUMBER_OF_PRODUCERS, 2);
participantAttributes.put(TOTAL_PAYLOAD_PROCESSED, 1024);
- participantAttributes.put(THROUGHPUT, 2048);
+ participantAttributes.put(THROUGHPUT, 2048.49);
participantAttributes.put(TIME_TAKEN, 1000);
participantAttributes.put(ERROR_MESSAGE, "error");
participantAttributes.put(MIN_LATENCY, 2l);
participantAttributes.put(MAX_LATENCY, 9l);
- participantAttributes.put(AVERAGE_LATENCY, 5.0f);
+ participantAttributes.put(AVERAGE_LATENCY, 4.6f);
participantAttributes.put(LATENCY_STANDARD_DEVIATION, 2.0f);
return participantAttributes;
}
@@ -142,5 +142,4 @@ public class CSVFormaterTest extends TestCase
return output.toString();
}
-
}
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv
index ada2303d46..a5881e187a 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv
@@ -1,2 +1,2 @@
-testName,iterationNumber,clientName,participantName,numberOfMessages,payloadSizeB,priority,timeToLiveMs,acknowledgeMode,deliveryMode,batchSize,maximumDurationMs,producerStartDelayMs,producerIntervalMs,isTopic,isDurableSubscription,isBrowsingSubscription,isSelector,isNoLocal,isSynchronousConsumer,totalNumberOfConsumers,totalNumberOfProducers,totalPayloadProcessedB,throughputKbPerS,timeTakenMs,errorMessage,minLatency,maxLatency,averageLatency,latencyStandardDeviation
-TEST1,0,CONFIGURED_CLIENT1,PARTICIPANT,0,1,2,3,4,5,6,7,8,9,true,false,true,false,true,false,1,2,1024,2048,1000,error,2,9,5.0,2.0
+testName,iterationNumber,throughputKbPerS,averageLatency,clientName,participantName,numberOfMessages,payloadSizeB,priority,timeToLiveMs,acknowledgeMode,deliveryMode,batchSize,maximumDurationMs,producerStartDelayMs,producerIntervalMs,isTopic,isDurableSubscription,isBrowsingSubscription,isSelector,isNoLocal,isSynchronousConsumer,totalNumberOfConsumers,totalNumberOfProducers,totalPayloadProcessedB,timeTakenMs,errorMessage,minLatency,maxLatency,latencyStandardDeviation
+TEST1,0,2048,5,CONFIGURED_CLIENT1,PARTICIPANT,0,1,2,3,4,5,6,7,8,9,true,false,true,false,true,false,1,2,1024,1000,error,2,9,2.0
diff --git a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java
index 7e58e1b5b1..75242e06cc 100644
--- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java
@@ -76,10 +76,10 @@ public class EndToEndTest extends QpidBrokerTestCase
String[] cells = csvLine.split(",", DONT_STRIP_EMPTY_LAST_FIELD_FLAG);
// All attributes become cells in the CSV, so this will be true
assertEquals("Unexpected number of cells in CSV line " + csvLine, ParticipantAttribute.values().length, cells.length);
- assertEquals("Unexpected test name in CSV line " + csvLine, testName, cells[0]);
- assertEquals("Unexpected client name in CSV line " + csvLine, clientName, cells[2]);
- assertEquals("Unexpected participant name in CSV line " + csvLine, participantName, cells[3]);
- assertEquals("Unexpected number of messages processed in CSV line " + csvLine, String.valueOf(expectedNumberOfMessagesProcessed), cells[4]);
+ assertEquals("Unexpected test name in CSV line " + csvLine, testName, cells[ParticipantAttribute.TEST_NAME.ordinal()]);
+ assertEquals("Unexpected client name in CSV line " + csvLine, clientName, cells[ParticipantAttribute.CONFIGURED_CLIENT_NAME.ordinal()]);
+ assertEquals("Unexpected participant name in CSV line " + csvLine, participantName, cells[ParticipantAttribute.PARTICIPANT_NAME.ordinal()]);
+ assertEquals("Unexpected number of messages processed in CSV line " + csvLine, String.valueOf(expectedNumberOfMessagesProcessed), cells[ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED.ordinal()]);
}