use of org.apache.qpid.disttest.controller.config.Config 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.config.Config in project qpid-broker-j by apache.
the class ControllerTest method setUp.
@Before
public void setUp() throws Exception {
_respondingJmsDelegate = mock(ControllerJmsDelegate.class);
final Map<String, String> controllerOptions = new HashMap<>();
controllerOptions.put(ControllerRunner.REGISTRATION_TIMEOUT, String.valueOf(REGISTRATION_TIMEOUT));
controllerOptions.put(ControllerRunner.COMMAND_RESPONSE_TIMEOUT, String.valueOf(COMMAND_RESPONSE_TIMEOUT));
_controller = new Controller(_respondingJmsDelegate, controllerOptions);
_clientRegistry = mock(ClientRegistry.class);
Config configWithOneClient = createMockConfig(1);
_controller.setConfig(configWithOneClient);
_controller.setClientRegistry(_clientRegistry);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
final String clientName = (String) invocation.getArguments()[0];
final Command command = (Command) invocation.getArguments()[1];
_controller.processStopClientResponse(new Response(clientName, command.getType()));
return null;
}
}).when(_respondingJmsDelegate).sendCommandToClient(anyString(), isA(Command.class));
}
use of org.apache.qpid.disttest.controller.config.Config in project qpid-broker-j by apache.
the class ControllerTest method createMockConfig.
private Config createMockConfig(int numberOfClients) {
Config config = mock(Config.class);
when(config.getTotalNumberOfClients()).thenReturn(numberOfClients);
return config;
}
use of org.apache.qpid.disttest.controller.config.Config in project qpid-broker-j by apache.
the class ControllerTest method testControllerReceivesTwoExpectedClientRegistrations.
@Test
public void testControllerReceivesTwoExpectedClientRegistrations() {
Config configWithTwoClients = createMockConfig(2);
_controller.setConfig(configWithTwoClients);
when(_clientRegistry.awaitClients(2, REGISTRATION_TIMEOUT)).thenReturn(0);
_controller.awaitClientRegistrations();
}
use of org.apache.qpid.disttest.controller.config.Config in project qpid-broker-j by apache.
the class ControllerRunner method createClientsIfNotDistributed.
private Collection<ClientRunner> createClientsIfNotDistributed(final List<String> testConfigFiles) {
if (!isDistributed()) {
int maxNumberOfClients = 0;
for (String testConfigFile : testConfigFiles) {
final Config testConfig = buildTestConfigFrom(testConfigFile);
final int numClients = testConfig.getTotalNumberOfClients();
maxNumberOfClients = Math.max(numClients, maxNumberOfClients);
}
// we must create the required test clients, running in single-jvm mode
Collection<ClientRunner> runners = new ArrayList<>(maxNumberOfClients);
for (int i = 1; i <= maxNumberOfClients; i++) {
ClientRunner clientRunner = new ClientRunner();
clientRunner.setJndiPropertiesFileLocation(getJndiConfig());
clientRunner.runClients();
runners.add(clientRunner);
}
return runners;
}
return Collections.emptyList();
}
Aggregations