You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2012/08/29 23:53:03 UTC

svn commit: r1378751 - in /qpid/trunk/qpid/java/perftests/src: main/java/org/apache/qpid/disttest/ main/java/org/apache/qpid/disttest/controller/ main/java/org/apache/qpid/disttest/message/ main/java/org/apache/qpid/disttest/results/aggregation/ main/j...

Author: kwall
Date: Wed Aug 29 21:53:02 2012
New Revision: 1378751

URL: http://svn.apache.org/viewvc?rev=1378751&view=rev
Log:
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 <ph...@philharveyonline.com>

Added:
    qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ResultsFileWriter.java
    qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormatter.java
      - copied, changed from r1378663, qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormater.java
    qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java
    qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java
      - copied, changed from r1378663, qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java
Removed:
    qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormater.java
    qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java
Modified:
    qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java
    qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java
    qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java
    qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java
    qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java
    qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java
    qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java
    qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java
    qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv
    qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java

Modified: qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java?rev=1378751&r1=1378750&r2=1378751&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java (original)
+++ qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java Wed Aug 29 21:53:02 2012
@@ -60,15 +60,4 @@ public class ConfigFileHelper
 
         return testConfigFile;
     }
-
-    /**
-     * generateOutputCsvNameFrom("/config/testConfigFile.js", "/output") returns /output/testConfigFile.csv
-     */
-    public String generateOutputCsvNameFrom(String testConfigFile, String outputDir)
-    {
-        final String filenameOnlyWithExtension = new File(testConfigFile).getName();
-        final String cvsFile = filenameOnlyWithExtension.replaceFirst(".?\\w*$", ".csv");
-
-        return new File(outputDir, cvsFile).getAbsolutePath();
-    }
 }

Modified: qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java?rev=1378751&r1=1378750&r2=1378751&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java (original)
+++ qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java Wed Aug 29 21:53:02 2012
@@ -19,9 +19,9 @@
  */
 package org.apache.qpid.disttest;
 
+import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.naming.Context;
@@ -32,7 +32,6 @@ import org.apache.qpid.disttest.controll
 import org.apache.qpid.disttest.controller.config.ConfigReader;
 import org.apache.qpid.disttest.jms.ControllerJmsDelegate;
 import org.apache.qpid.disttest.results.aggregation.Aggregator;
-import org.apache.qpid.disttest.results.formatting.CSVFormater;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,6 +51,8 @@ public class ControllerRunner extends Ab
 
     private final ConfigFileHelper _configFileHelper = new ConfigFileHelper();
 
+    private ResultsFileWriter _resuResultsFileWriter;
+
     public ControllerRunner()
     {
         getCliOptions().put(TEST_CONFIG_PROP, TEST_CONFIG_DEFAULT);
@@ -69,6 +70,7 @@ public class ControllerRunner extends Ab
     public void runController() throws Exception
     {
         Context context = getContext();
+        setUpResultsWriter();
 
         ControllerJmsDelegate jmsDelegate = new ControllerJmsDelegate(context);
 
@@ -82,6 +84,13 @@ public class ControllerRunner extends Ab
         }
     }
 
+    void setUpResultsWriter()
+    {
+        String outputDirString = getCliOptions().get(ControllerRunner.OUTPUT_DIR_PROP);
+        File outputDir = new File(outputDirString);
+        _resuResultsFileWriter = new ResultsFileWriter(outputDir);
+    }
+
     private void runTests(ControllerJmsDelegate jmsDelegate)
     {
         Controller controller = new Controller(jmsDelegate, DistributedTestConstants.REGISTRATION_TIMEOUT, DistributedTestConstants.COMMAND_RESPONSE_TIMEOUT);
@@ -92,6 +101,8 @@ public class ControllerRunner extends Ab
 
         try
         {
+            List<ResultsForAllTests> results = new ArrayList<ResultsForAllTests>();
+
             for (String testConfigFile : testConfigFiles)
             {
                 final Config testConfig = buildTestConfigFrom(testConfigFile);
@@ -100,8 +111,11 @@ public class ControllerRunner extends Ab
                 controller.awaitClientRegistrations();
 
                 LOGGER.info("Running test : " + testConfigFile);
-                runTest(controller, testConfigFile);
+                ResultsForAllTests testResult = runTest(controller, testConfigFile);
+                results.add(testResult);
             }
+
+            _resuResultsFileWriter.writeResultsSummary(results);
         }
         catch(Exception e)
         {
@@ -113,7 +127,7 @@ public class ControllerRunner extends Ab
         }
     }
 
-    private void runTest(Controller controller, String testConfigFile)
+    private ResultsForAllTests runTest(Controller controller, String testConfigFile)
     {
         final Config testConfig = buildTestConfigFrom(testConfigFile);
         controller.setConfig(testConfig);
@@ -121,9 +135,8 @@ public class ControllerRunner extends Ab
         ResultsForAllTests rawResultsForAllTests = controller.runAllTests();
         ResultsForAllTests resultsForAllTests = _aggregator.aggregateResults(rawResultsForAllTests);
 
-        String outputDir = getCliOptions().get(ControllerRunner.OUTPUT_DIR_PROP);
-        final String outputFile = _configFileHelper.generateOutputCsvNameFrom(testConfigFile, outputDir);
-        writeResultsToFile(resultsForAllTests, outputFile);
+        _resuResultsFileWriter.writeResultsToFile(resultsForAllTests, testConfigFile);
+        return resultsForAllTests;
     }
 
     private void createClientsIfNotDistributed(final List<String> testConfigFiles)
@@ -148,36 +161,6 @@ public class ControllerRunner extends Ab
         }
     }
 
-    private void writeResultsToFile(ResultsForAllTests resultsForAllTests, String outputFile)
-    {
-        FileWriter writer = null;
-        try
-        {
-            final String outputCsv = new CSVFormater().format(resultsForAllTests);
-            writer = new FileWriter(outputFile);
-            writer.write(outputCsv);
-            LOGGER.info("Wrote " + resultsForAllTests.getTestResults().size() + " test result(s) to output file " + outputFile);
-        }
-        catch (IOException e)
-        {
-            throw new DistributedTestException("Unable to write output file " + outputFile, e);
-        }
-        finally
-        {
-            if (writer != null)
-            {
-                try
-                {
-                    writer.close();
-                }
-                catch (IOException e)
-                {
-                    LOGGER.error("Failed to close stream for file " + outputFile, e);
-                }
-            }
-        }
-    }
-
     private Config buildTestConfigFrom(String testConfigFile)
     {
         ConfigReader configReader = new ConfigReader();

Added: qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ResultsFileWriter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ResultsFileWriter.java?rev=1378751&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ResultsFileWriter.java (added)
+++ qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/ResultsFileWriter.java Wed Aug 29 21:53:02 2012
@@ -0,0 +1,112 @@
+/*
+ * 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.FileWriter;
+import java.io.IOException;
+import java.util.List;
+
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ResultsFileWriter
+{
+    private static final Logger LOGGER = LoggerFactory.getLogger(ResultsFileWriter.class);
+
+    static final String TEST_SUMMARY_FILE_NAME = "test-summary.csv";
+
+    private final File _outputDir;
+
+    private CSVFormatter _csvFormater = new CSVFormatter();
+
+    private TestResultAggregator _testResultAggregator = new TestResultAggregator();
+
+    public ResultsFileWriter(File outputDir)
+    {
+        _outputDir = outputDir;
+    }
+
+    public void writeResultsToFile(ResultsForAllTests resultsForAllTests, String testConfigFile)
+    {
+        final String outputFile = generateOutputCsvNameFrom(testConfigFile);
+        writeResultsToOutputFile(resultsForAllTests, outputFile);
+    }
+
+    public void writeResultsSummary(List<ResultsForAllTests> allResultsList)
+    {
+        ResultsForAllTests combinedResults = _testResultAggregator.aggregateTestResults(allResultsList);
+        writeResultsToOutputFile(combinedResults, new File(_outputDir, TEST_SUMMARY_FILE_NAME).getAbsolutePath());
+    }
+
+    /**
+     * generateOutputCsvNameFrom("/config/testConfigFile.js", "/output") returns /output/testConfigFile.csv
+     */
+    private String generateOutputCsvNameFrom(String testConfigFile)
+    {
+        final String filenameOnlyWithExtension = new File(testConfigFile).getName();
+        final String cvsFile = filenameOnlyWithExtension.replaceFirst(".?\\w*$", ".csv");
+
+        return new File(_outputDir, cvsFile).getAbsolutePath();
+    }
+
+    private void writeResultsToOutputFile(ResultsForAllTests resultsForAllTests, String outputFile)
+    {
+        FileWriter writer = null;
+        try
+        {
+            final String outputCsv = _csvFormater.format(resultsForAllTests);
+            writer = new FileWriter(outputFile);
+            writer.write(outputCsv);
+            LOGGER.info("Wrote " + resultsForAllTests.getTestResults().size() + " test result(s) to output file " + outputFile);
+        }
+        catch (IOException e)
+        {
+            throw new DistributedTestException("Unable to write output file " + outputFile, e);
+        }
+        finally
+        {
+            if (writer != null)
+            {
+                try
+                {
+                    writer.close();
+                }
+                catch (IOException e)
+                {
+                    LOGGER.error("Failed to close stream for file " + outputFile, e);
+                }
+            }
+        }
+    }
+
+    void setCsvFormater(CSVFormatter csvFormater)
+    {
+        _csvFormater = csvFormater;
+    }
+
+    void setTestResultAggregator(TestResultAggregator testResultAggregator)
+    {
+        _testResultAggregator = testResultAggregator;
+    }
+
+}

Modified: qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java?rev=1378751&r1=1378750&r2=1378751&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java (original)
+++ qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java Wed Aug 29 21:53:02 2012
@@ -21,7 +21,9 @@ package org.apache.qpid.disttest.control
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.qpid.disttest.message.ParticipantResult;
 import org.apache.qpid.disttest.results.aggregation.ITestResult;
+import org.apache.qpid.disttest.results.aggregation.TestResultAggregator;
 
 public class ResultsForAllTests
 {
@@ -46,4 +48,23 @@ public class ResultsForAllTests
     {
         return _hasErrors;
     }
+
+    public ResultsForAllTests getAllParticipantsResult()
+    {
+        ResultsForAllTests summaryResultsForAllTests = new ResultsForAllTests();
+
+        for (ITestResult testResult : _results)
+        {
+            for(ParticipantResult participantResult : testResult.getParticipantResults())
+            {
+                if(TestResultAggregator.ALL_CONSUMER_PARTICIPANTS_NAME.equals(participantResult.getParticipantName()))
+                {
+                    TestResult summaryTestResult = new TestResult(testResult.getName());
+                    summaryTestResult.addParticipantResult(participantResult);
+                    summaryResultsForAllTests.add(summaryTestResult);
+                }
+            }
+        }
+        return summaryResultsForAllTests;
+    }
 }

Modified: qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java?rev=1378751&r1=1378750&r2=1378751&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java (original)
+++ qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java Wed Aug 29 21:53:02 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.qpid.disttest.message;
 
+import java.text.DecimalFormat;
+
 import org.apache.qpid.disttest.client.Participant;
 
 /**
@@ -31,6 +33,8 @@ public enum ParticipantAttribute
 {
     TEST_NAME("testName"),
     ITERATION_NUMBER("iterationNumber"),
+    THROUGHPUT("throughputKbPerS", "#"),
+    AVERAGE_LATENCY("averageLatency", "#"),
     CONFIGURED_CLIENT_NAME("clientName"),
     PARTICIPANT_NAME("participantName"),
     NUMBER_OF_MESSAGES_PROCESSED("numberOfMessages"),
@@ -52,24 +56,55 @@ public enum ParticipantAttribute
     TOTAL_NUMBER_OF_CONSUMERS("totalNumberOfConsumers"),
     TOTAL_NUMBER_OF_PRODUCERS("totalNumberOfProducers"),
     TOTAL_PAYLOAD_PROCESSED("totalPayloadProcessedB"),
-    THROUGHPUT("throughputKbPerS"),
     TIME_TAKEN("timeTakenMs"),
     ERROR_MESSAGE("errorMessage"),
     MIN_LATENCY("minLatency"),
     MAX_LATENCY("maxLatency"),
-    AVERAGE_LATENCY("averageLatency"),
     LATENCY_STANDARD_DEVIATION("latencyStandardDeviation")
     ;
 
     private String _displayName;
+    private String _decimalFormat;
 
     ParticipantAttribute(String displayName)
     {
         _displayName = displayName;
     }
 
+    ParticipantAttribute(String displayName, String decimalFormat)
+    {
+        _displayName = displayName;
+        _decimalFormat = decimalFormat;
+    }
+
+    public String getDecimalFormat()
+    {
+        return _decimalFormat;
+    }
+
     public String getDisplayName()
     {
         return _displayName;
     }
+
+    public String format(Object attributeValue)
+    {
+        if(attributeValue == null)
+        {
+            return null;
+        }
+
+        String attributeAsString = String.valueOf(attributeValue);
+
+        if(_decimalFormat != null)
+        {
+            DecimalFormat decimalFormat = new DecimalFormat(_decimalFormat);
+            double attributeAsDoule = Double.valueOf(attributeAsString);
+            return decimalFormat.format(attributeAsDoule);
+        }
+        else
+        {
+            return attributeAsString;
+        }
+    }
 }

Modified: qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java?rev=1378751&r1=1378750&r2=1378751&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java (original)
+++ qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java Wed Aug 29 21:53:02 2012
@@ -22,10 +22,8 @@ import java.util.List;
 
 import org.apache.qpid.disttest.message.ParticipantResult;
 
-// TODO rename me!!
 public interface ITestResult
 {
-
     // TODO  should weaken to Collection
     List<ParticipantResult> getParticipantResults();
 

Modified: qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java?rev=1378751&r1=1378750&r2=1378751&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java (original)
+++ qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java Wed Aug 29 21:53:02 2012
@@ -18,6 +18,9 @@
  */
 package org.apache.qpid.disttest.results.aggregation;
 
+import java.util.List;
+
+import org.apache.qpid.disttest.controller.ResultsForAllTests;
 import org.apache.qpid.disttest.message.ConsumerParticipantResult;
 import org.apache.qpid.disttest.message.ParticipantResult;
 import org.apache.qpid.disttest.message.ProducerParticipantResult;
@@ -103,4 +106,24 @@ public class TestResultAggregator
         aggregatedAllResult.setTotalPayloadProcessed(aggregatedConsumerResult.getTotalPayloadProcessed());
         aggregatedAllResult.setThroughput(aggregatedConsumerResult.getThroughput());
     }
+
+    /**
+     * Produces a single {@link ResultsForAllTests} from the supplied list, only containing
+     * the "All participants" results.
+     */
+    public ResultsForAllTests aggregateTestResults(List<ResultsForAllTests> allResultsList)
+    {
+        ResultsForAllTests retVal = new ResultsForAllTests();
+
+        for (ResultsForAllTests resultsForAllTests : allResultsList)
+        {
+            ResultsForAllTests allParticipantsResult = resultsForAllTests.getAllParticipantsResult();
+            for (ITestResult testResult : allParticipantsResult.getTestResults())
+            {
+                retVal.add(testResult);
+            }
+        }
+
+        return retVal;
+    }
 }

Copied: qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormatter.java (from r1378663, qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormater.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormatter.java?p2=qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormatter.java&p1=qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormater.java&r1=1378663&r2=1378751&rev=1378751&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormater.java (original)
+++ qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormatter.java Wed Aug 29 21:53:02 2012
@@ -32,7 +32,7 @@ import org.apache.qpid.disttest.results.
 /**
  * produces CSV output using the ordered enums in {@link ParticipantAttribute}
  */
-public class CSVFormater
+public class CSVFormatter
 {
     public String format(ResultsForAllTests results)
     {
@@ -66,7 +66,9 @@ public class CSVFormater
         List<Object> attributeValues = new ArrayList<Object>();
         for (ParticipantAttribute attribute : ParticipantAttribute.values())
         {
-            attributeValues.add(attributeValueMap.get(attribute));
+            Object attributeValue = attributeValueMap.get(attribute);
+            String attributeValueFormatted = attribute.format(attributeValue);
+            attributeValues.add(attributeValueFormatted);
         }
 
         String row = StringUtils.join(attributeValues.toArray(), ",");

Modified: qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java?rev=1378751&r1=1378750&r2=1378751&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java (original)
+++ qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java Wed Aug 29 21:53:02 2012
@@ -39,14 +39,6 @@ public class ConfigFileHelperTest extend
         _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");

Added: qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java?rev=1378751&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java (added)
+++ qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java Wed Aug 29 21:53:02 2012
@@ -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));
+    }
+
+}

Modified: qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java?rev=1378751&r1=1378750&r2=1378751&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java (original)
+++ qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java Wed Aug 29 21:53:02 2012
@@ -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.
 
 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 ex
 
     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 ex
         participantResult.setEndDate(new Date(end));
         participantResult.setBatchSize(batchSize);
     }
+
 }

Copied: qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java (from r1378663, qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java?p2=qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java&p1=qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java&r1=1378663&r2=1378751&rev=1378751&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java (original)
+++ qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java Wed Aug 29 21:53:02 2012
@@ -59,13 +59,13 @@ import org.apache.qpid.disttest.controll
 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 Tes
         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 Tes
 
         return output.toString();
     }
-
 }

Modified: qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv?rev=1378751&r1=1378750&r2=1378751&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv (original)
+++ qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv Wed Aug 29 21:53:02 2012
@@ -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

Modified: qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java?rev=1378751&r1=1378750&r2=1378751&view=diff
==============================================================================
--- qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java (original)
+++ qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java Wed Aug 29 21:53:02 2012
@@ -76,10 +76,10 @@ public class EndToEndTest extends QpidBr
         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()]);
 
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org