Search in sources :

Example 1 with ResultsForAllTests

use of org.apache.qpid.disttest.controller.ResultsForAllTests in project qpid-broker-j by apache.

the class ControllerRunner method runTests.

private void runTests(Controller controller, List<String> testConfigFiles) {
    boolean testError = false;
    try {
        List<ResultsForAllTests> results = new ArrayList<>();
        for (String testConfigFile : testConfigFiles) {
            final Config testConfig = buildTestConfigFrom(testConfigFile);
            controller.setConfig(testConfig);
            controller.awaitClientRegistrations();
            LOGGER.info("Running test : {} ", testConfigFile);
            ResultsForAllTests testResult = runTest(controller, testConfigFile);
            if (testResult.hasErrors()) {
                testError = true;
            }
            results.add(testResult);
        }
    } catch (Exception e) {
        LOGGER.error("Problem running test", e);
        throw new DistributedTestException("Problem running tests", e);
    }
    if (testError) {
        throw new DistributedTestException("One or more tests ended in error");
    }
}
Also used : Config(org.apache.qpid.disttest.controller.config.Config) ArrayList(java.util.ArrayList) ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests) IOException(java.io.IOException)

Example 2 with ResultsForAllTests

use of org.apache.qpid.disttest.controller.ResultsForAllTests in project qpid-broker-j by apache.

the class ResultsDbWriterTest method testWriteResults.

@Test
public void testWriteResults() throws Exception {
    Context context = getContext();
    ResultsForAllTests results = _resultsTestFixture.createResultsForAllTests();
    String runId = "myRunId";
    ResultsDbWriter resultsDbWriter = new ResultsDbWriter(context, runId, _clock);
    resultsDbWriter.begin();
    resultsDbWriter.writeResults(results, "testfile");
    ParticipantResult expectedResult = _resultsTestFixture.getFirstParticipantResult(results);
    assertResultsAreInDb(context, expectedResult, runId);
}
Also used : Context(javax.naming.Context) ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests) Test(org.junit.Test)

Example 3 with ResultsForAllTests

use of org.apache.qpid.disttest.controller.ResultsForAllTests in project qpid-broker-j by apache.

the class ResultsXmlWriterTest method testResultForNoTests.

@Test
public void testResultForNoTests() throws Exception {
    ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class);
    String expectedXmlContent = String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n" + "<testsuite tests=\"0\"/>%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 : File(java.io.File) ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests) Test(org.junit.Test)

Example 4 with ResultsForAllTests

use of org.apache.qpid.disttest.controller.ResultsForAllTests 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 5 with ResultsForAllTests

use of org.apache.qpid.disttest.controller.ResultsForAllTests in project qpid-broker-j by apache.

the class ResultsTestFixture method createResultsForAllTests.

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);
    return resultsForAllTests;
}
Also used : ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) ParticipantAttribute(org.apache.qpid.disttest.message.ParticipantAttribute) ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult) TestResult(org.apache.qpid.disttest.controller.TestResult) ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests)

Aggregations

ResultsForAllTests (org.apache.qpid.disttest.controller.ResultsForAllTests)11 Test (org.junit.Test)7 File (java.io.File)4 ITestResult (org.apache.qpid.disttest.results.aggregation.ITestResult)4 ParticipantResult (org.apache.qpid.disttest.message.ParticipantResult)3 Config (org.apache.qpid.disttest.controller.config.Config)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Context (javax.naming.Context)1 TestResult (org.apache.qpid.disttest.controller.TestResult)1 ParticipantAttribute (org.apache.qpid.disttest.message.ParticipantAttribute)1 ResultsTestFixture (org.apache.qpid.disttest.results.ResultsTestFixture)1