summaryrefslogtreecommitdiff
path: root/java/perftests/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/perftests/src')
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/ArgumentParser.java6
-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.java84
-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/client/ConsumerParticipant.java17
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java10
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java56
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/controller/ClientRegistry.java36
-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/controller/config/ConsumerConfig.java6
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ParticipantConfig.java4
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ProducerConfig.java2
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/db/ResultsDbWriter.java467
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/jms/ClientJmsDelegate.java64
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/jms/ControllerJmsDelegate.java4
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/jms/NoOpQueueCreator.java5
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidQueueCreator.java101
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/jms/QueueCreator.java5
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/message/ConsumerParticipantResult.java4
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateConsumerCommand.java11
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateParticpantCommand.java11
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java42
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantResult.java54
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/message/ProducerParticipantResult.java4
-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/ParticipantResultAggregator.java11
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java24
-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.java85
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/VisitorTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientCommandVisitorTest.java4
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java15
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/MessageProviderTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java25
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantRegistryTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantResultFactoryTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java34
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/property/ListPropertyValueTest.java8
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/property/PropertyValueFactoryTest.java4
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RandomPropertyValueTest.java6
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RangePropertyValueTest.java6
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/property/SimplePropertyValueTest.java4
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithNoLimitsTest.java4
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java6
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/ClientRegistryTest.java44
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/ControllerTest.java10
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/ParticipatingClientsTest.java4
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/TestRunnerTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ClientConfigTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest-test-config.js22
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java9
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java4
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest-test-config.js22
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java7
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ParticipantConfigTest.java2
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/db/ResultsDbWriterTest.java158
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java11
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsTestFixture.java (renamed from java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java)64
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java5
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java30
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java4
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java45
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java62
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVOrderParticipantResultComparatorTest.java6
-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/QpidQueueCreatorTest.java42
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java6
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java13
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties3
80 files changed, 1660 insertions, 386 deletions
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/ArgumentParser.java b/java/perftests/src/main/java/org/apache/qpid/disttest/ArgumentParser.java
index 8c1f8675e3..e962bfe799 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/ArgumentParser.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/ArgumentParser.java
@@ -34,10 +34,14 @@ public class ArgumentParser
throw new IllegalArgumentException("arguments must have format <name>=<value>: " + arg);
}
- if(initialValues.put(splitArg[0], splitArg[1]) == null)
+
+ String argumentKey = splitArg[0];
+ String argumentValue = splitArg[1];
+ if(!initialValues.containsKey(argumentKey))
{
throw new IllegalArgumentException("not a valid configuration property: " + arg);
}
+ initialValues.put(argumentKey, argumentValue);
}
}
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..449130a328 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;
@@ -30,9 +30,9 @@ import org.apache.qpid.disttest.controller.Controller;
import org.apache.qpid.disttest.controller.ResultsForAllTests;
import org.apache.qpid.disttest.controller.config.Config;
import org.apache.qpid.disttest.controller.config.ConfigReader;
+import org.apache.qpid.disttest.db.ResultsDbWriter;
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;
@@ -43,20 +43,29 @@ public class ControllerRunner extends AbstractRunner
public static final String TEST_CONFIG_PROP = "test-config";
public static final String DISTRIBUTED_PROP = "distributed";
public static final String OUTPUT_DIR_PROP = "outputdir";
+ public static final String WRITE_TO_DB = "writeToDb";
+ public static final String RUN_ID = "runId";
private static final String TEST_CONFIG_DEFAULT = "perftests-config.json";
private static final String DISTRIBUTED_DEFAULT = "false";
private static final String OUTPUT_DIR_DEFAULT = ".";
+ public static final String WRITE_TO_DB_DEFAULT = "false";
private final Aggregator _aggregator = new Aggregator();
private final ConfigFileHelper _configFileHelper = new ConfigFileHelper();
+ private ResultsFileWriter _resultsFileWriter;
+
+ private ResultsDbWriter _resultsDbWriter;
+
public ControllerRunner()
{
getCliOptions().put(TEST_CONFIG_PROP, TEST_CONFIG_DEFAULT);
getCliOptions().put(DISTRIBUTED_PROP, DISTRIBUTED_DEFAULT);
getCliOptions().put(OUTPUT_DIR_PROP, OUTPUT_DIR_DEFAULT);
+ getCliOptions().put(WRITE_TO_DB, WRITE_TO_DB_DEFAULT);
+ getCliOptions().put(RUN_ID, null);
}
public static void main(String[] args) throws Exception
@@ -69,6 +78,8 @@ public class ControllerRunner extends AbstractRunner
public void runController() throws Exception
{
Context context = getContext();
+ setUpResultFilesWriter();
+ setUpResultsDbWriter();
ControllerJmsDelegate jmsDelegate = new ControllerJmsDelegate(context);
@@ -82,6 +93,24 @@ public class ControllerRunner extends AbstractRunner
}
}
+ private void setUpResultsDbWriter()
+ {
+ String writeToDbStr = getCliOptions().get(WRITE_TO_DB);
+ if(Boolean.valueOf(writeToDbStr))
+ {
+ String runId = getCliOptions().get(RUN_ID);
+ _resultsDbWriter = new ResultsDbWriter(getContext(), runId);
+ _resultsDbWriter.createResultsTableIfNecessary();
+ }
+ }
+
+ void setUpResultFilesWriter()
+ {
+ String outputDirString = getCliOptions().get(ControllerRunner.OUTPUT_DIR_PROP);
+ File outputDir = new File(outputDirString);
+ _resultsFileWriter = new ResultsFileWriter(outputDir);
+ }
+
private void runTests(ControllerJmsDelegate jmsDelegate)
{
Controller controller = new Controller(jmsDelegate, DistributedTestConstants.REGISTRATION_TIMEOUT, DistributedTestConstants.COMMAND_RESPONSE_TIMEOUT);
@@ -92,6 +121,8 @@ public class ControllerRunner extends AbstractRunner
try
{
+ List<ResultsForAllTests> results = new ArrayList<ResultsForAllTests>();
+
for (String testConfigFile : testConfigFiles)
{
final Config testConfig = buildTestConfigFrom(testConfigFile);
@@ -100,8 +131,11 @@ public class ControllerRunner extends AbstractRunner
controller.awaitClientRegistrations();
LOGGER.info("Running test : " + testConfigFile);
- runTest(controller, testConfigFile);
+ ResultsForAllTests testResult = runTest(controller, testConfigFile);
+ results.add(testResult);
}
+
+ _resultsFileWriter.writeResultsSummary(results);
}
catch(Exception e)
{
@@ -113,7 +147,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 +155,13 @@ 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);
+ _resultsFileWriter.writeResultsToFile(resultsForAllTests, testConfigFile);
+ if(_resultsDbWriter != null)
+ {
+ _resultsDbWriter.writeResults(resultsForAllTests);
+ }
+
+ return resultsForAllTests;
}
private void createClientsIfNotDistributed(final List<String> testConfigFiles)
@@ -148,36 +186,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/client/ConsumerParticipant.java b/java/perftests/src/main/java/org/apache/qpid/disttest/client/ConsumerParticipant.java
index f9d50e8e64..d3a5e30191 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/client/ConsumerParticipant.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/client/ConsumerParticipant.java
@@ -35,7 +35,6 @@ import javax.jms.MessageListener;
import org.apache.qpid.disttest.DistributedTestException;
import org.apache.qpid.disttest.jms.ClientJmsDelegate;
-import org.apache.qpid.disttest.message.ConsumerParticipantResult;
import org.apache.qpid.disttest.message.CreateConsumerCommand;
import org.apache.qpid.disttest.message.ParticipantResult;
import org.slf4j.Logger;
@@ -103,16 +102,22 @@ public class ConsumerParticipant implements Participant
}
Date end = new Date();
- int numberOfMessagesSent = _totalNumberOfMessagesReceived.get();
+ int numberOfMessagesReceived = _totalNumberOfMessagesReceived.get();
long totalPayloadSize = _totalPayloadSizeOfAllMessagesReceived.get();
int payloadSize = getPayloadSizeForResultIfConstantOrZeroOtherwise(_allConsumedPayloadSizes);
- ConsumerParticipantResult result = _resultFactory.createForConsumer(
+ if (LOGGER.isInfoEnabled())
+ {
+ LOGGER.info("Consumer {} finished consuming. Number of messages consumed: {}",
+ getName(), numberOfMessagesReceived);
+ }
+
+ ParticipantResult result = _resultFactory.createForConsumer(
getName(),
registeredClientName,
_command,
acknowledgeMode,
- numberOfMessagesSent,
+ numberOfMessagesReceived,
payloadSize,
totalPayloadSize,
start, end, _messageLatencies);
@@ -174,7 +179,7 @@ public class ConsumerParticipant implements Participant
{
LOGGER.trace("Committing: batch size " + _command.getBatchSize() );
}
- _jmsDelegate.commitOrAcknowledgeMessage(message, _command.getSessionName());
+ _jmsDelegate.commitOrAcknowledgeMessageIfNecessary(_command.getSessionName(), message);
}
}
@@ -199,7 +204,7 @@ public class ConsumerParticipant implements Participant
}
// commit/acknowledge remaining messages if necessary
- _jmsDelegate.commitOrAcknowledgeMessage(message, _command.getSessionName());
+ _jmsDelegate.commitOrAcknowledgeMessageIfNecessary(_command.getSessionName(), message);
}
return false;
}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java b/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java
index bb9ce26f7e..10f62708a4 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java
@@ -108,8 +108,16 @@ public class ParticipantExecutor
}
finally
{
+ try
+ {
+ _participant.releaseResources();
+ }
+ catch(Exception e)
+ {
+ LOGGER.error("Participant " + _participant + " unable to release resources", e);
+ }
+
_client.sendResults(result);
- _participant.releaseResources();
}
}
}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java b/java/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java
index 63cbe98b5c..a9da837dea 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java
@@ -58,17 +58,25 @@ public class ProducerParticipant implements Participant
@Override
public ParticipantResult doIt(String registeredClientName) throws Exception
{
- if (_command.getMaximumDuration() == 0 && _command.getNumberOfMessages() == 0)
+ long numberOfMessages = _command.getNumberOfMessages();
+ long maximumDuration = _command.getMaximumDuration();
+
+ if (maximumDuration == 0 && numberOfMessages == 0)
{
throw new DistributedTestException("number of messages and duration cannot both be zero");
}
- int acknowledgeMode = _jmsDelegate.getAcknowledgeMode(_command.getSessionName());
+ long duration = maximumDuration - _command.getStartDelay();
+ if (maximumDuration > 0 && duration <= 0)
+ {
+ throw new DistributedTestException("Start delay must be less than maximum test duration");
+ }
+ final long requiredDuration = duration > 0 ? duration : 0;
doSleepForStartDelay();
- final long requiredDuration = _command.getMaximumDuration() - _command.getStartDelay();
-
+ final int batchSize = _command.getBatchSize();
+ final int acknowledgeMode = _jmsDelegate.getAcknowledgeMode(_command.getSessionName());
final long startTime = System.currentTimeMillis();
Message lastPublishedMessage = null;
@@ -78,10 +86,20 @@ public class ProducerParticipant implements Participant
_limiter = ExecutorWithLimitsFactory.createExecutorWithLimit(startTime, requiredDuration);
- LOGGER.info("Producer {} about to send messages", getName());
+ if (LOGGER.isInfoEnabled())
+ {
+ LOGGER.info("Producer {} about to send messages. Duration limit: {} ms, Message limit: {}",
+ new Object[]{getName(), requiredDuration, numberOfMessages});
+ }
while (true)
{
+ if (numberOfMessages > 0 && numberOfMessagesSent >= numberOfMessages
+ || requiredDuration > 0 && System.currentTimeMillis() - startTime >= requiredDuration)
+ {
+ break;
+ }
+
try
{
lastPublishedMessage = _limiter.execute(new Callable<Message>()
@@ -110,35 +128,35 @@ public class ProducerParticipant implements Participant
LOGGER.trace("message " + numberOfMessagesSent + " sent by " + this);
}
- final boolean batchLimitReached = _command.getBatchSize() <= 0
- || numberOfMessagesSent % _command.getBatchSize() == 0;
+ final boolean batchLimitReached = batchSize <= 0
+ || numberOfMessagesSent % batchSize == 0;
if (batchLimitReached)
{
- if (LOGGER.isTraceEnabled() && _command.getBatchSize() > 0)
+ if (LOGGER.isTraceEnabled() && batchSize > 0)
{
- LOGGER.trace("Committing: batch size " + _command.getBatchSize() );
+ LOGGER.trace("Committing: batch size " + batchSize );
}
- _jmsDelegate.commitOrAcknowledgeMessage(lastPublishedMessage, _command.getSessionName());
+ _jmsDelegate.commitIfNecessary(_command.getSessionName());
doSleepForInterval();
}
-
- if (_command.getNumberOfMessages() > 0 && numberOfMessagesSent >= _command.getNumberOfMessages()
- || requiredDuration > 0 && System.currentTimeMillis() - startTime >= requiredDuration)
- {
- break;
- }
}
// commit the remaining batch messages
- if (_command.getBatchSize() > 0 && numberOfMessagesSent % _command.getBatchSize() != 0)
+ if (batchSize > 0 && numberOfMessagesSent % batchSize != 0)
{
if (LOGGER.isTraceEnabled())
{
- LOGGER.trace("Committing: batch size " + _command.getBatchSize() );
+ LOGGER.trace("Committing: batch size " + batchSize );
}
- _jmsDelegate.commitOrAcknowledgeMessage(lastPublishedMessage, _command.getSessionName());
+ _jmsDelegate.commitIfNecessary(_command.getSessionName());
+ }
+
+ if (LOGGER.isInfoEnabled())
+ {
+ LOGGER.info("Producer {} finished publishing. Number of messages published: {}",
+ getName(), numberOfMessagesSent);
}
Date start = new Date(startTime);
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ClientRegistry.java b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ClientRegistry.java
index eaccb54f0e..5a726c50b4 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ClientRegistry.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ClientRegistry.java
@@ -57,34 +57,54 @@ public class ClientRegistry
return Collections.unmodifiableSet(_registeredClientNames);
}
- public int awaitClients(int numberOfClientsToAwait, long timeout)
+ /**
+ * @return the number of clients that are still absent.
+ */
+ public int awaitClients(final int numberOfClientsToAwait, final long idleTimeout)
{
- final long endTime = System.currentTimeMillis() + timeout;
+ long deadlineForNextRegistration = deadline(idleTimeout);
- int numberOfClientsAbsent = numberOfClientsToAwait - _registeredClientNames.size();
- long remainingTimeout = endTime - System.currentTimeMillis();
+ int numberOfClientsAbsent = numberAbsent(numberOfClientsToAwait);
- while(numberOfClientsAbsent > 0 && remainingTimeout > 0)
+ while(numberOfClientsAbsent > 0 && System.currentTimeMillis() < deadlineForNextRegistration)
{
synchronized (_lock)
{
try
{
- _lock.wait(remainingTimeout);
+ _lock.wait(idleTimeout);
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
+ return numberOfClientsAbsent;
}
}
- numberOfClientsAbsent = numberOfClientsToAwait - _registeredClientNames.size();
- remainingTimeout = endTime - System.currentTimeMillis();
+ int newNumberAbsent = numberAbsent(numberOfClientsToAwait);
+ if(newNumberAbsent < numberOfClientsAbsent)
+ {
+ // a registration was received since the last loop, so reset the timeout
+ deadlineForNextRegistration = deadline(idleTimeout);
+ }
+
+ numberOfClientsAbsent = newNumberAbsent;
}
return numberOfClientsAbsent < 0 ? 0 : numberOfClientsAbsent;
}
+
+ private long deadline(final long idleTimeout)
+ {
+ return System.currentTimeMillis() + idleTimeout;
+ }
+
+ private int numberAbsent(int numberOfClientsToAwait)
+ {
+ return numberOfClientsToAwait - _registeredClientNames.size();
+ }
+
private void notifyAllWaiters()
{
synchronized (_lock)
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/controller/config/ConsumerConfig.java b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ConsumerConfig.java
index 110de8a4ea..dcccccdd5f 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ConsumerConfig.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ConsumerConfig.java
@@ -24,7 +24,6 @@ import org.apache.qpid.disttest.message.CreateConsumerCommand;
public class ConsumerConfig extends ParticipantConfig
{
- private boolean _isTopic;
private boolean _isDurableSubscription;
private boolean _isBrowsingSubscription;
private String _selector;
@@ -35,7 +34,6 @@ public class ConsumerConfig extends ParticipantConfig
// For Gson
public ConsumerConfig()
{
- _isTopic = false;
_isDurableSubscription = false;
_isBrowsingSubscription = false;
_selector = null;
@@ -56,9 +54,8 @@ public class ConsumerConfig extends ParticipantConfig
boolean noLocal,
boolean synchronous)
{
- super(consumerName, destinationName, numberOfMessages, batchSize, maximumDuration);
+ super(consumerName, destinationName, isTopic, numberOfMessages, batchSize, maximumDuration);
- _isTopic = isTopic;
_isDurableSubscription = isDurableSubscription;
_isBrowsingSubscription = isBrowsingSubscription;
_selector = selector;
@@ -73,7 +70,6 @@ public class ConsumerConfig extends ParticipantConfig
setParticipantProperties(createConsumerCommand);
createConsumerCommand.setSessionName(sessionName);
- createConsumerCommand.setTopic(_isTopic);
createConsumerCommand.setDurableSubscription(_isDurableSubscription);
createConsumerCommand.setBrowsingSubscription(_isBrowsingSubscription);
createConsumerCommand.setSelector(_selector);
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ParticipantConfig.java b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ParticipantConfig.java
index 16f7b0d18d..99ae4b7426 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ParticipantConfig.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ParticipantConfig.java
@@ -33,6 +33,7 @@ public abstract class ParticipantConfig
private boolean _alreadyLoggedAboutOverriddenDuration;
private String _destinationName;
+ private boolean _isTopic;
private long _numberOfMessages;
private String _name;
private int _batchSize;
@@ -51,12 +52,14 @@ public abstract class ParticipantConfig
public ParticipantConfig(
String name,
String destinationName,
+ boolean isTopic,
long numberOfMessages,
int batchSize,
long maximumDuration)
{
_name = name;
_destinationName = destinationName;
+ _isTopic = isTopic;
_numberOfMessages = numberOfMessages;
_batchSize = batchSize;
_maximumDuration = maximumDuration;
@@ -66,6 +69,7 @@ public abstract class ParticipantConfig
{
createParticipantCommand.setParticipantName(_name);
createParticipantCommand.setDestinationName(_destinationName);
+ createParticipantCommand.setTopic(_isTopic);
createParticipantCommand.setNumberOfMessages(_numberOfMessages);
createParticipantCommand.setBatchSize(_batchSize);
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ProducerConfig.java b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ProducerConfig.java
index f2369ed671..88c188d3ac 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ProducerConfig.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ProducerConfig.java
@@ -59,7 +59,7 @@ public class ProducerConfig extends ParticipantConfig
long startDelay,
String messageProviderName)
{
- super(producerName, destinationName, numberOfMessages, batchSize, maximumDuration);
+ super(producerName, destinationName, false, numberOfMessages, batchSize, maximumDuration);
_deliveryMode = deliveryMode;
_messageSize = messageSize;
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/db/ResultsDbWriter.java b/java/perftests/src/main/java/org/apache/qpid/disttest/db/ResultsDbWriter.java
new file mode 100644
index 0000000000..fdea03ae5e
--- /dev/null
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/db/ResultsDbWriter.java
@@ -0,0 +1,467 @@
+/*
+ * 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.db;
+
+import static org.apache.qpid.disttest.message.ParticipantAttribute.ACKNOWLEDGE_MODE;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.AVERAGE_LATENCY;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.BATCH_SIZE;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.CONFIGURED_CLIENT_NAME;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.DELIVERY_MODE;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.ERROR_MESSAGE;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_BROWSING_SUBSCRIPTION;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_DURABLE_SUBSCRIPTION;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_NO_LOCAL;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_SELECTOR;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_SYNCHRONOUS_CONSUMER;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_TOPIC;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.ITERATION_NUMBER;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.LATENCY_STANDARD_DEVIATION;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.MAXIMUM_DURATION;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.MAX_LATENCY;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.MIN_LATENCY;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.PARTICIPANT_NAME;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.PRIORITY;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.PRODUCER_INTERVAL;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.PRODUCER_START_DELAY;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.TEST_NAME;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.THROUGHPUT;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.TIME_TAKEN;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.TIME_TO_LIVE;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.TOTAL_NUMBER_OF_CONSUMERS;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.TOTAL_NUMBER_OF_PRODUCERS;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.TOTAL_PAYLOAD_PROCESSED;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.TimeZone;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+import org.apache.log4j.Logger;
+import org.apache.qpid.disttest.controller.ResultsForAllTests;
+import org.apache.qpid.disttest.message.ParticipantResult;
+import org.apache.qpid.disttest.results.aggregation.ITestResult;
+
+/**
+ * Intended call sequence:
+ * <ul>
+ * <li>{@link #ResultsDbWriter(Context, String)}</li>
+ * <li>{@link #createResultsTableIfNecessary()}</li>
+ * <li>{@link #writeResults(ResultsForAllTests)} (usually multiple times)</li>
+ * </ul>
+ */
+public class ResultsDbWriter
+{
+ private static final Logger _logger = Logger.getLogger(ResultsDbWriter.class);
+
+ private static final String RESULTS_TABLE_NAME = "RESULTS";
+
+ /** column name */
+ static final String INSERTED_TIMESTAMP = "insertedTimestamp";
+ /** column name */
+ static final String RUN_ID = "runId";
+
+ private static final String TABLE_EXISTENCE_QUERY = "SELECT 1 FROM SYS.SYSTABLES WHERE TABLENAME = ?";
+
+ private static final String CREATE_RESULTS_TABLE = String.format(
+ "CREATE TABLE %1$s (" +
+ "%2$s varchar(200) not null" + // TEST_NAME
+ ", %3$s bigint not null" + // ITERATION_NUMBER
+ ", %4$s varchar(200) not null" + // PARTICIPANT_NAME
+ ", %5$s double not null" + // THROUGHPUT
+ ", %6$s double" + // AVERAGE_LATENCY
+ ", %7$s varchar(200)" + // CONFIGURED_CLIENT_NAME
+ ", %8$s bigint" + // NUMBER_OF_MESSAGES_PROCESSED
+ ", %9$s bigint" + // PAYLOAD_SIZE
+ ", %10$s bigint" + // PRIORITY
+ ", %11$s bigint" + // TIME_TO_LIVE
+ ", %12$s bigint" + // ACKNOWLEDGE_MODE
+ ", %13$s bigint" + // DELIVERY_MODE
+ ", %14$s bigint" + // BATCH_SIZE
+ ", %15$s bigint" + // MAXIMUM_DURATION
+ ", %16$s bigint" + // PRODUCER_START_DELAY
+ ", %17$s bigint" + // PRODUCER_INTERVAL
+ ", %18$s bigint" + // IS_TOPIC
+ ", %19$s bigint" + // IS_DURABLE_SUBSCRIPTION
+ ", %20$s bigint" + // IS_BROWSING_SUBSCRIPTION
+ ", %21$s bigint" + // IS_SELECTOR
+ ", %22$s bigint" + // IS_NO_LOCAL
+ ", %23$s bigint" + // IS_SYNCHRONOUS_CONSUMER
+ ", %24$s bigint" + // TOTAL_NUMBER_OF_CONSUMERS
+ ", %25$s bigint" + // TOTAL_NUMBER_OF_PRODUCERS
+ ", %26$s bigint" + // TOTAL_PAYLOAD_PROCESSED
+ ", %27$s bigint" + // TIME_TAKEN
+ ", %28$s varchar(2000)" + // ERROR_MESSAGE
+ ", %29$s bigint" + // MIN_LATENCY
+ ", %30$s bigint" + // MAX_LATENCY
+ ", %31$s double" + // LATENCY_STANDARD_DEVIATION
+ ", %32$s varchar(200) not null" +
+ ", %33$s timestamp not null" +
+ ")",
+ RESULTS_TABLE_NAME,
+ TEST_NAME.getDisplayName(),
+ ITERATION_NUMBER.getDisplayName(),
+ PARTICIPANT_NAME.getDisplayName(),
+ THROUGHPUT.getDisplayName(),
+ AVERAGE_LATENCY.getDisplayName(),
+ CONFIGURED_CLIENT_NAME.getDisplayName(),
+ NUMBER_OF_MESSAGES_PROCESSED.getDisplayName(),
+ PAYLOAD_SIZE.getDisplayName(),
+ PRIORITY.getDisplayName(),
+ TIME_TO_LIVE.getDisplayName(),
+ ACKNOWLEDGE_MODE.getDisplayName(),
+ DELIVERY_MODE.getDisplayName(),
+ BATCH_SIZE.getDisplayName(),
+ MAXIMUM_DURATION.getDisplayName(),
+ PRODUCER_START_DELAY.getDisplayName(),
+ PRODUCER_INTERVAL.getDisplayName(),
+ IS_TOPIC.getDisplayName(),
+ IS_DURABLE_SUBSCRIPTION.getDisplayName(),
+ IS_BROWSING_SUBSCRIPTION.getDisplayName(),
+ IS_SELECTOR.getDisplayName(),
+ IS_NO_LOCAL.getDisplayName(),
+ IS_SYNCHRONOUS_CONSUMER.getDisplayName(),
+ TOTAL_NUMBER_OF_CONSUMERS.getDisplayName(),
+ TOTAL_NUMBER_OF_PRODUCERS.getDisplayName(),
+ TOTAL_PAYLOAD_PROCESSED.getDisplayName(),
+ TIME_TAKEN.getDisplayName(),
+ ERROR_MESSAGE.getDisplayName(),
+ MIN_LATENCY.getDisplayName(),
+ MAX_LATENCY.getDisplayName(),
+ LATENCY_STANDARD_DEVIATION.getDisplayName(),
+ RUN_ID,
+ INSERTED_TIMESTAMP
+ );
+
+ public static final String DRIVER_NAME = "jdbcDriverClass";
+ public static final String URL = "jdbcUrl";
+
+ private final String _url;
+ private final String _runId;
+
+ private final Clock _clock;
+
+ /**
+ * @param runId may be null, in which case a default value is chosen based on current GMT time
+ * @param context must contain environment entries {@value #DRIVER_NAME} and {@value #URL}.
+ */
+ public ResultsDbWriter(Context context, String runId)
+ {
+ this(context, runId, new Clock());
+ }
+
+ /** only call directly from tests */
+ ResultsDbWriter(Context context, String runId, Clock clock)
+ {
+ _clock = clock;
+ _runId = defaultIfNullRunId(runId);
+
+ _url = initialiseJdbc(context);
+ }
+
+ private String defaultIfNullRunId(String runId)
+ {
+ if(runId == null)
+ {
+ Date dateNow = new Date(_clock.currentTimeMillis());
+ Calendar calNow = Calendar.getInstance(TimeZone.getTimeZone("GMT+00:00"));
+ calNow.setTime(dateNow);
+ return String.format("run %1$tF %1$tT.%tL", calNow);
+ }
+ else
+ {
+ return runId;
+ }
+ }
+
+ public String getRunId()
+ {
+ return _runId;
+ }
+
+ /**
+ * Uses the context's environment to load the JDBC driver class and return the
+ * JDBC URL specified therein.
+ * @return the JDBC URL
+ */
+ private String initialiseJdbc(Context context)
+ {
+ Hashtable<?, ?> environment = null;
+ try
+ {
+ environment = context.getEnvironment();
+
+ String driverName = (String) environment.get(DRIVER_NAME);
+ if(driverName == null)
+ {
+ throw new IllegalArgumentException("JDBC driver name " + DRIVER_NAME
+ + " missing from context environment: " + environment);
+ }
+
+ Class.forName(driverName);
+
+ Object url = environment.get(URL);
+ if(url == null)
+ {
+ throw new IllegalArgumentException("JDBC URL " + URL + " missing from context environment: " + environment);
+ }
+ return (String) url;
+ }
+ catch (NamingException e)
+ {
+ throw constructorRethrow(e, environment);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw constructorRethrow(e, environment);
+ }
+ }
+
+ private RuntimeException constructorRethrow(Exception e, Hashtable<?, ?> environment)
+ {
+ return new RuntimeException("Couldn't initialise ResultsDbWriter from context with environment" + environment, e);
+ }
+
+ public void createResultsTableIfNecessary()
+ {
+ try
+ {
+ Connection connection = null;
+ try
+ {
+ connection = DriverManager.getConnection(_url);
+ if(!tableExists(RESULTS_TABLE_NAME, connection))
+ {
+ Statement statement = connection.createStatement();
+ try
+ {
+ _logger.info("About to create results table using SQL: " + CREATE_RESULTS_TABLE);
+ statement.execute(CREATE_RESULTS_TABLE);
+ }
+ finally
+ {
+ statement.close();
+ }
+ }
+ }
+ finally
+ {
+ if(connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RuntimeException("Couldn't create results table", e);
+ }
+
+ }
+
+ private boolean tableExists(final String tableName, final Connection conn) throws SQLException
+ {
+ PreparedStatement stmt = conn.prepareStatement(TABLE_EXISTENCE_QUERY);
+ try
+ {
+ stmt.setString(1, tableName);
+ ResultSet rs = stmt.executeQuery();
+ try
+ {
+ return rs.next();
+ }
+ finally
+ {
+ rs.close();
+ }
+ }
+ finally
+ {
+ stmt.close();
+ }
+ }
+
+ public void writeResults(ResultsForAllTests results)
+ {
+ try
+ {
+ writeResultsThrowingException(results);
+ }
+ catch (SQLException e)
+ {
+ throw new RuntimeException("Couldn't write results " + results, e);
+ }
+ _logger.info(this + " wrote " + results.getTestResults().size() + " results to database");
+ }
+
+ private void writeResultsThrowingException(ResultsForAllTests results) throws SQLException
+ {
+ Connection connection = null;
+ try
+ {
+ connection = DriverManager.getConnection(_url);
+
+ for (ITestResult testResult : results.getTestResults())
+ {
+ for (ParticipantResult participantResult : testResult.getParticipantResults())
+ {
+ writeParticipantResult(connection, participantResult);
+ }
+ }
+ }
+ finally
+ {
+ if(connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+
+ private void writeParticipantResult(Connection connection, ParticipantResult participantResult) throws SQLException
+ {
+ if(_logger.isDebugEnabled())
+ {
+ _logger.debug("About to write to DB the following participant result: " + participantResult);
+ }
+
+ PreparedStatement statement = null;
+ try
+ {
+ String sqlTemplate = String.format(
+ "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) " +
+ "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ RESULTS_TABLE_NAME,
+ TEST_NAME.getDisplayName(),
+ ITERATION_NUMBER.getDisplayName(),
+ PARTICIPANT_NAME.getDisplayName(),
+ THROUGHPUT.getDisplayName(),
+ AVERAGE_LATENCY.getDisplayName(),
+ CONFIGURED_CLIENT_NAME.getDisplayName(),
+ NUMBER_OF_MESSAGES_PROCESSED.getDisplayName(),
+ PAYLOAD_SIZE.getDisplayName(),
+ PRIORITY.getDisplayName(),
+ TIME_TO_LIVE.getDisplayName(),
+ ACKNOWLEDGE_MODE.getDisplayName(),
+ DELIVERY_MODE.getDisplayName(),
+ BATCH_SIZE.getDisplayName(),
+ MAXIMUM_DURATION.getDisplayName(),
+ PRODUCER_START_DELAY.getDisplayName(),
+ PRODUCER_INTERVAL.getDisplayName(),
+ IS_TOPIC.getDisplayName(),
+ IS_DURABLE_SUBSCRIPTION.getDisplayName(),
+ IS_BROWSING_SUBSCRIPTION.getDisplayName(),
+ IS_SELECTOR.getDisplayName(),
+ IS_NO_LOCAL.getDisplayName(),
+ IS_SYNCHRONOUS_CONSUMER.getDisplayName(),
+ TOTAL_NUMBER_OF_CONSUMERS.getDisplayName(),
+ TOTAL_NUMBER_OF_PRODUCERS.getDisplayName(),
+ TOTAL_PAYLOAD_PROCESSED.getDisplayName(),
+ TIME_TAKEN.getDisplayName(),
+ ERROR_MESSAGE.getDisplayName(),
+ MIN_LATENCY.getDisplayName(),
+ MAX_LATENCY.getDisplayName(),
+ LATENCY_STANDARD_DEVIATION.getDisplayName(),
+ RUN_ID,
+ INSERTED_TIMESTAMP
+ );
+ statement = connection.prepareStatement(sqlTemplate);
+
+ int columnIndex = 1;
+ statement.setString(columnIndex++, participantResult.getTestName());
+ statement.setInt(columnIndex++, participantResult.getIterationNumber());
+ statement.setString(columnIndex++, participantResult.getParticipantName());
+ statement.setDouble(columnIndex++, participantResult.getThroughput());
+ statement.setDouble(columnIndex++, participantResult.getAverageLatency());
+ statement.setString(columnIndex++, participantResult.getConfiguredClientName());
+ statement.setLong(columnIndex++, participantResult.getNumberOfMessagesProcessed());
+ statement.setLong(columnIndex++, participantResult.getPayloadSize());
+ statement.setLong(columnIndex++, participantResult.getPriority());
+ statement.setLong(columnIndex++, participantResult.getTimeToLive());
+ statement.setLong(columnIndex++, participantResult.getAcknowledgeMode());
+ statement.setLong(columnIndex++, participantResult.getDeliveryMode());
+ statement.setLong(columnIndex++, participantResult.getBatchSize());
+ statement.setLong(columnIndex++, participantResult.getMaximumDuration());
+ statement.setLong(columnIndex++, 0 /* TODO PRODUCER_START_DELAY*/);
+ statement.setLong(columnIndex++, 0 /* TODO PRODUCER_INTERVAL*/);
+ statement.setLong(columnIndex++, 0 /* TODO IS_TOPIC*/);
+ statement.setLong(columnIndex++, 0 /* TODO IS_DURABLE_SUBSCRIPTION*/);
+ statement.setLong(columnIndex++, 0 /* TODO IS_BROWSING_SUBSCRIPTION*/);
+ statement.setLong(columnIndex++, 0 /* TODO IS_SELECTOR*/);
+ statement.setLong(columnIndex++, 0 /* TODO IS_NO_LOCAL*/);
+ statement.setLong(columnIndex++, 0 /* TODO IS_SYNCHRONOUS_CONSUMER*/);
+ statement.setLong(columnIndex++, participantResult.getTotalNumberOfConsumers());
+ statement.setLong(columnIndex++, participantResult.getTotalNumberOfProducers());
+ statement.setLong(columnIndex++, participantResult.getTotalPayloadProcessed());
+ statement.setLong(columnIndex++, participantResult.getTimeTaken());
+ statement.setString(columnIndex++, participantResult.getErrorMessage());
+ statement.setLong(columnIndex++, participantResult.getMinLatency());
+ statement.setLong(columnIndex++, participantResult.getMaxLatency());
+ statement.setDouble(columnIndex++, participantResult.getLatencyStandardDeviation());
+
+ statement.setString(columnIndex++, _runId);
+ statement.setTimestamp(columnIndex++, new Timestamp(_clock.currentTimeMillis()));
+
+ statement.execute();
+ connection.commit();
+ }
+ catch(SQLException e)
+ {
+ _logger.error("Couldn't write " + participantResult, e);
+ }
+ finally
+ {
+ if (statement != null)
+ {
+ statement.close();
+ }
+ }
+ }
+
+ public static class Clock
+ {
+ public long currentTimeMillis()
+ {
+ return System.currentTimeMillis();
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
+ .append("runId", _runId)
+ .append("url", _url)
+ .toString();
+ }
+}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ClientJmsDelegate.java b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ClientJmsDelegate.java
index 3f8afc9a9a..f242111dc5 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ClientJmsDelegate.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ClientJmsDelegate.java
@@ -218,7 +218,15 @@ public class ClientJmsDelegate
synchronized(session)
{
- final Destination destination = session.createQueue(command.getDestinationName());
+ final Destination destination;
+ if(command.isTopic())
+ {
+ destination = session.createTopic(command.getDestinationName());
+ }
+ else
+ {
+ destination = session.createQueue(command.getDestinationName());
+ }
final MessageProducer jmsProducer = session.createProducer(destination);
@@ -373,30 +381,6 @@ public class ClientJmsDelegate
}
}
- public void commitOrAcknowledgeMessage(final Message message, final String sessionName)
- {
- try
- {
- final Session session = _testSessions.get(sessionName);
- if (session.getTransacted())
- {
- synchronized(session)
- {
- session.commit();
- }
- }
- else if (message != null && session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE)
- {
- message.acknowledge();
- }
- }
- catch (final JMSException jmse)
- {
- throw new DistributedTestException("Unable to commit or acknowledge message on session: " +
- sessionName, jmse);
- }
- }
-
public int getAcknowledgeMode(final String sessionName)
{
try
@@ -493,31 +477,36 @@ public class ClientJmsDelegate
}
}
- public void rollbackOrRecover(String sessionName)
+ public void commitOrAcknowledgeMessageIfNecessary(final String sessionName, final Message message)
{
try
{
final Session session = _testSessions.get(sessionName);
- synchronized(session)
+ if (session.getTransacted())
{
- if (session.getTransacted())
- {
- session.rollback();
- }
- else if (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE)
+ synchronized(session)
{
- session.recover();
+ session.commit();
}
}
+ else if (message != null && session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE)
+ {
+ message.acknowledge();
+ }
}
catch (final JMSException jmse)
{
- throw new DistributedTestException("Unable to rollback or recover on session: " +
+ throw new DistributedTestException("Unable to commit or acknowledge message on session: " +
sessionName, jmse);
}
}
- public void releaseMessage(String sessionName)
+ public void commitIfNecessary(final String sessionName)
+ {
+ commitOrAcknowledgeMessageIfNecessary(sessionName, null);
+ }
+
+ public void rollbackOrRecoverIfNecessary(String sessionName)
{
try
{
@@ -528,7 +517,7 @@ public class ClientJmsDelegate
{
session.rollback();
}
- else
+ else if (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE)
{
session.recover();
}
@@ -536,7 +525,8 @@ public class ClientJmsDelegate
}
catch (final JMSException jmse)
{
- LOGGER.warn("Unable to rollback or recover on session: " + sessionName, jmse);
+ throw new DistributedTestException("Unable to rollback or recover on session: " +
+ sessionName, jmse);
}
}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ControllerJmsDelegate.java b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ControllerJmsDelegate.java
index c80e641e5c..782f7ae2fd 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ControllerJmsDelegate.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ControllerJmsDelegate.java
@@ -224,12 +224,12 @@ public class ControllerJmsDelegate
public void createQueues(List<QueueConfig> queues)
{
- _queueCreator.createQueues(_session, queues);
+ _queueCreator.createQueues(_connection, _session, queues);
}
public void deleteQueues(List<QueueConfig> queues)
{
- _queueCreator.deleteQueues(_session, queues);
+ _queueCreator.deleteQueues(_connection, _session, queues);
}
public void addCommandListener(CommandListener commandListener)
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/NoOpQueueCreator.java b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/NoOpQueueCreator.java
index 4d4850eccf..d7e0007b28 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/NoOpQueueCreator.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/NoOpQueueCreator.java
@@ -20,18 +20,19 @@ package org.apache.qpid.disttest.jms;
import java.util.List;
+import javax.jms.Connection;
import javax.jms.Session;
import org.apache.qpid.disttest.controller.config.QueueConfig;
public class NoOpQueueCreator implements QueueCreator
{
@Override
- public void createQueues(Session session, List<QueueConfig> configs)
+ public void createQueues(Connection connection, Session session, List<QueueConfig> configs)
{
}
@Override
- public void deleteQueues(Session session, List<QueueConfig> configs)
+ public void deleteQueues(Connection connection, Session session, List<QueueConfig> configs)
{
}
}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidQueueCreator.java b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidQueueCreator.java
index 6874abe7d4..ef2cfb6cd4 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidQueueCreator.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidQueueCreator.java
@@ -20,21 +20,29 @@ package org.apache.qpid.disttest.jms;
import java.util.List;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
import javax.jms.Session;
+
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.disttest.DistributedTestException;
import org.apache.qpid.disttest.controller.config.QueueConfig;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.FieldTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
public class QpidQueueCreator implements QueueCreator
{
private static final Logger LOGGER = LoggerFactory.getLogger(QpidQueueCreator.class);
private static final FieldTable EMPTY_QUEUE_BIND_ARGUMENTS = new FieldTable();
+ private static final String QUEUE_CREATOR_DRAIN_POLL_TIMEOUT = "qpid.disttest.queue.creator.drainPollTime";
+ private static int _drainPollTimeout = Integer.getInteger(QUEUE_CREATOR_DRAIN_POLL_TIMEOUT, 500);
@Override
- public void createQueues(Session session, List<QueueConfig> configs)
+ public void createQueues(Connection connection, Session session, List<QueueConfig> configs)
{
AMQSession<?, ?> amqSession = (AMQSession<?, ?>)session;
for (QueueConfig queueConfig : configs)
@@ -44,12 +52,88 @@ public class QpidQueueCreator implements QueueCreator
}
@Override
- public void deleteQueues(Session session, List<QueueConfig> configs)
+ public void deleteQueues(Connection connection, Session session, List<QueueConfig> configs)
{
AMQSession<?, ?> amqSession = (AMQSession<?, ?>)session;
for (QueueConfig queueConfig : configs)
{
- deleteQueue(amqSession, queueConfig);
+ AMQDestination destination = createAMQDestination(amqSession, queueConfig);
+
+ // drainQueue method is added because deletion of queue with a lot
+ // of messages takes time and might cause the timeout exception
+ drainQueue(connection, destination);
+
+ deleteQueue(amqSession, destination.getAMQQueueName());
+ }
+ }
+
+ private AMQDestination createAMQDestination(AMQSession<?, ?> amqSession, QueueConfig queueConfig)
+ {
+ try
+ {
+ return (AMQDestination) amqSession.createQueue(queueConfig.getName());
+ }
+ catch (Exception e)
+ {
+ throw new DistributedTestException("Failed to create amq destionation object:" + queueConfig, e);
+ }
+ }
+
+ private long getQueueDepth(AMQSession<?, ?> amqSession, AMQDestination destination)
+ {
+ try
+ {
+ long queueDepth = amqSession.getQueueDepth(destination);
+ return queueDepth;
+ }
+ catch (Exception e)
+ {
+ throw new DistributedTestException("Failed to query queue depth:" + destination, e);
+ }
+ }
+
+ private void drainQueue(Connection connection, AMQDestination destination)
+ {
+ Session noAckSession = null;
+ try
+ {
+ LOGGER.debug("About to drain the queue {}", destination.getQueueName());
+ noAckSession = connection.createSession(false, org.apache.qpid.jms.Session.NO_ACKNOWLEDGE);
+ MessageConsumer messageConsumer = noAckSession.createConsumer(destination);
+
+ long currentQueueDepth = getQueueDepth((AMQSession<?,?>)noAckSession, destination);
+ int counter = 0;
+ while (currentQueueDepth > 0)
+ {
+ LOGGER.info("Queue {} has {} message(s)", destination.getQueueName(), currentQueueDepth);
+
+ while(messageConsumer.receive(_drainPollTimeout) != null)
+ {
+ counter++;
+ }
+
+ currentQueueDepth = getQueueDepth((AMQSession<?,?>)noAckSession, destination);
+ }
+ LOGGER.info("Drained {} message(s) from queue {} ", counter, destination.getQueueName());
+ messageConsumer.close();
+ }
+ catch (Exception e)
+ {
+ throw new DistributedTestException("Failed to drain queue:" + destination, e);
+ }
+ finally
+ {
+ if (noAckSession != null)
+ {
+ try
+ {
+ noAckSession.close();
+ }
+ catch (JMSException e)
+ {
+ throw new DistributedTestException("Failed to close n/a session:" + noAckSession, e);
+ }
+ }
}
}
@@ -66,7 +150,7 @@ public class QpidQueueCreator implements QueueCreator
EMPTY_QUEUE_BIND_ARGUMENTS, destination.getExchangeName(),
destination, autoDelete);
- LOGGER.debug("Created queue " + queueConfig);
+ LOGGER.debug("Created queue {}", queueConfig);
}
catch (Exception e)
{
@@ -74,20 +158,19 @@ public class QpidQueueCreator implements QueueCreator
}
}
- private void deleteQueue(AMQSession<?, ?> session, QueueConfig queueConfig)
+ private void deleteQueue(AMQSession<?, ?> session, AMQShortString queueName)
{
try
{
// The Qpid AMQSession API currently makes the #deleteQueue method protected and the
// raw protocol method public. This should be changed then we should switch the below to
// use #deleteQueue.
- AMQDestination destination = (AMQDestination) session.createQueue(queueConfig.getName());
- session.sendQueueDelete(destination.getAMQQueueName());
- LOGGER.debug("Deleted queue " + queueConfig.getName());
+ session.sendQueueDelete(queueName);
+ LOGGER.debug("Deleted queue {}", queueName);
}
catch (Exception e)
{
- throw new DistributedTestException("Failed to delete queue:" + queueConfig.getName(), e);
+ throw new DistributedTestException("Failed to delete queue:" + queueName, e);
}
}
}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QueueCreator.java b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QueueCreator.java
index 0947dd53cb..a37cd7888c 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QueueCreator.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QueueCreator.java
@@ -20,12 +20,13 @@ package org.apache.qpid.disttest.jms;
import java.util.List;
+import javax.jms.Connection;
import javax.jms.Session;
import org.apache.qpid.disttest.controller.config.QueueConfig;
public interface QueueCreator
{
- public void createQueues(final Session session, final List<QueueConfig> configs);
- public void deleteQueues(final Session session, final List<QueueConfig> configs);
+ void createQueues(Connection connection, Session session, List<QueueConfig> configs);
+ void deleteQueues(Connection connection, Session session, List<QueueConfig> configs);
}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ConsumerParticipantResult.java b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ConsumerParticipantResult.java
index ad9aa31472..e78f6965d2 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ConsumerParticipantResult.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ConsumerParticipantResult.java
@@ -134,6 +134,7 @@ public class ConsumerParticipantResult extends ParticipantResult
_messageLatencies = messageLatencies;
}
+ @Override
@OutputAttribute(attribute=ParticipantAttribute.MIN_LATENCY)
public long getMinLatency()
{
@@ -145,6 +146,7 @@ public class ConsumerParticipantResult extends ParticipantResult
_minLatency = minLatency;
}
+ @Override
@OutputAttribute(attribute=ParticipantAttribute.MAX_LATENCY)
public long getMaxLatency()
{
@@ -156,6 +158,7 @@ public class ConsumerParticipantResult extends ParticipantResult
_maxLatency = maxLatency;
}
+ @Override
@OutputAttribute(attribute=ParticipantAttribute.AVERAGE_LATENCY)
public double getAverageLatency()
{
@@ -167,6 +170,7 @@ public class ConsumerParticipantResult extends ParticipantResult
_averageLatency = averageLatency;
}
+ @Override
@OutputAttribute(attribute=ParticipantAttribute.LATENCY_STANDARD_DEVIATION)
public double getLatencyStandardDeviation()
{
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateConsumerCommand.java b/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateConsumerCommand.java
index 68c21fbf83..07a60504c8 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateConsumerCommand.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateConsumerCommand.java
@@ -21,7 +21,6 @@ package org.apache.qpid.disttest.message;
public class CreateConsumerCommand extends CreateParticpantCommand
{
- private boolean _isTopic;
private boolean _isDurableSubscription;
private boolean _isBrowsingSubscription;
private String _selector;
@@ -75,16 +74,6 @@ public class CreateConsumerCommand extends CreateParticpantCommand
this._noLocal = noLocal;
}
- public boolean isTopic()
- {
- return _isTopic;
- }
-
- public void setTopic(boolean isTopic)
- {
- this._isTopic = isTopic;
- }
-
public boolean isSynchronous()
{
return _synchronous;
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateParticpantCommand.java b/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateParticpantCommand.java
index b1caa6ef75..e7349bf795 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateParticpantCommand.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateParticpantCommand.java
@@ -23,6 +23,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
public abstract class CreateParticpantCommand extends Command
{
+ private boolean _isTopic;
private String _participantName;
private String _sessionName;
private String _destinationName;
@@ -65,6 +66,16 @@ public abstract class CreateParticpantCommand extends Command
_destinationName = destinationName;
}
+ public boolean isTopic()
+ {
+ return _isTopic;
+ }
+
+ public void setTopic(boolean isTopic)
+ {
+ _isTopic = isTopic;
+ }
+
public long getNumberOfMessages()
{
return _numberOfMessages;
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..1154ff306c 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,56 @@ 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")
+ LATENCY_STANDARD_DEVIATION("latencyStandardDeviation"),
+ MESSAGE_THROUGHPUT("throughputMessagesPerS")
;
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/message/ParticipantResult.java b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantResult.java
index a6d3d91bae..0a824a316b 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantResult.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantResult.java
@@ -22,11 +22,12 @@ import static org.apache.qpid.disttest.message.ParticipantAttribute.BATCH_SIZE;
import static org.apache.qpid.disttest.message.ParticipantAttribute.CONFIGURED_CLIENT_NAME;
import static org.apache.qpid.disttest.message.ParticipantAttribute.ITERATION_NUMBER;
import static org.apache.qpid.disttest.message.ParticipantAttribute.MAXIMUM_DURATION;
-import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.MESSAGE_THROUGHPUT;
import static org.apache.qpid.disttest.message.ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED;
-import static org.apache.qpid.disttest.message.ParticipantAttribute.THROUGHPUT;
import static org.apache.qpid.disttest.message.ParticipantAttribute.PARTICIPANT_NAME;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE;
import static org.apache.qpid.disttest.message.ParticipantAttribute.TEST_NAME;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.THROUGHPUT;
import java.util.Comparator;
import java.util.Date;
@@ -49,6 +50,7 @@ public class ParticipantResult extends Response
private long _totalPayloadProcessed;
private int _payloadSize;
private double _throughput;
+ private int _messageThroughput;
private int _totalNumberOfConsumers;
private int _totalNumberOfProducers;
@@ -236,6 +238,17 @@ public class ParticipantResult extends Response
_throughput = throughput;
}
+ @OutputAttribute(attribute=MESSAGE_THROUGHPUT)
+ public int getMessageThroughput()
+ {
+ return _messageThroughput;
+ }
+
+ public void setMessageThroughput(int throughput)
+ {
+ _messageThroughput = throughput;
+ }
+
public void setTotalNumberOfConsumers(int totalNumberOfConsumers)
{
_totalNumberOfConsumers = totalNumberOfConsumers;
@@ -269,4 +282,41 @@ public class ParticipantResult extends Response
_acknowledgeMode = acknowledgeMode;
}
+ public double getLatencyStandardDeviation()
+ {
+ return 0.0;
+ }
+
+ @OutputAttribute(attribute = ParticipantAttribute.MIN_LATENCY)
+ public long getMinLatency()
+ {
+ return 0;
+ }
+
+ @OutputAttribute(attribute = ParticipantAttribute.MAX_LATENCY)
+ public long getMaxLatency()
+ {
+ return 0;
+ }
+
+ @OutputAttribute(attribute = ParticipantAttribute.AVERAGE_LATENCY)
+ public double getAverageLatency()
+ {
+ return 0;
+ }
+
+ public int getPriority()
+ {
+ return 0;
+ }
+
+ public long getTimeToLive()
+ {
+ return 0;
+ }
+
+ public int getDeliveryMode()
+ {
+ return 0;
+ }
}
diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ProducerParticipantResult.java b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ProducerParticipantResult.java
index 766c90eec8..2d9399a3d3 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ProducerParticipantResult.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ProducerParticipantResult.java
@@ -42,6 +42,7 @@ public class ProducerParticipantResult extends ParticipantResult
setParticipantName(participantName);
}
+ @Override
@OutputAttribute(attribute=PRIORITY)
public int getPriority()
{
@@ -53,6 +54,7 @@ public class ProducerParticipantResult extends ParticipantResult
_priority = priority;
}
+ @Override
@OutputAttribute(attribute=TIME_TO_LIVE)
public long getTimeToLive()
{
@@ -86,6 +88,7 @@ public class ProducerParticipantResult extends ParticipantResult
_interval = producerInterval;
}
+ @Override
@OutputAttribute(attribute=DELIVERY_MODE)
public int getDeliveryMode()
{
@@ -96,5 +99,4 @@ public class ProducerParticipantResult extends ParticipantResult
{
this._deliveryMode = deliveryMode;
}
-
}
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/ParticipantResultAggregator.java b/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregator.java
index 4dcabe6c7b..c21a78d359 100644
--- a/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregator.java
+++ b/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregator.java
@@ -142,6 +142,7 @@ public class ParticipantResultAggregator
aggregatedResult.setStartDate(new Date(_minStartDate));
aggregatedResult.setEndDate(new Date(_maxEndDate));
aggregatedResult.setThroughput(calculateThroughputInKiloBytesPerSecond());
+ aggregatedResult.setMessageThroughput(calculateThroughputInMessagesPerSecond());
}
private void setRolledUpConstantAttributes(ParticipantResult aggregatedResult)
@@ -197,4 +198,14 @@ public class ParticipantResultAggregator
return totalPayloadProcessedInKiloBytes/durationInSeconds;
}
+ private int calculateThroughputInMessagesPerSecond()
+ {
+ double durationInMillis = _maxEndDate - _minStartDate;
+ if (durationInMillis == 0 )
+ {
+ return 0;
+ }
+
+ return (int)Math.round((_numberOfMessagesProcessed * 1000.0d)/durationInMillis);
+ }
}
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..954828b043 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;
@@ -102,5 +105,26 @@ public class TestResultAggregator
aggregatedAllResult.setNumberOfMessagesProcessed(aggregatedConsumerResult.getNumberOfMessagesProcessed());
aggregatedAllResult.setTotalPayloadProcessed(aggregatedConsumerResult.getTotalPayloadProcessed());
aggregatedAllResult.setThroughput(aggregatedConsumerResult.getThroughput());
+ aggregatedAllResult.setMessageThroughput(aggregatedConsumerResult.getMessageThroughput());
+ }
+
+ /**
+ * 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..ab55e8003d
--- /dev/null
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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 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.QpidTestCase;
+import org.apache.qpid.test.utils.TestFileUtils;
+import org.apache.qpid.util.FileUtils;
+
+public class ResultsFileWriterTest extends QpidTestCase
+{
+ 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/VisitorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/VisitorTest.java
index 320e7d8c9d..09f7da4efb 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/VisitorTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/VisitorTest.java
@@ -19,12 +19,11 @@
*/
package org.apache.qpid.disttest;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.message.Command;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class VisitorTest extends TestCase
+public class VisitorTest extends QpidTestCase
{
public void testStringVisited() throws Exception
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientCommandVisitorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientCommandVisitorTest.java
index 4a82f6719f..2b29471558 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientCommandVisitorTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientCommandVisitorTest.java
@@ -21,7 +21,6 @@ package org.apache.qpid.disttest.client;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import junit.framework.TestCase;
import org.apache.qpid.disttest.jms.ClientJmsDelegate;
import org.apache.qpid.disttest.message.CreateConnectionCommand;
@@ -32,8 +31,9 @@ import org.apache.qpid.disttest.message.CreateSessionCommand;
import org.apache.qpid.disttest.message.StartTestCommand;
import org.apache.qpid.disttest.message.StopClientCommand;
import org.apache.qpid.disttest.message.TearDownTestCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class ClientCommandVisitorTest extends TestCase
+public class ClientCommandVisitorTest extends QpidTestCase
{
private Client _client;
private ClientCommandVisitor _visitor;
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java
index dd50766918..8139961fa4 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java
@@ -29,17 +29,16 @@ import java.util.Collections;
import java.util.Timer;
import java.util.TimerTask;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.jms.ClientJmsDelegate;
import org.apache.qpid.disttest.message.Command;
import org.apache.qpid.disttest.message.ParticipantResult;
import org.apache.qpid.disttest.message.Response;
import org.apache.qpid.disttest.message.StopClientCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
import org.mockito.InOrder;
import org.mockito.Mockito;
-public class ClientTest extends TestCase
+public class ClientTest extends QpidTestCase
{
private Client _client;
private ClientJmsDelegate _delegate;
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java
index 58589d36f4..f75415a2bf 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java
@@ -34,16 +34,15 @@ import java.util.Collection;
import javax.jms.Message;
import javax.jms.Session;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.DistributedTestException;
import org.apache.qpid.disttest.jms.ClientJmsDelegate;
import org.apache.qpid.disttest.message.ConsumerParticipantResult;
import org.apache.qpid.disttest.message.CreateConsumerCommand;
import org.apache.qpid.disttest.message.ParticipantResult;
+import org.apache.qpid.test.utils.QpidTestCase;
import org.mockito.InOrder;
-public class ConsumerParticipantTest extends TestCase
+public class ConsumerParticipantTest extends QpidTestCase
{
private static final String SESSION_NAME1 = "SESSION1";
private static final String PARTICIPANT_NAME1 = "PARTICIPANT_NAME1";
@@ -114,7 +113,7 @@ public class ConsumerParticipantTest extends TestCase
_inOrder.verify(_delegate).consumeMessage(PARTICIPANT_NAME1, RECEIVE_TIMEOUT);
_inOrder.verify(_delegate).calculatePayloadSizeFrom(_mockMessage);
- _inOrder.verify(_delegate).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1);
+ _inOrder.verify(_delegate).commitOrAcknowledgeMessageIfNecessary(SESSION_NAME1, _mockMessage);
}
public void testReceiveMessagesForDurationSynch() throws Exception
@@ -129,7 +128,7 @@ public class ConsumerParticipantTest extends TestCase
verify(_delegate, atLeastOnce()).consumeMessage(PARTICIPANT_NAME1, RECEIVE_TIMEOUT);
verify(_delegate, atLeastOnce()).calculatePayloadSizeFrom(_mockMessage);
- verify(_delegate, atLeastOnce()).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1);
+ verify(_delegate, atLeastOnce()).commitOrAcknowledgeMessageIfNecessary(SESSION_NAME1, _mockMessage);
}
public void testReceiveMessagesBatchedSynch() throws Exception
@@ -147,7 +146,7 @@ public class ConsumerParticipantTest extends TestCase
verify(_delegate, times(numberOfMessages)).consumeMessage(PARTICIPANT_NAME1, RECEIVE_TIMEOUT);
verify(_delegate, times(numberOfMessages)).calculatePayloadSizeFrom(_mockMessage);
- verify(_delegate, times(4)).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1);
+ verify(_delegate, times(4)).commitOrAcknowledgeMessageIfNecessary(SESSION_NAME1, _mockMessage);
}
public void testReceiveMessagesWithVaryingPayloadSize() throws Exception
@@ -171,7 +170,7 @@ public class ConsumerParticipantTest extends TestCase
verify(_delegate, times(numberOfMessages)).consumeMessage(PARTICIPANT_NAME1, RECEIVE_TIMEOUT);
verify(_delegate, times(numberOfMessages)).calculatePayloadSizeFrom(_mockMessage);
- verify(_delegate, times(numberOfMessages)).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1);
+ verify(_delegate, times(numberOfMessages)).commitOrAcknowledgeMessageIfNecessary(SESSION_NAME1, _mockMessage);
}
public void testReleaseResources()
@@ -194,7 +193,7 @@ public class ConsumerParticipantTest extends TestCase
_inOrder.verify(_delegate).consumeMessage(PARTICIPANT_NAME1, RECEIVE_TIMEOUT);
_inOrder.verify(_delegate).calculatePayloadSizeFrom(_mockMessage);
- _inOrder.verify(_delegate).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1);
+ _inOrder.verify(_delegate).commitOrAcknowledgeMessageIfNecessary(SESSION_NAME1, _mockMessage);
assertTrue("Unexpected consuemr results", result instanceof ConsumerParticipantResult);
Collection<Long> latencies = ((ConsumerParticipantResult)result).getMessageLatencies();
assertNotNull("Message latency is not cllected", latencies);
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/MessageProviderTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/MessageProviderTest.java
index 1ff8d3e5d7..8863e0f289 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/MessageProviderTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/MessageProviderTest.java
@@ -33,14 +33,13 @@ import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.client.property.ListPropertyValue;
import org.apache.qpid.disttest.client.property.PropertyValue;
import org.apache.qpid.disttest.client.property.SimplePropertyValue;
import org.apache.qpid.disttest.message.CreateProducerCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class MessageProviderTest extends TestCase
+public class MessageProviderTest extends QpidTestCase
{
private Session _session;
private TextMessage _message;
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
index f30e4664ff..6720047cd1 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
@@ -20,6 +20,7 @@
package org.apache.qpid.disttest.client;
import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -28,14 +29,13 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.DistributedTestException;
import org.apache.qpid.disttest.message.ParticipantResult;
+import org.apache.qpid.test.utils.QpidTestCase;
import org.mockito.ArgumentMatcher;
import org.mockito.InOrder;
-public class ParticipantExecutorTest extends TestCase
+public class ParticipantExecutorTest extends QpidTestCase
{
private static final ResultHasError HAS_ERROR = new ResultHasError();
private static final String CLIENT_NAME = "CLIENT_NAME";
@@ -69,8 +69,8 @@ public class ParticipantExecutorTest extends TestCase
InOrder inOrder = inOrder(_participant, _client);
inOrder.verify(_participant).doIt(CLIENT_NAME);
- inOrder.verify(_client).sendResults(_mockResult);
inOrder.verify(_participant).releaseResources();
+ inOrder.verify(_client).sendResults(_mockResult);
}
public void testParticipantThrowsException() throws Exception
@@ -82,13 +82,28 @@ public class ParticipantExecutorTest extends TestCase
InOrder inOrder = inOrder(_participant, _client);
inOrder.verify(_participant).doIt(CLIENT_NAME);
+ inOrder.verify(_participant).releaseResources();
inOrder.verify(_client).sendResults(argThat(HAS_ERROR));
+ }
+
+ public void testReleaseResourcesThrowsException() throws Exception
+ {
+ when(_participant.doIt(CLIENT_NAME)).thenReturn(_mockResult);
+ doThrow(DistributedTestException.class).when(_participant).releaseResources();
+
+ _participantExecutor.start(_client);
+
+ InOrder inOrder = inOrder(_participant, _client);
+
+ inOrder.verify(_participant).doIt(CLIENT_NAME);
inOrder.verify(_participant).releaseResources();
+
+ // check that sendResults is called even though releaseResources threw an exception
+ inOrder.verify(_client).sendResults(_mockResult);
}
public void testThreadNameAndDaemonness() throws Exception
{
-
ThreadPropertyReportingParticipant participant = new ThreadPropertyReportingParticipant(PARTICIPANT_NAME);
_participantExecutor = new ParticipantExecutor(participant);
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantRegistryTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantRegistryTest.java
index bd0d5a39c8..5cc8d2f30a 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantRegistryTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantRegistryTest.java
@@ -20,9 +20,10 @@
package org.apache.qpid.disttest.client;
import static org.mockito.Mockito.mock;
-import junit.framework.TestCase;
-public class ParticipantRegistryTest extends TestCase
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class ParticipantRegistryTest extends QpidTestCase
{
private ParticipantExecutorRegistry _participantRegistry = new ParticipantExecutorRegistry();
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantResultFactoryTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantResultFactoryTest.java
index 3b21834a5c..9eab459443 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantResultFactoryTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantResultFactoryTest.java
@@ -22,16 +22,15 @@ import java.util.Date;
import javax.jms.DeliveryMode;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.message.ConsumerParticipantResult;
import org.apache.qpid.disttest.message.CreateConsumerCommand;
import org.apache.qpid.disttest.message.CreateParticpantCommand;
import org.apache.qpid.disttest.message.CreateProducerCommand;
import org.apache.qpid.disttest.message.ParticipantResult;
import org.apache.qpid.disttest.message.ProducerParticipantResult;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class ParticipantResultFactoryTest extends TestCase
+public class ParticipantResultFactoryTest extends QpidTestCase
{
private static final String PARTICIPANT_NAME = "participantName";
private static final String REGISTERED_CLIENT_NAME = "registeredClientName";
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java
index a3ac11b756..08ee8715fd 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java
@@ -31,15 +31,14 @@ import javax.jms.DeliveryMode;
import javax.jms.Message;
import javax.jms.Session;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.DistributedTestException;
import org.apache.qpid.disttest.jms.ClientJmsDelegate;
import org.apache.qpid.disttest.message.CreateProducerCommand;
import org.apache.qpid.disttest.message.ParticipantResult;
+import org.apache.qpid.test.utils.QpidTestCase;
import org.mockito.InOrder;
-public class ProducerParticipantTest extends TestCase
+public class ProducerParticipantTest extends QpidTestCase
{
private ProducerParticipant _producer;
@@ -127,13 +126,13 @@ public class ProducerParticipantTest extends TestCase
_inOrder.verify(_delegate).sendNextMessage(isA(CreateProducerCommand.class));
_inOrder.verify(_delegate).calculatePayloadSizeFrom(_mockMessage);
- _inOrder.verify(_delegate).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1);
+ _inOrder.verify(_delegate).commitIfNecessary(SESSION_NAME1);
}
public void testSendMessagesForDuration() throws Exception
{
- final long duration = 100;
+ final long duration = 1000;
_command.setMaximumDuration(duration);
ParticipantResult result = _producer.doIt(CLIENT_NAME);
@@ -142,7 +141,24 @@ public class ProducerParticipantTest extends TestCase
verify(_delegate, atLeastOnce()).sendNextMessage(isA(CreateProducerCommand.class));
verify(_delegate, atLeastOnce()).calculatePayloadSizeFrom(_mockMessage);
- verify(_delegate, atLeastOnce()).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1);
+ verify(_delegate, atLeastOnce()).commitIfNecessary(SESSION_NAME1);
+ }
+
+ public void testSendMessagesForDurationWithDelayExceedingDuration() throws Exception
+ {
+ final long duration = 100;
+ _command.setMaximumDuration(duration);
+ _command.setStartDelay(150);
+
+ try
+ {
+ _producer.doIt(CLIENT_NAME);
+ fail("Exception should be thrown indicating configuration error");
+ }
+ catch(DistributedTestException e)
+ {
+ assertEquals("Start delay must be less than maximum test duration", e.getMessage());
+ }
}
public void testSendMessageBatches() throws Exception
@@ -161,7 +177,7 @@ public class ProducerParticipantTest extends TestCase
verify(_delegate, times(numberOfMessages)).sendNextMessage(isA(CreateProducerCommand.class));
verify(_delegate, times(numberOfMessages)).calculatePayloadSizeFrom(_mockMessage);
- verify(_delegate, times(expectedNumberOfCommits)).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1);
+ verify(_delegate, times(expectedNumberOfCommits)).commitIfNecessary(SESSION_NAME1);
}
public void testSendMessageWithPublishInterval() throws Exception
@@ -183,7 +199,7 @@ public class ProducerParticipantTest extends TestCase
verify(_delegate, times(numberOfMessages)).sendNextMessage(isA(CreateProducerCommand.class));
verify(_delegate, times(numberOfMessages)).calculatePayloadSizeFrom(_mockMessage);
- verify(_delegate, times(4)).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1);
+ verify(_delegate, times(4)).commitIfNecessary(SESSION_NAME1);
}
public void testSendMessageWithVaryingPayloadSize() throws Exception
@@ -208,7 +224,7 @@ public class ProducerParticipantTest extends TestCase
verify(_delegate, times(numberOfMessages)).sendNextMessage(isA(CreateProducerCommand.class));
verify(_delegate, times(numberOfMessages)).calculatePayloadSizeFrom(_mockMessage);
- verify(_delegate, times(numberOfMessages)).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1);
+ verify(_delegate, times(numberOfMessages)).commitIfNecessary(SESSION_NAME1);
}
public void testReleaseResources()
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/ListPropertyValueTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/ListPropertyValueTest.java
index c54355bc76..3172eb07ed 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/ListPropertyValueTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/ListPropertyValueTest.java
@@ -21,13 +21,9 @@ package org.apache.qpid.disttest.client.property;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
+import org.apache.qpid.test.utils.QpidTestCase;
-import org.apache.qpid.disttest.client.property.ListPropertyValue;
-import org.apache.qpid.disttest.client.property.PropertyValue;
-import org.apache.qpid.disttest.client.property.SimplePropertyValue;
-
-public class ListPropertyValueTest extends TestCase
+public class ListPropertyValueTest extends QpidTestCase
{
private ListPropertyValue _generator;
private List<PropertyValue> _items;
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/PropertyValueFactoryTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/PropertyValueFactoryTest.java
index 17397db5b8..eba1bcc435 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/PropertyValueFactoryTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/PropertyValueFactoryTest.java
@@ -18,9 +18,9 @@
*/
package org.apache.qpid.disttest.client.property;
-import junit.framework.TestCase;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class PropertyValueFactoryTest extends TestCase
+public class PropertyValueFactoryTest extends QpidTestCase
{
private PropertyValueFactory _factory;
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RandomPropertyValueTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RandomPropertyValueTest.java
index 878141895c..9651dd95ce 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RandomPropertyValueTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RandomPropertyValueTest.java
@@ -18,11 +18,9 @@
*/
package org.apache.qpid.disttest.client.property;
-import org.apache.qpid.disttest.client.property.RandomPropertyValue;
+import org.apache.qpid.test.utils.QpidTestCase;
-import junit.framework.TestCase;
-
-public class RandomPropertyValueTest extends TestCase
+public class RandomPropertyValueTest extends QpidTestCase
{
private RandomPropertyValue _generator;
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RangePropertyValueTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RangePropertyValueTest.java
index 6932919bed..b0649a49ae 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RangePropertyValueTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RangePropertyValueTest.java
@@ -18,11 +18,9 @@
*/
package org.apache.qpid.disttest.client.property;
-import org.apache.qpid.disttest.client.property.RangePropertyValue;
+import org.apache.qpid.test.utils.QpidTestCase;
-import junit.framework.TestCase;
-
-public class RangePropertyValueTest extends TestCase
+public class RangePropertyValueTest extends QpidTestCase
{
private RangePropertyValue _generator;
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/SimplePropertyValueTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/SimplePropertyValueTest.java
index a347d866c7..f1977015fe 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/SimplePropertyValueTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/SimplePropertyValueTest.java
@@ -18,9 +18,9 @@
*/
package org.apache.qpid.disttest.client.property;
-import junit.framework.TestCase;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class SimplePropertyValueTest extends TestCase
+public class SimplePropertyValueTest extends QpidTestCase
{
public void testGetValue()
{
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithNoLimitsTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithNoLimitsTest.java
index 37820d2582..0880512333 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithNoLimitsTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithNoLimitsTest.java
@@ -25,9 +25,9 @@ import static org.mockito.Mockito.when;
import java.util.concurrent.Callable;
-import junit.framework.TestCase;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class ExecutorWithNoLimitsTest extends TestCase
+public class ExecutorWithNoLimitsTest extends QpidTestCase
{
private final static Object RESULT = new Object();
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java
index a201a7bacf..2abdba2446 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java
@@ -20,16 +20,16 @@
package org.apache.qpid.disttest.client.utils;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.never;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
-import junit.framework.TestCase;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class ExecutorWithTimeLimitTest extends TestCase
+public class ExecutorWithTimeLimitTest extends QpidTestCase
{
private static final int TIMEOUT = 500;
private static final Object RESULT = new Object();
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ClientRegistryTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ClientRegistryTest.java
index cc969e1ef2..c07d9fcb81 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ClientRegistryTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ClientRegistryTest.java
@@ -21,14 +21,15 @@ package org.apache.qpid.disttest.controller;
import java.util.Timer;
import java.util.TimerTask;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.DistributedTestException;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class ClientRegistryTest extends TestCase
+public class ClientRegistryTest extends QpidTestCase
{
private static final String CLIENT1_REGISTERED_NAME = "CLIENT1_REGISTERED_NAME";
private static final String CLIENT2_REGISTERED_NAME = "CLIENT2_REGISTERED_NAME";
+ private static final String CLIENT3_REGISTERED_NAME = "CLIENT3_REGISTERED_NAME";
+
private static final int AWAIT_DELAY = 100;
private ClientRegistry _clientRegistry = new ClientRegistry();
@@ -70,7 +71,7 @@ public class ClientRegistryTest extends TestCase
assertEquals(0, numberOfClientsAbsent);
}
- public void testAwaitTwoClientWhenClientRegistersWhilstWaiting()
+ public void testAwaitTwoClientsWhenClientRegistersWhilstWaiting()
{
_clientRegistry.registerClient(CLIENT1_REGISTERED_NAME);
registerClientLater(CLIENT2_REGISTERED_NAME, 50);
@@ -79,6 +80,41 @@ public class ClientRegistryTest extends TestCase
assertEquals(0, numberOfClientsAbsent);
}
+ public void testAwaitTimeoutForPromptRegistrations()
+ {
+ registerClientsLaterAndAssertResult("Clients registering every 100ms should be within 600ms timeout",
+ new int[] {300, 400, 500},
+ 600,
+ 0);
+ }
+
+ public void testAwaitTimeoutForWhenThirdRegistrationIsLate()
+ {
+ registerClientsLaterAndAssertResult("Third client registering tardily should exceed timeout",
+ new int[] {300, 400, 1500},
+ 600,
+ 1);
+ }
+
+ public void testAwaitTimeoutWhenSecondAndThirdRegistrationsAreLate()
+ {
+ registerClientsLaterAndAssertResult("Second and third clients registering tardily should exceed timeout",
+ new int[] {300, 1500, 1500},
+ 600,
+ 2);
+ }
+
+ private void registerClientsLaterAndAssertResult(String message, int[] registrationDelays, int timeout, int expectedNumberOfAbsentees)
+ {
+ registerClientLater(CLIENT1_REGISTERED_NAME, registrationDelays[0]);
+ registerClientLater(CLIENT2_REGISTERED_NAME, registrationDelays[1]);
+ registerClientLater(CLIENT3_REGISTERED_NAME, registrationDelays[2]);
+
+ int numberOfClientsAbsent = _clientRegistry.awaitClients(3, timeout);
+
+ assertEquals(message, expectedNumberOfAbsentees, numberOfClientsAbsent);
+ }
+
private void registerClientLater(final String clientName, long delayInMillis)
{
doLater(new TimerTask()
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ControllerTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ControllerTest.java
index bc58ea41c5..f773c727a1 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ControllerTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ControllerTest.java
@@ -19,6 +19,8 @@
*/
package org.apache.qpid.disttest.controller;
+import static org.apache.qpid.systest.disttest.SystemTestConstants.COMMAND_RESPONSE_TIMEOUT;
+import static org.apache.qpid.systest.disttest.SystemTestConstants.REGISTRATION_TIMEOUT;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isA;
@@ -31,8 +33,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.DistributedTestException;
import org.apache.qpid.disttest.controller.config.Config;
import org.apache.qpid.disttest.controller.config.TestInstance;
@@ -42,16 +42,14 @@ import org.apache.qpid.disttest.message.RegisterClientCommand;
import org.apache.qpid.disttest.message.Response;
import org.apache.qpid.disttest.message.StopClientCommand;
import org.apache.qpid.disttest.results.aggregation.ITestResult;
+import org.apache.qpid.test.utils.QpidTestCase;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-public class ControllerTest extends TestCase
+public class ControllerTest extends QpidTestCase
{
private static final String CLIENT1_REGISTERED_NAME = "client-uid1";
- private static final long COMMAND_RESPONSE_TIMEOUT = 1000;
- private static final long REGISTRATION_TIMEOUT = 1000;
-
private Controller _controller;
private ControllerJmsDelegate _respondingJmsDelegate;
private TestRunner _testRunner;
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ParticipatingClientsTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ParticipatingClientsTest.java
index 284db38f44..da180f328f 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ParticipatingClientsTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ParticipatingClientsTest.java
@@ -25,9 +25,9 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-import junit.framework.TestCase;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class ParticipatingClientsTest extends TestCase
+public class ParticipatingClientsTest extends QpidTestCase
{
private static final String CLIENT1_CONFIGURED_NAME = "CLIENT1_CONFIGURED_NAME";
private static final String CLIENT2_CONFIGURED_NAME = "CLIENT2_CONFIGURED_NAME";
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/TestRunnerTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/TestRunnerTest.java
index 983da299b9..d8b25e76fa 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/TestRunnerTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/TestRunnerTest.java
@@ -32,8 +32,6 @@ import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.DistributedTestException;
import org.apache.qpid.disttest.controller.config.QueueConfig;
import org.apache.qpid.disttest.controller.config.TestInstance;
@@ -45,10 +43,11 @@ import org.apache.qpid.disttest.message.ParticipantResult;
import org.apache.qpid.disttest.message.Response;
import org.apache.qpid.disttest.message.StartTestCommand;
import org.apache.qpid.disttest.message.TearDownTestCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-public class TestRunnerTest extends TestCase
+public class TestRunnerTest extends QpidTestCase
{
private static final String TEST_NAME = "TEST_NAME";
private static final String PARTICIPANT_NAME = "TEST_PARTICIPANT_NAME";
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ClientConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ClientConfigTest.java
index d4af439dea..4bf4307eaf 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ClientConfigTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ClientConfigTest.java
@@ -29,16 +29,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.client.property.PropertyValue;
import org.apache.qpid.disttest.client.property.SimplePropertyValue;
import org.apache.qpid.disttest.controller.CommandForClient;
import org.apache.qpid.disttest.message.Command;
import org.apache.qpid.disttest.message.CreateMessageProviderCommand;
import org.apache.qpid.disttest.message.NoOpCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class ClientConfigTest extends TestCase
+public class ClientConfigTest extends QpidTestCase
{
private static final String CLIENT1 = "client1";
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest-test-config.js b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest-test-config.js
index 07f8bf9d92..527300eff4 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest-test-config.js
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest-test-config.js
@@ -1,3 +1,23 @@
+/*
+ *
+ * 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.
+ *
+ */
jsonObject = {
"_tests":
QPID.iterations( { "__ACK_MODE": [ 0, 1 ] },
@@ -31,4 +51,4 @@ jsonObject = {
)
})
-} \ No newline at end of file
+}
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java
index 257f139849..e208945901 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java
@@ -23,12 +23,12 @@ import java.io.Reader;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.ConfigFileTestHelper;
import org.apache.qpid.disttest.client.property.PropertyValue;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.TestFileUtils;
-public class ConfigReaderTest extends TestCase
+public class ConfigReaderTest extends QpidTestCase
{
private Config _config;
@@ -111,8 +111,9 @@ public class ConfigReaderTest extends TestCase
public void testReadsJS() throws Exception
{
ConfigReader configReader = new ConfigReader();
- String path = getClass().getResource("ConfigReaderTest-test-config.js").toURI().getPath();
+ String path = TestFileUtils.createTempFileFromResource(this, "ConfigReaderTest-test-config.js").getAbsolutePath();
_config = configReader.getConfigFromFile(path);
+
List<TestConfig> testConfigs = _config.getTestConfigs();
assertEquals("Unexpected number of tests", 2, testConfigs.size());
TestConfig testConfig1 = _config.getTestConfigs().get(0);
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java
index 88750b9737..291ce2af78 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java
@@ -24,9 +24,9 @@ import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.List;
-import junit.framework.TestCase;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class ConfigTest extends TestCase
+public class ConfigTest extends QpidTestCase
{
public void testGetTestsForTestWithIteratingMessageSizes()
{
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java
index 7c839ed462..0eee80e425 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java
@@ -27,13 +27,12 @@ import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.message.Command;
import org.apache.qpid.disttest.message.CreateConnectionCommand;
import org.apache.qpid.disttest.message.NoOpCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class ConnectionConfigTest extends TestCase
+public class ConnectionConfigTest extends QpidTestCase
{
private static final String CONNECTION_FACTORY_NAME = "ConnectionFactoryName";
private static final String CONNECTION_NAME = "ConnectionName";
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java
index c011ff4711..0aa05a176e 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java
@@ -19,11 +19,10 @@
*/
package org.apache.qpid.disttest.controller.config;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.message.CreateConsumerCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class ConsumerConfigTest extends TestCase
+public class ConsumerConfigTest extends QpidTestCase
{
public void testConsumerHasZeroArgConstructorForGson()
{
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest-test-config.js b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest-test-config.js
index f64af82feb..eab98e8bd7 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest-test-config.js
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest-test-config.js
@@ -1,3 +1,23 @@
+/*
+ *
+ * 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.
+ *
+ */
jsonObject = {
"_countries":
QPID.iterations( { "__ITERATING_VALUE": [ 0, 1 ] },
@@ -20,4 +40,4 @@ jsonObject = {
)
})
-} \ No newline at end of file
+}
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java
index eb4063888b..55c1d4a7bd 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java
@@ -25,15 +25,16 @@ import static org.apache.commons.beanutils.PropertyUtils.getProperty;
import java.util.List;
import java.util.TreeMap;
-import junit.framework.TestCase;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.TestFileUtils;
import com.google.gson.Gson;
-public class JavaScriptConfigEvaluatorTest extends TestCase
+public class JavaScriptConfigEvaluatorTest extends QpidTestCase
{
public void testEvaluateJavaScript() throws Exception
{
- String jsFilePath = getClass().getResource("JavaScriptConfigEvaluatorTest-test-config.js").toURI().getPath();
+ String jsFilePath = TestFileUtils.createTempFileFromResource(this, "JavaScriptConfigEvaluatorTest-test-config.js").getAbsolutePath();
String rawConfig = new JavaScriptConfigEvaluator().evaluateJavaScript(jsFilePath);
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java
index a3b367a4b4..148c07b1ca 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java
@@ -21,13 +21,12 @@ package org.apache.qpid.disttest.controller.config;
import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.client.property.PropertyValue;
import org.apache.qpid.disttest.client.property.SimplePropertyValue;
import org.apache.qpid.disttest.message.CreateMessageProviderCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class MessageProviderConfigTest extends TestCase
+public class MessageProviderConfigTest extends QpidTestCase
{
public void testCreateCommandsForMessageProvider()
{
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ParticipantConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ParticipantConfigTest.java
index f58cc628a4..b6efd68cbd 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ParticipantConfigTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ParticipantConfigTest.java
@@ -32,7 +32,7 @@ public class ParticipantConfigTest extends QpidTestCase
setTestSystemProperty(ParticipantConfig.DURATION_OVERRIDE_SYSTEM_PROPERTY, String.valueOf(overriddenDuration));
CreateParticpantCommand createParticipantCommand = mock(CreateParticpantCommand.class);
- ParticipantConfig participantConfig = new ParticipantConfig("name", "destinationName", 1, 2, 5000)
+ ParticipantConfig participantConfig = new ParticipantConfig("name", "destinationName", false, 1, 2, 5000)
{
};
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java
index b9e591f113..44fca4bb7c 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java
@@ -22,11 +22,10 @@ package org.apache.qpid.disttest.controller.config;
import javax.jms.DeliveryMode;
import javax.jms.Message;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.message.CreateProducerCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class ProducerConfigTest extends TestCase
+public class ProducerConfigTest extends QpidTestCase
{
public void testProducerHasZeroArgConstructorForGson()
{
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java
index 8775e4064d..02cdbb8fca 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java
@@ -29,14 +29,13 @@ import java.util.List;
import javax.jms.Session;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.message.Command;
import org.apache.qpid.disttest.message.CreateConsumerCommand;
import org.apache.qpid.disttest.message.CreateProducerCommand;
import org.apache.qpid.disttest.message.CreateSessionCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class SessionConfigTest extends TestCase
+public class SessionConfigTest extends QpidTestCase
{
private static final String CONNECTION_NAME = "conn1";
private static final String SESSION = "session1";
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java
index 1212a57606..be7c7a7c8c 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java
@@ -26,12 +26,11 @@ import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.controller.CommandForClient;
import org.apache.qpid.disttest.message.NoOpCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class TestConfigTest extends TestCase
+public class TestConfigTest extends QpidTestCase
{
private static final QueueConfig[] EMPTY_QUEUES_ARRAY = new QueueConfig[0];
private static final String CLIENT1 = "client1";
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java
index 928fbe58cf..187b57c399 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java
@@ -26,14 +26,13 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.controller.CommandForClient;
import org.apache.qpid.disttest.message.CreateConsumerCommand;
import org.apache.qpid.disttest.message.CreateProducerCommand;
import org.apache.qpid.disttest.message.NoOpCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class TestInstanceTest extends TestCase
+public class TestInstanceTest extends QpidTestCase
{
private static final String CLIENT_NAME = "CLIENT_NAME";
private static final int ITERATION_NUMBER = 0;
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/db/ResultsDbWriterTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/db/ResultsDbWriterTest.java
new file mode 100644
index 0000000000..abc6b44493
--- /dev/null
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/db/ResultsDbWriterTest.java
@@ -0,0 +1,158 @@
+/*
+ * 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.db;
+
+import static org.apache.qpid.disttest.message.ParticipantAttribute.ITERATION_NUMBER;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.PARTICIPANT_NAME;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.TEST_NAME;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.THROUGHPUT;
+import static org.apache.qpid.test.utils.TestFileUtils.createTestDirectory;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.sql.Timestamp;
+import java.util.Hashtable;
+import java.util.TimeZone;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.qpid.disttest.controller.ResultsForAllTests;
+import org.apache.qpid.disttest.db.ResultsDbWriter.Clock;
+import org.apache.qpid.disttest.message.ParticipantResult;
+import org.apache.qpid.disttest.results.ResultsTestFixture;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.util.FileUtils;
+
+public class ResultsDbWriterTest extends QpidTestCase
+{
+ private static final long _dummyTimestamp = 1234;
+
+ private File _tempDbDirectory;
+ private Clock _clock = mock(Clock.class);
+ private ResultsTestFixture _resultsTestFixture = new ResultsTestFixture();
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ _tempDbDirectory = createTestDirectory();
+ when(_clock.currentTimeMillis()).thenReturn(_dummyTimestamp);
+ }
+
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ try
+ {
+ FileUtils.deleteDirectory(_tempDbDirectory.getAbsolutePath());
+ }
+ finally
+ {
+ super.tearDown();
+ }
+ }
+
+
+ public void testWriteResults() throws Exception
+ {
+ Context context = getContext();
+ ResultsForAllTests results = _resultsTestFixture.createResultsForAllTests();
+ String runId = "myRunId";
+
+ ResultsDbWriter resultsDbWriter = new ResultsDbWriter(context, runId, _clock);
+ resultsDbWriter.createResultsTableIfNecessary();
+
+ resultsDbWriter.writeResults(results);
+
+ ParticipantResult expectedResult = _resultsTestFixture.getFirstParticipantResult(results);
+ assertResultsAreInDb(context, expectedResult, runId);
+ }
+
+ public void testDefaultRunId() throws Exception
+ {
+ TimeZone defaultTimeZone = TimeZone.getDefault();
+ try
+ {
+ // set non-GMT timezone to make the test more rigorous.
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT-05:00"));
+ ResultsDbWriter resultsDbWriter = new ResultsDbWriter(getContext(), null, _clock);
+ String runId = resultsDbWriter.getRunId();
+ assertEquals(
+ "Default run id '" + runId + "' should correspond to dummy timestamp " + _clock.currentTimeMillis(),
+ "run 1970-01-01 00:00:01.234",
+ runId);
+ }
+ finally
+ {
+ TimeZone.setDefault(defaultTimeZone);
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private Context getContext() throws NamingException
+ {
+ Context context = mock(Context.class);
+ Hashtable environment = new Hashtable();
+
+ environment.put(ResultsDbWriter.DRIVER_NAME, "org.apache.derby.jdbc.EmbeddedDriver");
+ environment.put(ResultsDbWriter.URL, "jdbc:derby:" + _tempDbDirectory + "perftestResultsDb;create=true");
+
+ when(context.getEnvironment()).thenReturn(environment);
+ return context;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void assertResultsAreInDb(Context context, ParticipantResult participantResult, String expectedRunId) throws Exception
+ {
+ String driverName = (String) context.getEnvironment().get(ResultsDbWriter.DRIVER_NAME);
+ Class<? extends Driver> driverClass = (Class<? extends Driver>) Class.forName(driverName);
+ driverClass.newInstance();
+ String url = (String) context.getEnvironment().get(ResultsDbWriter.URL);
+
+ Connection connection = DriverManager.getConnection(url);
+ Statement statement = connection.createStatement();
+ ResultSet rs = statement.executeQuery(
+ "SELECT * FROM results WHERE testName='" + participantResult.getTestName() +
+ "' AND runId='" + expectedRunId + "'");
+
+ try
+ {
+ rs.next();
+ assertEquals(participantResult.getTestName(), rs.getString(TEST_NAME.getDisplayName()));
+ assertEquals(participantResult.getIterationNumber(), rs.getInt(ITERATION_NUMBER.getDisplayName()));
+ assertEquals(participantResult.getParticipantName(), rs.getString(PARTICIPANT_NAME.getDisplayName()));
+ assertEquals(participantResult.getThroughput(), rs.getDouble(THROUGHPUT.getDisplayName()));
+ assertEquals(expectedRunId, rs.getString(ResultsDbWriter.RUN_ID));
+ assertEquals(new Timestamp(_dummyTimestamp), rs.getTimestamp(ResultsDbWriter.INSERTED_TIMESTAMP));
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+}
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java
index ab0f52263b..d4f0cb1f22 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java
@@ -18,12 +18,11 @@
*/
package org.apache.qpid.disttest.jms;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.message.Command;
import org.apache.qpid.disttest.message.CommandType;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class JmsMessageAdaptorTest extends TestCase
+public class JmsMessageAdaptorTest extends QpidTestCase
{
public void testCheckAllCommandTypes()
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java
index 4a56fff8fe..2e0c2e1ecd 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java
@@ -24,14 +24,13 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.qpid.disttest.client.property.ListPropertyValue;
import org.apache.qpid.disttest.client.property.PropertyValue;
import org.apache.qpid.disttest.json.JsonHandler;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class JsonHandlerTest extends TestCase
+public class JsonHandlerTest extends QpidTestCase
{
private JsonHandler _jsonHandler = null;
private SendChristmasCards _testCommand = null;
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java
index 34727a7b8d..e9d444d59c 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java
@@ -18,7 +18,8 @@
*/
package org.apache.qpid.disttest.message;
-import static org.apache.qpid.disttest.message.ParticipantAttribute.*;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.ACKNOWLEDGE_MODE;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.BATCH_SIZE;
import static org.apache.qpid.disttest.message.ParticipantAttribute.CONFIGURED_CLIENT_NAME;
import static org.apache.qpid.disttest.message.ParticipantAttribute.DELIVERY_MODE;
import static org.apache.qpid.disttest.message.ParticipantAttribute.ERROR_MESSAGE;
@@ -30,23 +31,25 @@ import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_SYNCHRONO
import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_TOPIC;
import static org.apache.qpid.disttest.message.ParticipantAttribute.ITERATION_NUMBER;
import static org.apache.qpid.disttest.message.ParticipantAttribute.MAXIMUM_DURATION;
-import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE;
import static org.apache.qpid.disttest.message.ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED;
import static org.apache.qpid.disttest.message.ParticipantAttribute.PARTICIPANT_NAME;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE;
import static org.apache.qpid.disttest.message.ParticipantAttribute.PRIORITY;
import static org.apache.qpid.disttest.message.ParticipantAttribute.PRODUCER_INTERVAL;
import static org.apache.qpid.disttest.message.ParticipantAttribute.PRODUCER_START_DELAY;
import static org.apache.qpid.disttest.message.ParticipantAttribute.TEST_NAME;
import static org.apache.qpid.disttest.message.ParticipantAttribute.TIME_TAKEN;
import static org.apache.qpid.disttest.message.ParticipantAttribute.TIME_TO_LIVE;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.TOTAL_NUMBER_OF_CONSUMERS;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.TOTAL_NUMBER_OF_PRODUCERS;
import java.util.Date;
import javax.jms.DeliveryMode;
-import junit.framework.TestCase;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class ParticipantResultTest extends TestCase
+public class ParticipantResultTest extends QpidTestCase
{
public void testSharedParticipantResultAttributes() throws Exception
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/ResultsTestFixture.java
index 565f59d25b..1edef031bf 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/ResultsTestFixture.java
@@ -15,12 +15,15 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
*/
-package org.apache.qpid.disttest.results.formatting;
+package org.apache.qpid.disttest.results;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.ACKNOWLEDGE_MODE;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.AVERAGE_LATENCY;
import static org.apache.qpid.disttest.message.ParticipantAttribute.BATCH_SIZE;
import static org.apache.qpid.disttest.message.ParticipantAttribute.CONFIGURED_CLIENT_NAME;
-import static org.apache.qpid.disttest.message.ParticipantAttribute.*;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.DELIVERY_MODE;
import static org.apache.qpid.disttest.message.ParticipantAttribute.ERROR_MESSAGE;
import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_BROWSING_SUBSCRIPTION;
import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_DURABLE_SUBSCRIPTION;
@@ -29,7 +32,11 @@ import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_SELECTOR;
import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_SYNCHRONOUS_CONSUMER;
import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_TOPIC;
import static org.apache.qpid.disttest.message.ParticipantAttribute.ITERATION_NUMBER;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.LATENCY_STANDARD_DEVIATION;
import static org.apache.qpid.disttest.message.ParticipantAttribute.MAXIMUM_DURATION;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.MAX_LATENCY;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.MESSAGE_THROUGHPUT;
+import static org.apache.qpid.disttest.message.ParticipantAttribute.MIN_LATENCY;
import static org.apache.qpid.disttest.message.ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED;
import static org.apache.qpid.disttest.message.ParticipantAttribute.PARTICIPANT_NAME;
import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE;
@@ -46,46 +53,41 @@ import static org.apache.qpid.disttest.message.ParticipantAttribute.TOTAL_PAYLOA
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.controller.ResultsForAllTests;
import org.apache.qpid.disttest.controller.TestResult;
import org.apache.qpid.disttest.message.ParticipantAttribute;
import org.apache.qpid.disttest.message.ParticipantResult;
+import org.apache.qpid.disttest.results.aggregation.ITestResult;
-public class CSVFormaterTest extends TestCase
+public class ResultsTestFixture
{
+ public static final double THROUGHPUT_VALUE = 2048.49;
+
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();
-
- public void testResultsFileWithWithOneRow() throws Exception
+ public ResultsForAllTests createResultsForAllTests()
{
ParticipantResult participantResult = mock(ParticipantResult.class);
Map<ParticipantAttribute, Object> participantAttributes = getParticipantAttributes();
when(participantResult.getAttributes()).thenReturn(participantAttributes);
when(participantResult.getParticipantName()).thenReturn(PARTICIPANT);
+ when(participantResult.getTestName()).thenReturn(TEST1);
+ when(participantResult.getIterationNumber()).thenReturn(0);
+ when(participantResult.getThroughput()).thenReturn(THROUGHPUT_VALUE);
TestResult testResult = new TestResult(TEST1);
testResult.addParticipantResult(participantResult);
ResultsForAllTests resultsForAllTests = new ResultsForAllTests();
resultsForAllTests.add(testResult);
-
- String output = _formatter.format(resultsForAllTests);
-
- String expectedOutput = readCsvOutputFileAsString("expectedOutput.csv");
-
- assertEquals(expectedOutput, output);
+ return resultsForAllTests;
}
private Map<ParticipantAttribute, Object> getParticipantAttributes()
@@ -96,7 +98,7 @@ public class CSVFormaterTest extends TestCase
participantAttributes.put(ITERATION_NUMBER, 0);
participantAttributes.put(CONFIGURED_CLIENT_NAME, CONFIGURED_CLIENT1);
participantAttributes.put(PARTICIPANT_NAME, PARTICIPANT);
- participantAttributes.put(NUMBER_OF_MESSAGES_PROCESSED, 0);
+ participantAttributes.put(NUMBER_OF_MESSAGES_PROCESSED, 2);
participantAttributes.put(PAYLOAD_SIZE, 1);
participantAttributes.put(PRIORITY, 2);
participantAttributes.put(TIME_TO_LIVE, 3);
@@ -115,32 +117,22 @@ 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, THROUGHPUT_VALUE);
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);
+ participantAttributes.put(MESSAGE_THROUGHPUT, 2);
return participantAttributes;
}
- private String readCsvOutputFileAsString(String filename) throws Exception
+ public ParticipantResult getFirstParticipantResult(ResultsForAllTests results)
{
- InputStream is = getClass().getResourceAsStream(filename);
- assertNotNull(is);
-
- StringBuilder output = new StringBuilder();
-
- BufferedReader br = new BufferedReader(new InputStreamReader(is));
- String line = null;
- while((line = br.readLine()) != null)
- {
- output.append(line);
- output.append("\n");
- }
-
- return output.toString();
+ List<ITestResult> testResults = results.getTestResults();
+ ITestResult testResult = testResults.iterator().next();
+ List<ParticipantResult> participantResults = testResult.getParticipantResults();
+ return participantResults.iterator().next();
}
-
}
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java
index 393837b4d5..011eb4e68b 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java
@@ -24,11 +24,10 @@ import static org.mockito.Mockito.when;
import java.util.Arrays;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.controller.ResultsForAllTests;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class AggregatorTest extends TestCase
+public class AggregatorTest extends QpidTestCase
{
private Aggregator _aggregator = new Aggregator();
private TestResultAggregator _testResultAggregator = mock(TestResultAggregator.class);
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java
index 72743be1d1..41da1edb33 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java
@@ -24,11 +24,9 @@ import java.util.Date;
import javax.jms.Session;
import org.apache.qpid.disttest.message.ParticipantResult;
-import org.apache.qpid.disttest.results.aggregation.ParticipantResultAggregator;
+import org.apache.qpid.test.utils.QpidTestCase;
-import junit.framework.TestCase;
-
-public class ParticipantResultAggregatorTest extends TestCase
+public class ParticipantResultAggregatorTest extends QpidTestCase
{
private ParticipantResultAggregator _aggregator = new ParticipantResultAggregator(ParticipantResult.class, AGGREGATED_RESULT_NAME);
@@ -39,15 +37,19 @@ public class ParticipantResultAggregatorTest extends TestCase
private static final long PARTICIPANT1_STARTDATE = 50;
private static final long PARTICIPANT1_ENDDATE = 20000;
private static final long PARTICIPANT1_TOTAL_PROCESSED = 1024;
+ private static final int PARTICIPANT1_NUMBER_OF_MESSAGES_PROCESSED = 20000;
private static final long PARTICIPANT2_STARTDATE = 100;
private static final long PARTICIPANT2_ENDDATE = 21000;
private static final long PARTICIPANT2_TOTAL_PROCESSED = 2048;
+ private static final int PARTICIPANT2_NUMBER_OF_MESSAGES_PROCESSED = 950;
private static final long OVERALL_PROCESSED = PARTICIPANT1_TOTAL_PROCESSED + PARTICIPANT2_TOTAL_PROCESSED;
private static final double OVERALL_TIMETAKEN = PARTICIPANT2_ENDDATE - PARTICIPANT1_STARTDATE;
+ private static final long OVERALL_NUMBER_OF_MESSAGES_PROCESSED = PARTICIPANT1_NUMBER_OF_MESSAGES_PROCESSED + PARTICIPANT2_NUMBER_OF_MESSAGES_PROCESSED;
private static final double EXPECTED_AGGREGATED_ALL_THROUGHPUT = ((OVERALL_PROCESSED)/1024)/((OVERALL_TIMETAKEN)/1000);
+ private static final int EXPECTED_AGGREGATED_MESSAGE_THROUGHPUT = (int)(OVERALL_NUMBER_OF_MESSAGES_PROCESSED * 1000.0d/OVERALL_TIMETAKEN);
public void testStartAndEndDateForOneParticipantResult()
{
@@ -128,6 +130,26 @@ public class ParticipantResultAggregatorTest extends TestCase
assertEquals(EXPECTED_AGGREGATED_ALL_THROUGHPUT, aggregratedResult.getThroughput(), 0.1);
}
+ public void testComputeMessageThroughput()
+ {
+ ParticipantResult result1 = new ParticipantResult();
+ result1.setStartDate(new Date(PARTICIPANT1_STARTDATE));
+ result1.setEndDate(new Date(PARTICIPANT1_ENDDATE));
+ result1.setNumberOfMessagesProcessed(PARTICIPANT1_NUMBER_OF_MESSAGES_PROCESSED);
+
+ ParticipantResult result2 = new ParticipantResult();
+ result2.setStartDate(new Date(PARTICIPANT2_STARTDATE));
+ result2.setEndDate(new Date(PARTICIPANT2_ENDDATE));
+ result2.setNumberOfMessagesProcessed(PARTICIPANT2_NUMBER_OF_MESSAGES_PROCESSED);
+
+ _aggregator.aggregate(result1);
+ _aggregator.aggregate(result2);
+
+ ParticipantResult aggregratedResult = _aggregator.getAggregatedResult();
+ assertEquals(EXPECTED_AGGREGATED_MESSAGE_THROUGHPUT, aggregratedResult.getMessageThroughput());
+
+ }
+
public void testConstantTestNameAndIterationNumberRolledUp() throws Exception
{
ParticipantResult result1 = new ParticipantResult();
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java
index ec8da8418f..7417dddc4f 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java
@@ -23,9 +23,9 @@ package org.apache.qpid.disttest.results.aggregation;
import java.util.Arrays;
import java.util.Collection;
-import junit.framework.TestCase;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class SeriesStatisticsTest extends TestCase
+public class SeriesStatisticsTest extends QpidTestCase
{
public static Collection<Long> SERIES = Arrays.asList(new Long[] { 2l, 4l, 4l, 4l, 5l, 5l, 7l, 9l, 5l });
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..b254a0e3bf 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,29 +18,30 @@
*/
package org.apache.qpid.disttest.results.aggregation;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+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;
import org.apache.qpid.disttest.message.ProducerParticipantResult;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class TestResultAggregatorTest extends TestCase
+public class TestResultAggregatorTest extends QpidTestCase
{
-
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();
@@ -141,6 +169,10 @@ public class TestResultAggregatorTest extends TestCase
aggregatedTestResult.getAllParticipantResult(),
TEST1_NAME, TEST1_ITERATION_NUMBER,
BATCH_SIZE, NUMBER_OF_MESSAGES_CONSUMED_IN_TOTAL, 2, 1);
+
+ int expectedThroughtput = (int)Math.round(NUMBER_OF_MESSAGES_PRODUCED * 1000.0d /(CONSUMER2_ENDDATE - PRODUCER_STARTDATE));
+ ParticipantResult result = aggregatedTestResult.getAllParticipantResult();
+ assertEquals("Unexpected message throughtput", expectedThroughtput, result.getMessageThroughput());
}
private void assertLatencyAggregatedResults(ParticipantResult allConsumerParticipantResult)
@@ -197,4 +229,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/CSVFormatterTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java
new file mode 100644
index 0000000000..bbf73b23d2
--- /dev/null
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.results.formatting;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.qpid.disttest.controller.ResultsForAllTests;
+import org.apache.qpid.disttest.results.ResultsTestFixture;
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class CSVFormatterTest extends QpidTestCase
+{
+ private CSVFormatter _formatter = new CSVFormatter();
+
+ public void testResultsFileWithWithOneRow() throws Exception
+ {
+ ResultsTestFixture resultsTestFixture = new ResultsTestFixture();
+ ResultsForAllTests resultsForAllTests = resultsTestFixture.createResultsForAllTests();
+
+ String output = _formatter.format(resultsForAllTests);
+
+ String expectedOutput = readCsvOutputFileAsString("expectedOutput.csv");
+
+ assertEquals(expectedOutput, output);
+ }
+
+ private String readCsvOutputFileAsString(String filename) throws Exception
+ {
+ InputStream is = getClass().getResourceAsStream(filename);
+ assertNotNull(is);
+
+ StringBuilder output = new StringBuilder();
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ String line = null;
+ while((line = br.readLine()) != null)
+ {
+ output.append(line);
+ output.append("\n");
+ }
+
+ return output.toString();
+ }
+}
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVOrderParticipantResultComparatorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVOrderParticipantResultComparatorTest.java
index 6cec4b5245..ed109a2e27 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVOrderParticipantResultComparatorTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVOrderParticipantResultComparatorTest.java
@@ -19,15 +19,13 @@
package org.apache.qpid.disttest.results.formatting;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.message.ConsumerParticipantResult;
import org.apache.qpid.disttest.message.ParticipantResult;
import org.apache.qpid.disttest.message.ProducerParticipantResult;
import org.apache.qpid.disttest.results.aggregation.TestResultAggregator;
-import org.apache.qpid.disttest.results.formatting.CSVOrderParticipantResultComparator;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class CSVOrderParticipantResultComparatorTest extends TestCase
+public class CSVOrderParticipantResultComparatorTest extends QpidTestCase
{
CSVOrderParticipantResultComparator _comparator = new CSVOrderParticipantResultComparator();
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..02ea67d56d 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,throughputMessagesPerS
+TEST1,0,2048,5,CONFIGURED_CLIENT1,PARTICIPANT,2,1,2,3,4,5,6,7,8,9,true,false,true,false,true,false,1,2,1024,1000,error,2,9,2.0,2
diff --git a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java
index 784e43469e..59396d46c0 100644
--- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java
@@ -29,7 +29,6 @@ import javax.jms.Session;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.disttest.DistributedTestException;
import org.apache.qpid.disttest.controller.config.QueueConfig;
import org.apache.qpid.disttest.jms.QpidQueueCreator;
@@ -37,6 +36,9 @@ public class QpidQueueCreatorTest extends DistributedTestSystemTestBase
{
private static final Map<String, Object> EMPTY_ATTRIBUTES = Collections.emptyMap();
+ private static final boolean QUEUE_DURABILITY = true;
+
+ private Connection _connection;
private QpidQueueCreator _creator;
private Session _session;
private List<QueueConfig> _configs;
@@ -46,20 +48,20 @@ public class QpidQueueCreatorTest extends DistributedTestSystemTestBase
public void setUp() throws Exception
{
super.setUp();
- Connection connection = getConnection();
- _session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ _connection = getConnection();
+ _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
_creator = new QpidQueueCreator();
_configs = new ArrayList<QueueConfig>();
- _queueName = "direct://amq.direct//" + getTestQueueName();
+ _queueName = "direct://amq.direct//" + getTestQueueName() + "?durable='" + QUEUE_DURABILITY + "'";
}
public void testCreateQueueWithoutAttributes() throws Exception
{
- _configs.add(new QueueConfig(_queueName, true, EMPTY_ATTRIBUTES));
+ _configs.add(new QueueConfig(_queueName, QUEUE_DURABILITY, EMPTY_ATTRIBUTES));
assertQueueBound(_queueName, false);
- _creator.createQueues(_session, _configs);
+ _creator.createQueues(_connection, _session, _configs);
assertQueueBound(_queueName, true);
}
@@ -68,46 +70,28 @@ public class QpidQueueCreatorTest extends DistributedTestSystemTestBase
{
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("x-qpid-priorities", Integer.valueOf(5));
- _configs.add(new QueueConfig(_queueName, true, attributes));
+ _configs.add(new QueueConfig(_queueName, QUEUE_DURABILITY, attributes));
assertQueueBound(_queueName, false);
- _creator.createQueues(_session, _configs);
+ _creator.createQueues(_connection, _session, _configs);
assertQueueBound(_queueName, true);
}
public void testDeleteQueues() throws Exception
{
- _configs.add(new QueueConfig(_queueName, true, EMPTY_ATTRIBUTES));
+ _configs.add(new QueueConfig(_queueName, QUEUE_DURABILITY, EMPTY_ATTRIBUTES));
assertQueueBound(_queueName, false);
- _creator.createQueues(_session, _configs);
+ _creator.createQueues(_connection, _session, _configs);
assertQueueBound(_queueName, true);
- _creator.deleteQueues(_session, _configs);
+ _creator.deleteQueues(_connection, _session, _configs);
assertQueueBound(_queueName, false);
}
- public void testDeleteQueueThatDoesNotExist() throws Exception
- {
- String queueThatDoesNotExist = _queueName;
- List<QueueConfig> configs = new ArrayList<QueueConfig>();
- Map<String, Object> attributes = Collections.emptyMap();
- configs.add(new QueueConfig(queueThatDoesNotExist, true, attributes));
-
- try
- {
- _creator.deleteQueues(_session, configs);
- fail("Exception not thrown");
- }
- catch (DistributedTestException e)
- {
- // PASS
- }
- }
-
private void assertQueueBound(String queueName, boolean isBound) throws Exception
{
AMQDestination destination = (AMQDestination)_session.createQueue(queueName);
diff --git a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java
index 808b428bc9..b06ab0c735 100644
--- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java
+++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java
@@ -21,8 +21,8 @@ package org.apache.qpid.systest.disttest;
public abstract class SystemTestConstants
{
- public static final long REGISTRATION_TIMEOUT = 5000;
- public static final long COMMAND_RESPONSE_TIMEOUT = 10000;
- public static final long TEST_RESULT_TIMEOUT = 5000;
+ public static final long REGISTRATION_TIMEOUT = 20000;
+ public static final long COMMAND_RESPONSE_TIMEOUT = 30000;
+ public static final long TEST_RESULT_TIMEOUT = 20000;
}
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..a0c2a4b342 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
@@ -20,7 +20,9 @@ package org.apache.qpid.systest.disttest.endtoend;
import static org.apache.qpid.disttest.AbstractRunner.JNDI_CONFIG_PROP;
import static org.apache.qpid.disttest.ControllerRunner.OUTPUT_DIR_PROP;
+import static org.apache.qpid.disttest.ControllerRunner.RUN_ID;
import static org.apache.qpid.disttest.ControllerRunner.TEST_CONFIG_PROP;
+import static org.apache.qpid.disttest.ControllerRunner.WRITE_TO_DB;
import java.io.File;
import java.io.IOException;
@@ -36,6 +38,7 @@ public class EndToEndTest extends QpidBrokerTestCase
private ControllerRunner _runner;
private static final String TEST_CONFIG = "perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/endtoend.json";
private static final String JNDI_CONFIG_FILE = "perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties";
+ private static final String RUN1 = "run1";
public void testRunner() throws Exception
{
@@ -44,6 +47,8 @@ public class EndToEndTest extends QpidBrokerTestCase
final String[] args = new String[] {TEST_CONFIG_PROP + "=" + TEST_CONFIG,
JNDI_CONFIG_PROP + "=" + JNDI_CONFIG_FILE,
+ WRITE_TO_DB + "=true",
+ RUN_ID + "=" + RUN1,
OUTPUT_DIR_PROP + "=" + csvOutputDir.getAbsolutePath()};
_runner = new ControllerRunner();
_runner.parseArgumentsIntoConfig(args);
@@ -76,10 +81,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()]);
}
diff --git a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties
index b5d053227c..149e632048 100644
--- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties
+++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties
@@ -24,3 +24,6 @@ java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextF
connectionfactory.connectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:15672'
destination.controllerqueue = direct://amq.direct//controllerqueue
+
+jdbcDriverClass=org.apache.derby.jdbc.EmbeddedDriver
+jdbcUrl=jdbc:derby:/tmp/tempDbDirectory/perftestResultsDb;create=true