summaryrefslogtreecommitdiff
path: root/java/perftests/src/test
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2012-08-03 12:13:32 +0000
committerKim van der Riet <kpvdr@apache.org>2012-08-03 12:13:32 +0000
commitd43d1912b376322e27fdcda551a73f9ff5487972 (patch)
treece493e10baa95f44be8beb5778ce51783463196d /java/perftests/src/test
parent04877fec0c6346edec67072d7f2d247740cf2af5 (diff)
downloadqpid-python-d43d1912b376322e27fdcda551a73f9ff5487972.tar.gz
QPID-3858: Updated branch - merged from trunk r.1368650
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1368910 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/perftests/src/test')
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java79
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileTestHelper.java (renamed from java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelper.java)2
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java2
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java23
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/MessageProviderTest.java1
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java2
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/property/ListPropertyValueTest.java1
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/property/PropertyValueFactoryTest.java1
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RandomPropertyValueTest.java1
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RangePropertyValueTest.java1
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithNoLimitsTest.java61
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java131
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest-test-config.js34
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java40
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/IterationValueTest.java33
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest-test-config.js23
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java81
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ParticipantConfigTest.java43
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java4
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java43
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java52
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java10
-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/clientonly/ControllerQueue.java22
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java18
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java22
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json3
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java4
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java6
29 files changed, 696 insertions, 51 deletions
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
new file mode 100644
index 0000000000..a10b3b359e
--- /dev/null
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.TestFileUtils;
+
+public class ConfigFileHelperTest extends QpidTestCase
+{
+ private File _testDir;
+ private ConfigFileHelper _configFileHelper = new ConfigFileHelper();
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ _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");
+ String jsonFile = createFile("file2.json");
+ createFile("file.txt");
+ createDir("dir.js");
+
+ String testConfigPath = _testDir.getAbsolutePath();
+
+ List<String> configFiles = _configFileHelper.getTestConfigFiles(testConfigPath);
+
+ Set<String> expectedFiles = new HashSet<String>(Arrays.asList(jsFile, jsonFile));
+ Set<String> actualFiles = new HashSet<String>(configFiles);
+
+ assertEquals(expectedFiles, actualFiles);
+ }
+
+ private void createDir(String dirName)
+ {
+ File dir = new File(_testDir, dirName);
+ dir.mkdir();
+ }
+
+ private String createFile(String fileName) throws IOException
+ {
+ File file = new File(_testDir, fileName);
+ file.createNewFile();
+ return file.getAbsolutePath();
+ }
+}
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelper.java b/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileTestHelper.java
index 12ba3b56ad..71cd61db82 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelper.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileTestHelper.java
@@ -26,7 +26,7 @@ import java.io.Reader;
import org.apache.qpid.disttest.controller.config.Config;
import org.apache.qpid.disttest.controller.config.ConfigReader;
-public class ConfigFileHelper
+public class ConfigFileTestHelper
{
public static Reader getConfigFileReader(Class<?> testClass, String resourceName)
{
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 198baa6ef4..dd50766918 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
@@ -125,7 +125,7 @@ public class ClientTest extends TestCase
_client.tearDownTest();
- verify(_delegate).closeTestConnections();
+ verify(_delegate).tearDownTest();
verify(_participantRegistry).clear();
}
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 ff7cfd2b41..58589d36f4 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
@@ -29,6 +29,8 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.util.Collection;
+
import javax.jms.Message;
import javax.jms.Session;
@@ -36,6 +38,7 @@ 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.mockito.InOrder;
@@ -177,4 +180,24 @@ public class ConsumerParticipantTest extends TestCase
verify(_delegate).closeTestConsumer(PARTICIPANT_NAME1);
}
+ public void testLatency() throws Exception
+ {
+ int numberOfMessages = 1;
+ long totalPayloadSize = PAYLOAD_SIZE_PER_MESSAGE * numberOfMessages;
+ _command.setNumberOfMessages(numberOfMessages);
+ _command.setEvaluateLatency(true);
+ _consumerParticipant = new ConsumerParticipant(_delegate, _command);
+ ParticipantResult result = _consumerParticipant.doIt(CLIENT_NAME);
+
+ assertExpectedConsumerResults(result, PARTICIPANT_NAME1, CLIENT_NAME, _testStartTime,
+ Session.CLIENT_ACKNOWLEDGE, null, numberOfMessages, PAYLOAD_SIZE_PER_MESSAGE, totalPayloadSize, null);
+
+ _inOrder.verify(_delegate).consumeMessage(PARTICIPANT_NAME1, RECEIVE_TIMEOUT);
+ _inOrder.verify(_delegate).calculatePayloadSizeFrom(_mockMessage);
+ _inOrder.verify(_delegate).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1);
+ assertTrue("Unexpected consuemr results", result instanceof ConsumerParticipantResult);
+ Collection<Long> latencies = ((ConsumerParticipantResult)result).getMessageLatencies();
+ assertNotNull("Message latency is not cllected", latencies);
+ assertEquals("Unexpected message latency results", 1, latencies.size());
+ }
}
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 ffc3733eb7..1ff8d3e5d7 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
@@ -59,6 +59,7 @@ public class MessageProviderTest extends TestCase
{
MessageProvider messageProvider = new MessageProvider(null)
{
+ @Override
public String getMessagePayload(CreateProducerCommand command)
{
return super.getMessagePayload(command);
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 cf05623e8f..a3ac11b756 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
@@ -121,7 +121,7 @@ public class ProducerParticipantTest extends TestCase
_command.setBatchSize(batchSize);
_command.setDeliveryMode(deliveryMode);
- ParticipantResult result = (ParticipantResult) _producer.doIt(CLIENT_NAME);
+ ParticipantResult result = _producer.doIt(CLIENT_NAME);
assertExpectedProducerResults(result, PARTICIPANT_NAME1, CLIENT_NAME, _testStartTime,
Session.AUTO_ACKNOWLEDGE, null, numberOfMessages, PAYLOAD_SIZE_PER_MESSAGE, totalPayloadSize, null);
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 75a634ba54..c54355bc76 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
@@ -32,6 +32,7 @@ public class ListPropertyValueTest extends TestCase
private ListPropertyValue _generator;
private List<PropertyValue> _items;
+ @Override
public void setUp() throws Exception
{
super.setUp();
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 2d560163c2..17397db5b8 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
@@ -24,6 +24,7 @@ public class PropertyValueFactoryTest extends TestCase
{
private PropertyValueFactory _factory;
+ @Override
public void setUp() throws Exception
{
super.setUp();
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 bd5de3e370..878141895c 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
@@ -26,6 +26,7 @@ public class RandomPropertyValueTest extends TestCase
{
private RandomPropertyValue _generator;
+ @Override
public void setUp() throws Exception
{
super.setUp();
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 91791c9d55..6932919bed 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
@@ -26,6 +26,7 @@ public class RangePropertyValueTest extends TestCase
{
private RangePropertyValue _generator;
+ @Override
public void setUp() throws Exception
{
super.setUp();
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
new file mode 100644
index 0000000000..37820d2582
--- /dev/null
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithNoLimitsTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.client.utils;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.concurrent.Callable;
+
+import junit.framework.TestCase;
+
+public class ExecutorWithNoLimitsTest extends TestCase
+{
+ private final static Object RESULT = new Object();
+
+ private ExecutorWithLimits _limiter = new ExecutorWithNoLimits();
+ @SuppressWarnings("unchecked")
+ private Callable<Object> _callback = mock(Callable.class);
+
+ public void testNormalExecution() throws Exception
+ {
+ when(_callback.call()).thenReturn(RESULT);
+ final Object actualResult = _limiter.execute(_callback);
+ verify(_callback).call();
+ assertEquals(RESULT, actualResult);
+ }
+
+ public void testCallableThrowsException() throws Exception
+ {
+ when(_callback.call()).thenThrow(new Exception("mocked exception"));
+
+ try
+ {
+ _limiter.execute(_callback);
+ fail("Exception not thrown");
+ }
+ catch (Exception e)
+ {
+ // PASS
+ }
+ verify(_callback).call();
+ }
+}
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
new file mode 100644
index 0000000000..a201a7bacf
--- /dev/null
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java
@@ -0,0 +1,131 @@
+/*
+ * 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.client.utils;
+
+import static org.mockito.Mockito.mock;
+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;
+
+public class ExecutorWithTimeLimitTest extends TestCase
+{
+ private static final int TIMEOUT = 500;
+ private static final Object RESULT = new Object();
+
+ private ExecutorWithLimits _limiter;
+ @SuppressWarnings("unchecked")
+ private Callable<Object> _callback = mock(Callable.class);
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ _limiter = new ExecutorWithTimeLimit(System.currentTimeMillis(), TIMEOUT);
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ if (_limiter != null)
+ {
+ _limiter.shutdown();
+ }
+ }
+
+ public void testCallableCompletesNormally() throws Exception
+ {
+ when(_callback.call()).thenReturn(RESULT);
+
+ final Object actualResult = _limiter.execute(_callback);
+
+ verify(_callback).call();
+ assertEquals(RESULT, actualResult);
+ }
+
+ public void testCallableThrowsException() throws Exception
+ {
+ when(_callback.call()).thenThrow(new Exception("mocked exception"));
+
+ try
+ {
+ _limiter.execute(_callback);
+ fail("Exception not thrown");
+ }
+ catch (CancellationException ce)
+ {
+ fail("Wrong exception thrown");
+ }
+ catch (Exception e)
+ {
+ // PASS
+ }
+ verify(_callback).call();
+ }
+
+ public void testCallableNotRunDueToInsufficentTimeRemaining() throws Exception
+ {
+ long now = System.currentTimeMillis();
+ ExecutorWithLimits shortTimeLimiter = new ExecutorWithTimeLimit(now - 100, 100);
+ try
+ {
+ shortTimeLimiter.execute(_callback);
+ fail("Exception not thrown");
+ }
+ catch (CancellationException ca)
+ {
+ // PASS
+ }
+ finally
+ {
+ shortTimeLimiter.shutdown();
+ }
+
+ verify(_callback, never()).call();
+ }
+
+ public void testExecutionInterruptedByTimeout() throws Exception
+ {
+ Callable<Void> oversleepingCallback = new Callable<Void>()
+ {
+ @Override
+ public Void call() throws Exception
+ {
+ Thread.sleep(TIMEOUT * 2);
+ return null;
+ }
+ };
+
+ try
+ {
+ _limiter.execute(oversleepingCallback);
+ fail("Exception not thrown");
+ }
+ catch (CancellationException ca)
+ {
+ // PASS
+ }
+ }
+}
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
new file mode 100644
index 0000000000..07f8bf9d92
--- /dev/null
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest-test-config.js
@@ -0,0 +1,34 @@
+jsonObject = {
+ "_tests":
+ QPID.iterations( { "__ACK_MODE": [ 0, 1 ] },
+ {
+ // this is a comment - it wouldn't be allowed if this were pure JSON
+
+ "_name": "Test 1",
+ "_queues": [
+ {
+ "_name": "Json-Queue-Name"
+ }
+ ],
+
+ "_clients": QPID.times(2,
+ {
+ "_name": "repeatingClient__CLIENT_INDEX",
+ "_connections": [
+ {
+ "_name": "connection1",
+ "_sessions": [
+ {
+ "_sessionName": "session1",
+ "_acknowledgeMode": "__ACK_MODE",
+ "_consumers": []
+ }
+ ]
+ }
+ ]
+ },
+ "__CLIENT_INDEX"
+ )
+ })
+
+} \ 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 af9ec28db0..257f139849 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
@@ -25,10 +25,8 @@ import java.util.Map;
import junit.framework.TestCase;
-import org.apache.qpid.disttest.ConfigFileHelper;
-import org.apache.qpid.disttest.client.MessageProvider;
+import org.apache.qpid.disttest.ConfigFileTestHelper;
import org.apache.qpid.disttest.client.property.PropertyValue;
-import org.apache.qpid.disttest.controller.CommandForClient;
public class ConfigReaderTest extends TestCase
{
@@ -38,7 +36,7 @@ public class ConfigReaderTest extends TestCase
protected void setUp()
{
ConfigReader configReader = new ConfigReader();
- Reader reader = ConfigFileHelper.getConfigFileReader(getClass(), "sampleConfig.json");
+ Reader reader = ConfigFileTestHelper.getConfigFileReader(getClass(), "sampleConfig.json");
_config = configReader.readConfig(reader);
}
@@ -110,4 +108,38 @@ public class ConfigReaderTest extends TestCase
assertNotNull("id property is not found", properties.get("id"));
}
+ public void testReadsJS() throws Exception
+ {
+ ConfigReader configReader = new ConfigReader();
+ String path = getClass().getResource("ConfigReaderTest-test-config.js").toURI().getPath();
+ _config = configReader.getConfigFromFile(path);
+ List<TestConfig> testConfigs = _config.getTestConfigs();
+ assertEquals("Unexpected number of tests", 2, testConfigs.size());
+ TestConfig testConfig1 = _config.getTestConfigs().get(0);
+ List<ClientConfig> cleintConfigs = testConfig1.getClients();
+ assertEquals("Unexpected number of test 1 clients", 2, cleintConfigs.size());
+ List<QueueConfig> queueConfigs = testConfig1.getQueues();
+ assertEquals("Unexpected number of test 1 queue", 1, queueConfigs.size());
+ assertEquals("Unexpected queue name", "Json-Queue-Name", queueConfigs.get(0).getName());
+ ClientConfig cleintConfig = cleintConfigs.get(0);
+ List<ConnectionConfig> connectionConfigs = cleintConfig.getConnections();
+ assertEquals("Unexpected number of connections", 1, connectionConfigs.size());
+ List<SessionConfig> sessionConfigs = connectionConfigs.get(0).getSessions();
+ assertEquals("Unexpected number of sessions", 1, sessionConfigs.size());
+ assertEquals("Unexpected ack mode", 0, sessionConfigs.get(0).getAcknowledgeMode());
+
+ TestConfig testConfig2 = _config.getTestConfigs().get(1);
+ List<ClientConfig> cleintConfigs2 = testConfig2.getClients();
+ assertEquals("Unexpected number of test 1 clients", 2, cleintConfigs2.size());
+ List<QueueConfig> queueConfigs2 = testConfig2.getQueues();
+ assertEquals("Unexpected number of test 1 queue", 1, queueConfigs2.size());
+ assertEquals("Unexpected queue name", "Json-Queue-Name", queueConfigs2.get(0).getName());
+ ClientConfig cleintConfig2 = cleintConfigs2.get(0);
+ List<ConnectionConfig> connectionConfigs2 = cleintConfig2.getConnections();
+ assertEquals("Unexpected number of connections", 1, connectionConfigs2.size());
+ List<SessionConfig> sessionConfigs2 = connectionConfigs2.get(0).getSessions();
+ assertEquals("Unexpected number of sessions", 1, sessionConfigs2.size());
+ assertEquals("Unexpected ack mode", 1, sessionConfigs2.get(0).getAcknowledgeMode());
+ }
+
}
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/IterationValueTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/IterationValueTest.java
index 7998eae37e..860f6af565 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/IterationValueTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/IterationValueTest.java
@@ -22,19 +22,19 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
-import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
-
+import org.apache.qpid.disttest.message.CreateConnectionCommand;
import org.apache.qpid.disttest.message.CreateConsumerCommand;
-import org.apache.qpid.disttest.message.CreateProducerCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class IterationValueTest extends TestCase
+public class IterationValueTest extends QpidTestCase
{
- private static final int MESSAGE_SIZE = 10;
+ private static final int MAXIMUM_DURATION = 10;
+
+ private static final boolean IS_DURABLE_SUBSCRIPTION = true;
- private CreateProducerCommand _createProducerCommand;
private CreateConsumerCommand _createConsumerCommand;
private Map<String, String> _iterationValueMap;
@@ -42,37 +42,40 @@ public class IterationValueTest extends TestCase
protected void setUp() throws Exception
{
super.setUp();
- _createProducerCommand = mock(CreateProducerCommand.class);
_createConsumerCommand = mock(CreateConsumerCommand.class);
- _iterationValueMap = Collections.singletonMap("_messageSize", String.valueOf(MESSAGE_SIZE));
+ _iterationValueMap = new HashMap<String, String>();
+ _iterationValueMap.put("_maximumDuration", String.valueOf(MAXIMUM_DURATION));
+ _iterationValueMap.put("_durableSubscription", String.valueOf(IS_DURABLE_SUBSCRIPTION));
}
public void testApplyPopulatedIterationValueToCommandWithMatchingProperties() throws Exception
{
IterationValue iterationValue = new IterationValue(_iterationValueMap);
- iterationValue.applyToCommand(_createProducerCommand);
+ iterationValue.applyToCommand(_createConsumerCommand);
- verify(_createProducerCommand).setMessageSize(MESSAGE_SIZE);
+ verify(_createConsumerCommand).setMaximumDuration(MAXIMUM_DURATION);
+ verify(_createConsumerCommand).setDurableSubscription(IS_DURABLE_SUBSCRIPTION);
}
public void testApplyPopulatedIterationValueToCommandWithoutMatchingProperties() throws Exception
{
IterationValue iterationValue = new IterationValue(_iterationValueMap);
- iterationValue.applyToCommand(_createConsumerCommand);
+ CreateConnectionCommand createConnectionCommand = mock(CreateConnectionCommand.class);
+ iterationValue.applyToCommand(createConnectionCommand);
- verifyZeroInteractions(_createConsumerCommand);
+ verifyZeroInteractions(createConnectionCommand);
}
public void testApplyUnpopulatedIterationValueToCommand() throws Exception
{
IterationValue iterationValue = new IterationValue();
- iterationValue.applyToCommand(_createProducerCommand);
+ iterationValue.applyToCommand(_createConsumerCommand);
- verifyZeroInteractions(_createProducerCommand);
+ verifyZeroInteractions(_createConsumerCommand);
}
}
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
new file mode 100644
index 0000000000..f64af82feb
--- /dev/null
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest-test-config.js
@@ -0,0 +1,23 @@
+jsonObject = {
+ "_countries":
+ QPID.iterations( { "__ITERATING_VALUE": [ 0, 1 ] },
+ {
+ // this is a comment - it wouldn't be allowed if this were pure JSON
+
+ "_name": "Country",
+ "_regions": QPID.times(2,
+ {
+ "_name": "repeatingRegion__REGION_INDEX",
+ "_towns": [
+ {
+ "_name": "town1",
+ "_iteratingAttribute": "__ITERATING_VALUE",
+ "_consumers": []
+ }
+ ]
+ },
+ "__REGION_INDEX"
+ )
+ })
+
+} \ 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
new file mode 100644
index 0000000000..eb4063888b
--- /dev/null
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java
@@ -0,0 +1,81 @@
+/*
+ *
+ * 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.controller.config;
+
+import static org.apache.commons.beanutils.PropertyUtils.getProperty;
+
+import java.util.List;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import com.google.gson.Gson;
+
+public class JavaScriptConfigEvaluatorTest extends TestCase
+{
+ public void testEvaluateJavaScript() throws Exception
+ {
+ String jsFilePath = getClass().getResource("JavaScriptConfigEvaluatorTest-test-config.js").toURI().getPath();
+
+ String rawConfig = new JavaScriptConfigEvaluator().evaluateJavaScript(jsFilePath);
+
+ Object configAsObject = getObject(rawConfig);
+
+ // Tests are produced by the QPID.iterations js function
+ assertEquals("Unexpected number of countries", 2, getPropertyAsList(configAsObject, "_countries").size());
+
+ Object country0 = getProperty(configAsObject, "_countries.[0]");
+ assertEquals("Unexpected country name", "Country", getProperty(country0, "_name"));
+ assertEquals("Unexpected country iteration number", 0, getPropertyAsInt(country0, "_iterationNumber"));
+
+ assertEquals("Unexpected number of regions", 2, getPropertyAsList(country0, "_regions").size());
+ // Region names are produced by the QPID.times js function
+ assertEquals("Unexpected region name", "repeatingRegion0", getProperty(country0, "_regions.[0]._name"));
+ assertEquals("Unexpected region name", "repeatingRegion1", getProperty(country0, "_regions.[1]._name"));
+ // Iterating attribute are produced by the QPID.iterations js function
+ assertEquals("Unexpected iterating attribute", "0", getProperty(country0, "_regions.[0]._towns.[0]._iteratingAttribute"));
+
+ Object country1 = getProperty(configAsObject, "_countries.[1]");
+ assertEquals("Unexpected country iteration number", 1, getPropertyAsInt(country1, "_iterationNumber"));
+ assertEquals("Unexpected iterating attribute", "1", getProperty(country1, "_regions.[0]._towns.[0]._iteratingAttribute"));
+ }
+
+ private int getPropertyAsInt(Object configAsObject, String property) throws Exception
+ {
+ Number propertyValue = (Number) getProperty(configAsObject, property);
+
+ return propertyValue.intValue();
+ }
+
+ private List<?> getPropertyAsList(Object configAsObject, String property)
+ throws Exception
+ {
+ return (List<?>)getProperty(configAsObject, property);
+ }
+
+ private Object getObject(String jsonStringIn)
+ {
+ Gson gson = new Gson();
+ @SuppressWarnings("rawtypes")
+ TreeMap object = gson.fromJson(jsonStringIn, TreeMap.class);
+ return object;
+ }
+}
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
new file mode 100644
index 0000000000..f58cc628a4
--- /dev/null
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ParticipantConfigTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.controller.config;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import org.apache.qpid.disttest.message.CreateParticpantCommand;
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class ParticipantConfigTest extends QpidTestCase
+{
+ public void testCreateProducerCommandAppliesDurationOverride()
+ {
+ long overriddenDuration = 123;
+ setTestSystemProperty(ParticipantConfig.DURATION_OVERRIDE_SYSTEM_PROPERTY, String.valueOf(overriddenDuration));
+
+ CreateParticpantCommand createParticipantCommand = mock(CreateParticpantCommand.class);
+ ParticipantConfig participantConfig = new ParticipantConfig("name", "destinationName", 1, 2, 5000)
+ {
+ };
+
+ participantConfig.setParticipantProperties(createParticipantCommand);
+
+ verify(createParticipantCommand).setMaximumDuration(overriddenDuration);
+ }
+}
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 12731c06f4..34727a7b8d 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
@@ -22,7 +22,7 @@ import static org.apache.qpid.disttest.message.ParticipantAttribute.*;
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_BROWSIING_SUBSCRIPTION;
+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;
@@ -127,7 +127,7 @@ public class ParticipantResultTest extends TestCase
assertEquals(topic, result.getAttributes().get(IS_TOPIC));
assertEquals(durable, result.getAttributes().get(IS_DURABLE_SUBSCRIPTION));
- assertEquals(browsingSubscription, result.getAttributes().get(IS_BROWSIING_SUBSCRIPTION));
+ assertEquals(browsingSubscription, result.getAttributes().get(IS_BROWSING_SUBSCRIPTION));
assertEquals(selector, result.getAttributes().get(IS_SELECTOR));
assertEquals(noLocal, result.getAttributes().get(IS_NO_LOCAL));
assertEquals(synchronousConsumer, result.getAttributes().get(IS_SYNCHRONOUS_CONSUMER));
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
new file mode 100644
index 0000000000..ec8da8418f
--- /dev/null
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java
@@ -0,0 +1,43 @@
+/*
+ *
+ * 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.aggregation;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+public class SeriesStatisticsTest extends TestCase
+{
+ public static Collection<Long> SERIES = Arrays.asList(new Long[] { 2l, 4l, 4l, 4l, 5l, 5l, 7l, 9l, 5l });
+
+ public void testAggregate()
+ {
+ SeriesStatistics results = new SeriesStatistics();
+ results.addMessageLatencies(SERIES);
+ results.aggregate();
+ assertEquals("Unexpected average", 5.0, results.getAverage(), 0.01);
+ assertEquals("Unexpected min", 2, results.getMinimum());
+ assertEquals("Unexpected max", 9, results.getMaximum());
+ assertEquals("Unexpected standard deviation", 2.0, results.getStandardDeviation(), 0.01);
+ }
+
+}
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 a803120cc6..9c00e7cf1c 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
@@ -19,6 +19,7 @@
package org.apache.qpid.disttest.results.aggregation;
import java.util.Date;
+import java.util.List;
import junit.framework.TestCase;
@@ -26,8 +27,6 @@ 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.disttest.results.aggregation.AggregatedTestResult;
-import org.apache.qpid.disttest.results.aggregation.TestResultAggregator;
public class TestResultAggregatorTest extends TestCase
{
@@ -105,6 +104,55 @@ public class TestResultAggregatorTest extends TestCase
assertEquals(TestResultAggregator.AGGREGATED_ERROR_MESSAGE, aggregatedTestResult.getAllParticipantResult().getErrorMessage());
}
+ public void testAggregateResultsForConsumerWithLatencyResults() throws Exception
+ {
+ TestResult originalTestResult = createResultsFromTest();
+ List<ParticipantResult> results = originalTestResult.getParticipantResults();
+ for (ParticipantResult participantResult : results)
+ {
+ if (participantResult instanceof ConsumerParticipantResult)
+ {
+ ((ConsumerParticipantResult)participantResult).setMessageLatencies(SeriesStatisticsTest.SERIES);
+ break;
+ }
+ }
+
+ int numberOfOriginalParticipantResults = originalTestResult.getParticipantResults().size();
+ int expectedNumberOfResults = numberOfOriginalParticipantResults + EXPECTED_NUMBER_OF_AGGREGATED_RESULTS;
+
+ AggregatedTestResult aggregatedTestResult = _aggregator.aggregateTestResult(originalTestResult);
+
+ aggregatedTestResult.getAllConsumerParticipantResult().getTotalPayloadProcessed();
+ assertEquals(expectedNumberOfResults, aggregatedTestResult.getParticipantResults().size());
+
+ assertMinimalAggregatedResults(
+ aggregatedTestResult.getAllConsumerParticipantResult(),
+ TEST1_NAME, TEST1_ITERATION_NUMBER,
+ BATCH_SIZE, NUMBER_OF_MESSAGES_CONSUMED_IN_TOTAL, 2, 0);
+
+ assertLatencyAggregatedResults(aggregatedTestResult.getAllConsumerParticipantResult());
+
+ assertMinimalAggregatedResults(
+ aggregatedTestResult.getAllProducerParticipantResult(),
+ TEST1_NAME, TEST1_ITERATION_NUMBER,
+ BATCH_SIZE, NUMBER_OF_MESSAGES_PRODUCED, 0, 1);
+
+ assertMinimalAggregatedResults(
+ aggregatedTestResult.getAllParticipantResult(),
+ TEST1_NAME, TEST1_ITERATION_NUMBER,
+ BATCH_SIZE, NUMBER_OF_MESSAGES_CONSUMED_IN_TOTAL, 2, 1);
+ }
+
+ private void assertLatencyAggregatedResults(ParticipantResult allConsumerParticipantResult)
+ {
+ assertTrue("Unexpected result", allConsumerParticipantResult instanceof ConsumerParticipantResult);
+ ConsumerParticipantResult results = (ConsumerParticipantResult)allConsumerParticipantResult;
+ assertEquals("Unexpected average", 5.0, results.getAverageLatency(), 0.01);
+ assertEquals("Unexpected min", 2, results.getMinLatency());
+ assertEquals("Unexpected max", 9, results.getMaxLatency());
+ assertEquals("Unexpected standard deviation", 2.0, results.getLatencyStandardDeviation(), 0.01);
+ }
+
private void assertMinimalAggregatedResults(ParticipantResult result, String expectedTestName, int expectedIterationNumber, int expectedBatchSize, long expectedNumberOfMessagesProcessed, int expectedTotalNumberOfConsumers, int expectedTotalNumberOfProducers)
{
assertEquals("Unexpected test name in " + result.getParticipantName(), expectedTestName, result.getTestName());
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java
index 088746d8cd..565f59d25b 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java
@@ -22,7 +22,7 @@ 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.ERROR_MESSAGE;
-import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_BROWSIING_SUBSCRIPTION;
+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;
@@ -58,7 +58,6 @@ 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.qmf.QMFProperty.AccessCode;
public class CSVFormaterTest extends TestCase
{
@@ -109,7 +108,7 @@ public class CSVFormaterTest extends TestCase
participantAttributes.put(PRODUCER_INTERVAL, 9);
participantAttributes.put(IS_TOPIC, true);
participantAttributes.put(IS_DURABLE_SUBSCRIPTION, false);
- participantAttributes.put(IS_BROWSIING_SUBSCRIPTION, true);
+ participantAttributes.put(IS_BROWSING_SUBSCRIPTION, true);
participantAttributes.put(IS_SELECTOR, false);
participantAttributes.put(IS_NO_LOCAL, true);
participantAttributes.put(IS_SYNCHRONOUS_CONSUMER, false);
@@ -119,7 +118,10 @@ public class CSVFormaterTest extends TestCase
participantAttributes.put(THROUGHPUT, 2048);
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(LATENCY_STANDARD_DEVIATION, 2.0f);
return participantAttributes;
}
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 cfffb1e549..ada2303d46 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
-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 \ No newline at end of file
+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
diff --git a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ControllerQueue.java b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ControllerQueue.java
index 7f0c23eb38..75783eef4b 100644
--- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ControllerQueue.java
+++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ControllerQueue.java
@@ -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.
+ *
+ */
package org.apache.qpid.systest.disttest.clientonly;
import java.util.Map;
@@ -66,7 +86,7 @@ public class ControllerQueue
public <T extends Command> T getNext(boolean assertMessageExists) throws JMSException
{
- final Message message = _controllerQueueMessageConsumer.receive(1000);
+ final Message message = _controllerQueueMessageConsumer.receive(2000);
if(assertMessageExists)
{
Assert.assertNotNull("No message received from control queue", message);
diff --git a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java
index 4a872a7ee2..5b5a60ac43 100644
--- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java
@@ -32,6 +32,7 @@ import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
+import org.apache.qpid.client.AMQSession;
import org.apache.qpid.disttest.client.Client;
import org.apache.qpid.disttest.client.ClientState;
import org.apache.qpid.disttest.jms.ClientJmsDelegate;
@@ -158,7 +159,7 @@ public class DistributedClientTest extends DistributedTestSystemTestBase
assertState(_client, RUNNING_TEST);
}
- public void testParticipantsSendResults() throws JMSException
+ public void testParticipantsSendResults() throws Exception
{
createTestProducer(TEST_SESSION_NAME, TEST_PRODUCER_NAME, TEST_DESTINATION);
@@ -204,20 +205,21 @@ public class DistributedClientTest extends DistributedTestSystemTestBase
assertState(_client, READY);
}
- private void sendCommandToClient(final Command command) throws JMSException
+ private void sendCommandToClient(final Command command) throws Exception
{
final Message message = JmsMessageAdaptor.commandToMessage(_session, command);
_clientQueueProducer.send(message);
+ ((AMQSession<?, ?>)_session).sync();
}
- private void sendCommandAndValidateResponse(final Command command, boolean shouldSucceed) throws JMSException
+ private void sendCommandAndValidateResponse(final Command command, boolean shouldSucceed) throws Exception
{
sendCommandToClient(command);
Response response = _controllerQueue.getNext();
validateResponse(command.getType(), response, shouldSucceed);
}
- private void sendCommandAndValidateResponse(final Command command) throws JMSException
+ private void sendCommandAndValidateResponse(final Command command) throws Exception
{
sendCommandAndValidateResponse(command, true);
}
@@ -258,7 +260,7 @@ public class DistributedClientTest extends DistributedTestSystemTestBase
createTestSession(connectionName, sessionName, true);
}
- private void createTestProducer(String sessionName, String producerName, String destinationName, boolean shouldSucceed) throws JMSException
+ private void createTestProducer(String sessionName, String producerName, String destinationName, boolean shouldSucceed) throws Exception
{
final CreateProducerCommand createProducerCommand = new CreateProducerCommand();
createProducerCommand.setParticipantName(producerName);
@@ -269,12 +271,12 @@ public class DistributedClientTest extends DistributedTestSystemTestBase
sendCommandAndValidateResponse(createProducerCommand, shouldSucceed);
}
- private void createTestProducer(String sessionName, String producerName, String destinationName) throws JMSException
+ private void createTestProducer(String sessionName, String producerName, String destinationName) throws Exception
{
createTestProducer(sessionName, producerName, destinationName, true);
}
- private void createTestConsumer(String sessionName, String consumerName, String destinationName, boolean shouldSucceed) throws JMSException
+ private void createTestConsumer(String sessionName, String consumerName, String destinationName, boolean shouldSucceed) throws Exception
{
final CreateConsumerCommand createConsumerCommand = new CreateConsumerCommand();
createConsumerCommand.setSessionName(sessionName);
@@ -285,7 +287,7 @@ public class DistributedClientTest extends DistributedTestSystemTestBase
sendCommandAndValidateResponse(createConsumerCommand, shouldSucceed);
}
- private void createTestConsumer(String sessionName, String consumerName, String destinationName) throws JMSException
+ private void createTestConsumer(String sessionName, String consumerName, String destinationName) throws Exception
{
createTestConsumer(sessionName, consumerName, destinationName, true);
}
diff --git a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java
index 9fd90d3215..ddb4cb7e51 100644
--- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java
@@ -23,6 +23,7 @@ import static org.apache.qpid.systest.disttest.SystemTestConstants.COMMAND_RESPO
import static org.apache.qpid.systest.disttest.SystemTestConstants.REGISTRATION_TIMEOUT;
import static org.apache.qpid.systest.disttest.SystemTestConstants.TEST_RESULT_TIMEOUT;
+import java.util.Collection;
import java.util.List;
import javax.jms.Message;
@@ -31,7 +32,7 @@ import javax.jms.Queue;
import javax.jms.Session;
import javax.naming.NamingException;
-import org.apache.qpid.disttest.ConfigFileHelper;
+import org.apache.qpid.disttest.ConfigFileTestHelper;
import org.apache.qpid.disttest.client.Client;
import org.apache.qpid.disttest.client.ClientState;
import org.apache.qpid.disttest.controller.Controller;
@@ -73,6 +74,19 @@ public class ControllerAndClientTest extends DistributedTestSystemTestBase
List<ParticipantResult> test1ParticipantResults = testResult1.getParticipantResults();
assertEquals("Unexpected number of participant results for test 1", 2, test1ParticipantResults.size());
assertParticipantNames(test1ParticipantResults, "participantConsumer1", "participantProducer1");
+ ConsumerParticipantResult result = null;
+ for (ParticipantResult participantResult : test1ParticipantResults)
+ {
+ if (participantResult instanceof ConsumerParticipantResult)
+ {
+ result = (ConsumerParticipantResult)participantResult;
+ break;
+ }
+ }
+ assertNotNull("Consumer results not recived", result);
+ Collection<Long> latencies = result.getMessageLatencies();
+ assertNotNull("Latency results are not collected", latencies);
+ assertEquals("Unexpected latency results", 1, latencies.size());
}
public void testProducerClient() throws Exception
@@ -86,7 +100,7 @@ public class ControllerAndClientTest extends DistributedTestSystemTestBase
// cleaning manually
while(consumer.receive(1000l) != null);
- final Config config = ConfigFileHelper.getConfigFromResource(getClass(), "produceClient.json");
+ final Config config = ConfigFileTestHelper.getConfigFromResource(getClass(), "produceClient.json");
_controller.setConfig(config);
final Client client1 = new Client(new ClientJmsDelegate(_context));
final Thread client1Thread = createBackgroundClientThread(client1);
@@ -151,7 +165,7 @@ public class ControllerAndClientTest extends DistributedTestSystemTestBase
List<ParticipantResult> test1ParticipantResults = testResult.getParticipantResults();
assertEquals("Unexpected number of participant results for test", 2, test1ParticipantResults.size());
- ParticipantResult producer1 = (ParticipantResult) test1ParticipantResults.get(1);
+ ParticipantResult producer1 = test1ParticipantResults.get(1);
assertEquals(expectedMessageSize, producer1.getPayloadSize());
assertEquals(iterationNumber, producer1.getIterationNumber());
@@ -167,7 +181,7 @@ public class ControllerAndClientTest extends DistributedTestSystemTestBase
private List<TestResult> runTestsForTwoClients(String jsonConfigFile, int expectedNumberOfTests) throws NamingException, InterruptedException
{
- final Config config = ConfigFileHelper.getConfigFromResource(getClass(), jsonConfigFile);
+ final Config config = ConfigFileTestHelper.getConfigFromResource(getClass(), jsonConfigFile);
_controller.setConfig(config);
final Client client1 = new Client(new ClientJmsDelegate(_context));
diff --git a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json
index 8d210dce84..a008dc40d8 100644
--- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json
+++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json
@@ -42,7 +42,8 @@
{
"_name": "participantConsumer1",
"_destinationName": "direct://amq.direct//testQueue",
- "_numberOfMessages": 1
+ "_numberOfMessages": 1,
+ "_evaluateLatency": true
}
]
}
diff --git a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java
index ad7f0e0682..74c4724901 100644
--- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java
@@ -38,7 +38,7 @@ import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TemporaryQueue;
-import org.apache.qpid.disttest.ConfigFileHelper;
+import org.apache.qpid.disttest.ConfigFileTestHelper;
import org.apache.qpid.disttest.controller.Controller;
import org.apache.qpid.disttest.controller.config.Config;
import org.apache.qpid.disttest.jms.ControllerJmsDelegate;
@@ -96,7 +96,7 @@ public class DistributedControllerTest extends DistributedTestSystemTestBase
public void testControllerSendsOneCommandToSingleClient() throws Exception
{
- Config config = ConfigFileHelper.getConfigFromResource(getClass(), "distributedControllerTest.json");
+ Config config = ConfigFileTestHelper.getConfigFromResource(getClass(), "distributedControllerTest.json");
_controller.setConfig(config);
sendRegistration(CLIENT1);
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 63c9b42858..7e58e1b5b1 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
@@ -62,10 +62,10 @@ public class EndToEndTest extends QpidBrokerTestCase
assertEquals("Unexpected number of lines in CSV", numberOfExpectedRows, csvLines.length);
assertDataRowsHaveCorrectTestAndClientName("End To End 1", "producingClient", "participantProducer1", csvLines[1], 1);
- assertDataRowsHaveCorrectTestAndClientName("End To End 1", "consumingClient", "participantConsumer1", csvLines[2], 1);
+ assertDataRowsHaveCorrectTestAndClientName("End To End 1", "consumingClient", "participantConsumer1", csvLines[3], 1);
- assertDataRowsHaveCorrectTestAndClientName("End To End 1", "", TestResultAggregator.ALL_PARTICIPANTS_NAME, csvLines[3], 1);
- assertDataRowsHaveCorrectTestAndClientName("End To End 1", "", TestResultAggregator.ALL_CONSUMER_PARTICIPANTS_NAME, csvLines[4], 1);
+ assertDataRowsHaveCorrectTestAndClientName("End To End 1", "", TestResultAggregator.ALL_PARTICIPANTS_NAME, csvLines[4], 1);
+ assertDataRowsHaveCorrectTestAndClientName("End To End 1", "", TestResultAggregator.ALL_CONSUMER_PARTICIPANTS_NAME, csvLines[2], 1);
assertDataRowsHaveCorrectTestAndClientName("End To End 1", "", TestResultAggregator.ALL_PRODUCER_PARTICIPANTS_NAME, csvLines[5], 1);
}