diff options
| author | Keith Wall <kwall@apache.org> | 2012-07-02 14:26:36 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2012-07-02 14:26:36 +0000 |
| commit | 220f542e8e00932cfcd3d4c4f7832c58b7fef4cd (patch) | |
| tree | 257838ce9fa6491e2333ef15fd0203c24bb23297 /qpid/java/perftests/src/test | |
| parent | 7d96daca11cde3df099c652b671e3bf8ab2627b6 (diff) | |
| download | qpid-python-220f542e8e00932cfcd3d4c4f7832c58b7fef4cd.tar.gz | |
QPID-4089: Add latency tests into java performance test framework
Applied patch from Oleksandr Rudyy <orudyy@gmail.com>.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1356250 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/perftests/src/test')
8 files changed, 141 insertions, 9 deletions
diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java index ff7cfd2b41..58589d36f4 100644 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java +++ b/qpid/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/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java new file mode 100644 index 0000000000..ec8da8418f --- /dev/null +++ b/qpid/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/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java index a803120cc6..9c00e7cf1c 100644 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java +++ b/qpid/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/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java index 6b4157a9b3..7c6cfed402 100644 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java +++ b/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java @@ -118,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/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv b/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv index cfffb1e549..ada2303d46 100644 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv +++ b/qpid/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/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java index e06ace156f..c103af501c 100644 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java +++ b/qpid/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; @@ -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 diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json index 8d210dce84..a008dc40d8 100644 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json +++ b/qpid/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/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java index 63c9b42858..7e58e1b5b1 100644 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java +++ b/qpid/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); } |
