Search in sources :

Example 1 with ITestResult

use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.

the class ResultsForAllTests method getAllParticipantsResult.

public List<ITestResult> getAllParticipantsResult() {
    List<ITestResult> results = new ArrayList<>(_results.size());
    for (ITestResult testResult : _results) {
        for (ParticipantResult participantResult : testResult.getParticipantResults()) {
            if (TestResultAggregator.ALL_PARTICIPANTS_NAME.equals(participantResult.getParticipantName())) {
                TestResult summaryTestResult = new TestResult(testResult.getName());
                summaryTestResult.addParticipantResult(participantResult);
                results.add(summaryTestResult);
            }
        }
    }
    return results;
}
Also used : ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult) ArrayList(java.util.ArrayList) ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult)

Example 2 with ITestResult

use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.

the class Controller method runAllTests.

public ResultsForAllTests runAllTests() {
    LOGGER.info("Running all tests");
    ResultsForAllTests resultsForAllTests = new ResultsForAllTests();
    for (TestInstance testInstance : _config.getTests()) {
        ParticipatingClients participatingClients = new ParticipatingClients(_clientRegistry, testInstance.getClientNames());
        ITestRunner runner = _testRunnerFactory.createTestRunner(participatingClients, testInstance, _jmsDelegate, _commandResponseTimeout, AbstractTestRunner.WAIT_FOREVER, _options);
        LOGGER.info("Running test {}. Participating clients: {}", testInstance, participatingClients.getRegisteredNames());
        ITestResult result = runner.run();
        if (result != null) {
            LOGGER.info("Finished test {}, result {}", testInstance, result);
            resultsForAllTests.add(result);
        } else {
            LOGGER.warn("Finished test {} without producing a result.", testInstance);
        }
    }
    return resultsForAllTests;
}
Also used : TestInstance(org.apache.qpid.disttest.controller.config.TestInstance) ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult)

Example 3 with ITestResult

use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.

the class ResultsXmlWriterTest method testResultForOneTest.

@Test
public void testResultForOneTest() throws Exception {
    ITestResult test = mock(ITestResult.class);
    when(test.getName()).thenReturn("mytest");
    ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class);
    when(resultsForAllTests.getTestResults()).thenReturn(Collections.singletonList(test));
    String expectedXmlContent = String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n" + "<testsuite tests=\"1\">%n" + "  <testcase classname=\"config.json\" name=\"mytest\"/>%n" + "</testsuite>%n");
    _resultsFileWriter.writeResults(resultsForAllTests, "config.json");
    File resultsFile = new File(_outputDir, "config.xml");
    assertEquals(expectedXmlContent, Resources.toString(resultsFile.toURI().toURL(), StandardCharsets.UTF_8));
}
Also used : ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult) File(java.io.File) ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests) Test(org.junit.Test)

Example 4 with ITestResult

use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.

the class ResultsCsvWriterTest method testWriteResultsToFile.

@Test
public void testWriteResultsToFile() throws Exception {
    List<ITestResult> testResult1 = mock(List.class);
    ResultsForAllTests results1 = mock(ResultsForAllTests.class);
    when(results1.getTestResults()).thenReturn(testResult1);
    List<ITestResult> testResult2 = mock(List.class);
    ResultsForAllTests results2 = mock(ResultsForAllTests.class);
    when(results2.getTestResults()).thenReturn(testResult2);
    String expectedCsvContents1 = "expected-csv-contents1";
    String expectedCsvContents2 = "expected-csv-contents2";
    String expectedSummaryFileContents = "expected-summary-file";
    when(_csvFormater.format(testResult1)).thenReturn(expectedCsvContents1);
    when(_csvFormater.format(testResult2)).thenReturn(expectedCsvContents2);
    _resultsFileWriter.begin();
    _resultsFileWriter.writeResults(results1, "config1.json");
    File resultsFile1 = new File(_outputDir, "config1.csv");
    assertEquals(expectedCsvContents1, Resources.toString(resultsFile1.toURI().toURL(), StandardCharsets.UTF_8));
    _resultsFileWriter.writeResults(results2, "config2.json");
    File resultsFile2 = new File(_outputDir, "config2.csv");
    assertEquals(expectedCsvContents2, Resources.toString(resultsFile2.toURI().toURL(), StandardCharsets.UTF_8));
    when(_csvFormater.format(any(List.class))).thenReturn(expectedSummaryFileContents);
    _resultsFileWriter.end();
    File summaryFile = new File(_outputDir, ResultsCsvWriter.TEST_SUMMARY_FILE_NAME);
    assertEquals(expectedSummaryFileContents, Resources.toString(summaryFile.toURI().toURL(), StandardCharsets.UTF_8));
}
Also used : ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult) List(java.util.List) File(java.io.File) ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests) Test(org.junit.Test)

Example 5 with ITestResult

use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.

the class ResultsXmlWriterTest method testResultForOneTestWithError.

@Test
public void testResultForOneTestWithError() throws Exception {
    ParticipantResult resultWithError = mock(ParticipantResult.class);
    when(resultWithError.hasError()).thenReturn(true);
    when(resultWithError.getErrorMessage()).thenReturn("something went wrong");
    ITestResult test = mock(ITestResult.class);
    when(test.getName()).thenReturn("mytest");
    when(test.hasErrors()).thenReturn(true);
    when(test.getParticipantResults()).thenReturn(Collections.singletonList(resultWithError));
    ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class);
    when(resultsForAllTests.getTestResults()).thenReturn(Collections.singletonList(test));
    String expectedXmlContent = String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n" + "<testsuite tests=\"1\">%n" + "  <testcase classname=\"config.json\" name=\"mytest\">%n" + "    <error message=\"something went wrong\"/>%n" + "  </testcase>%n" + "</testsuite>%n");
    _resultsFileWriter.writeResults(resultsForAllTests, "config.json");
    File resultsFile = new File(_outputDir, "config.xml");
    assertEquals(expectedXmlContent, Resources.toString(resultsFile.toURI().toURL(), StandardCharsets.UTF_8));
}
Also used : ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult) File(java.io.File) ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests) Test(org.junit.Test)

Aggregations

ITestResult (org.apache.qpid.disttest.results.aggregation.ITestResult)8 ParticipantResult (org.apache.qpid.disttest.message.ParticipantResult)5 File (java.io.File)4 ResultsForAllTests (org.apache.qpid.disttest.controller.ResultsForAllTests)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 List (java.util.List)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Transformer (javax.xml.transform.Transformer)1 TransformerException (javax.xml.transform.TransformerException)1 DOMSource (javax.xml.transform.dom.DOMSource)1 StreamResult (javax.xml.transform.stream.StreamResult)1 DistributedTestException (org.apache.qpid.disttest.DistributedTestException)1 TestInstance (org.apache.qpid.disttest.controller.config.TestInstance)1 ParticipantAttribute (org.apache.qpid.disttest.message.ParticipantAttribute)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1