diff options
Diffstat (limited to 'java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java')
-rw-r--r-- | java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java | 45 |
1 files changed, 39 insertions, 6 deletions
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); } + } |