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");
}
}
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);
}
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));
}
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));
}
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;
}
Aggregations