diff options
| author | Keith Wall <kwall@apache.org> | 2012-08-29 21:53:02 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2012-08-29 21:53:02 +0000 |
| commit | 0e96a636c825288987e07212aa556197e0fb43f6 (patch) | |
| tree | bf0888e3b9e8c3f9cf64166e173c0e73fd8f0047 /qpid/java/perftests/src/test | |
| parent | 9bd10d81a6676a8fae6a4ff03c4142f80a27f011 (diff) | |
| download | qpid-python-0e96a636c825288987e07212aa556197e0fb43f6.tar.gz | |
QPID-4143 now producing test-summary.csv to make viewing all the 'all participants' test results more convenient. Re-ordered columns so that the important stuff appears first.
Applied patch from Philip Harvey <phil@philharveyonline.com>
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1378751 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/perftests/src/test')
| -rw-r--r-- | qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java | 8 | ||||
| -rw-r--r-- | qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java | 86 | ||||
| -rw-r--r-- | qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java | 35 | ||||
| -rw-r--r-- | qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java (renamed from qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java) | 9 | ||||
| -rw-r--r-- | qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv | 4 | ||||
| -rw-r--r-- | qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java | 8 |
6 files changed, 128 insertions, 22 deletions
diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java index a10b3b359e..629442d86c 100644 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java +++ b/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java @@ -39,14 +39,6 @@ public class ConfigFileHelperTest extends QpidTestCase _testDir = TestFileUtils.createTestDirectory(); } - public void testGenerateOutputCsvNameFrom() - { - String outputDir = "/tmp/outputDir"; - - assertEquals("/tmp/outputDir/my.json.file.csv", _configFileHelper.generateOutputCsvNameFrom("/tmp/my.json.file.json", outputDir)); - assertEquals("/tmp/outputDir/my.js.file.csv", _configFileHelper.generateOutputCsvNameFrom("/tmp/my.js.file.js", outputDir)); - } - public void testGetTestConfigFilesForDirectory() throws Exception { String jsFile = createFile("file1.js"); diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java new file mode 100644 index 0000000000..abe000f072 --- /dev/null +++ b/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.qpid.disttest; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.util.Arrays; + +import junit.framework.TestCase; + +import org.apache.qpid.disttest.controller.ResultsForAllTests; +import org.apache.qpid.disttest.results.aggregation.TestResultAggregator; +import org.apache.qpid.disttest.results.formatting.CSVFormatter; +import org.apache.qpid.test.utils.TestFileUtils; +import org.apache.qpid.util.FileUtils; + +public class ResultsFileWriterTest extends TestCase +{ + private CSVFormatter _csvFormater = mock(CSVFormatter.class); + private TestResultAggregator _testResultAggregator = mock(TestResultAggregator.class); + + private File _outputDir = TestFileUtils.createTestDirectory(); + + private ResultsFileWriter _resultsFileWriter = new ResultsFileWriter(_outputDir); + + @Override + public void setUp() + { + _resultsFileWriter.setCsvFormater(_csvFormater); + _resultsFileWriter.setTestResultAggregator(_testResultAggregator); + } + + public void testWriteResultsToFile() + { + ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class); + + String expectedCsvContents = "expected-csv-contents"; + when(_csvFormater.format(resultsForAllTests)).thenReturn(expectedCsvContents); + + _resultsFileWriter.writeResultsToFile(resultsForAllTests, "config.json"); + + File resultsFile = new File(_outputDir, "config.csv"); + + assertEquals(expectedCsvContents, FileUtils.readFileAsString(resultsFile)); + } + + public void testWriteResultsSummary() + { + ResultsForAllTests results1 = mock(ResultsForAllTests.class); + ResultsForAllTests results2 = mock(ResultsForAllTests.class); + ResultsForAllTests summaryResults = mock(ResultsForAllTests.class); + + when(_testResultAggregator.aggregateTestResults(Arrays.asList(results1, results2))) + .thenReturn(summaryResults); + + String expectedSummaryFileContents = "expected-summary-file"; + + when(_csvFormater.format(summaryResults)) + .thenReturn(expectedSummaryFileContents); + + _resultsFileWriter.writeResultsSummary(Arrays.asList(results1, results2)); + + File summaryFile = new File(_outputDir, ResultsFileWriter.TEST_SUMMARY_FILE_NAME); + + assertEquals(expectedSummaryFileContents, FileUtils.readFileAsString(summaryFile)); + } + +} diff --git a/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 9c00e7cf1c..7cb9ebed5e 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 @@ -18,11 +18,15 @@ */ package org.apache.qpid.disttest.results.aggregation; +import static org.mockito.Mockito.*; + +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; @@ -30,17 +34,14 @@ import org.apache.qpid.disttest.message.ProducerParticipantResult; public class TestResultAggregatorTest extends TestCase { - 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(); @@ -197,4 +225,5 @@ public class TestResultAggregatorTest extends TestCase participantResult.setEndDate(new Date(end)); participantResult.setBatchSize(batchSize); } + } 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/CSVFormatterTest.java index 565f59d25b..0d66c7ffb5 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/CSVFormatterTest.java @@ -59,13 +59,13 @@ import org.apache.qpid.disttest.controller.TestResult; import org.apache.qpid.disttest.message.ParticipantAttribute; import org.apache.qpid.disttest.message.ParticipantResult; -public class CSVFormaterTest extends TestCase +public class CSVFormatterTest extends TestCase { 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(); + private CSVFormatter _formatter = new CSVFormatter(); public void testResultsFileWithWithOneRow() throws Exception { @@ -115,12 +115,12 @@ 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, 2048.49); 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); return participantAttributes; } @@ -142,5 +142,4 @@ public class CSVFormaterTest extends TestCase return output.toString(); } - } 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 ada2303d46..a5881e187a 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,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 +TEST1,0,2048,5,CONFIGURED_CLIENT1,PARTICIPANT,0,1,2,3,4,5,6,7,8,9,true,false,true,false,true,false,1,2,1024,1000,error,2,9,2.0 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 7e58e1b5b1..75242e06cc 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 @@ -76,10 +76,10 @@ public class EndToEndTest extends QpidBrokerTestCase String[] cells = csvLine.split(",", DONT_STRIP_EMPTY_LAST_FIELD_FLAG); // All attributes become cells in the CSV, so this will be true assertEquals("Unexpected number of cells in CSV line " + csvLine, ParticipantAttribute.values().length, cells.length); - assertEquals("Unexpected test name in CSV line " + csvLine, testName, cells[0]); - assertEquals("Unexpected client name in CSV line " + csvLine, clientName, cells[2]); - assertEquals("Unexpected participant name in CSV line " + csvLine, participantName, cells[3]); - assertEquals("Unexpected number of messages processed in CSV line " + csvLine, String.valueOf(expectedNumberOfMessagesProcessed), cells[4]); + assertEquals("Unexpected test name in CSV line " + csvLine, testName, cells[ParticipantAttribute.TEST_NAME.ordinal()]); + assertEquals("Unexpected client name in CSV line " + csvLine, clientName, cells[ParticipantAttribute.CONFIGURED_CLIENT_NAME.ordinal()]); + assertEquals("Unexpected participant name in CSV line " + csvLine, participantName, cells[ParticipantAttribute.PARTICIPANT_NAME.ordinal()]); + assertEquals("Unexpected number of messages processed in CSV line " + csvLine, String.valueOf(expectedNumberOfMessagesProcessed), cells[ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED.ordinal()]); } |
