diff options
Diffstat (limited to 'java/perftests/src/test/java/org/apache/qpid/disttest/results')
8 files changed, 163 insertions, 57 deletions
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 |