Search in sources :

Example 1 with Config

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

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));
}
Also used : HashMap(java.util.HashMap) Config(org.apache.qpid.disttest.controller.config.Config) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Response(org.apache.qpid.disttest.message.Response) StopClientCommand(org.apache.qpid.disttest.message.StopClientCommand) RegisterClientCommand(org.apache.qpid.disttest.message.RegisterClientCommand) Command(org.apache.qpid.disttest.message.Command) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ControllerJmsDelegate(org.apache.qpid.disttest.jms.ControllerJmsDelegate) Before(org.junit.Before)

Example 3 with Config

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;
}
Also used : Config(org.apache.qpid.disttest.controller.config.Config)

Example 4 with 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();
}
Also used : Config(org.apache.qpid.disttest.controller.config.Config) Test(org.junit.Test)

Example 5 with Config

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();
}
Also used : Config(org.apache.qpid.disttest.controller.config.Config) ArrayList(java.util.ArrayList)

Aggregations

Config (org.apache.qpid.disttest.controller.config.Config)8 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ResultsForAllTests (org.apache.qpid.disttest.controller.ResultsForAllTests)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 DistributedTestException (org.apache.qpid.disttest.DistributedTestException)1 ConfigReader (org.apache.qpid.disttest.controller.config.ConfigReader)1 ControllerJmsDelegate (org.apache.qpid.disttest.jms.ControllerJmsDelegate)1 Command (org.apache.qpid.disttest.message.Command)1 RegisterClientCommand (org.apache.qpid.disttest.message.RegisterClientCommand)1 Response (org.apache.qpid.disttest.message.Response)1 StopClientCommand (org.apache.qpid.disttest.message.StopClientCommand)1 Before (org.junit.Before)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1