Search in sources :

Example 26 with SimulatorAddress

use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.

the class RegistryTest method testHasClientWorkers_withClientWorkers.

@Test
public void testHasClientWorkers_withClientWorkers() {
    SimulatorAddress agentAddress = addAgent();
    List<WorkerParameters> parametersList = newWorkerParametersList(agentAddress, 2);
    registry.addWorkers(parametersList);
    parametersList = newWorkerParametersList(agentAddress, 2, "javaclient");
    registry.addWorkers(parametersList);
    assertTrue(registry.hasClientWorkers());
}
Also used : WorkerParameters(com.hazelcast.simulator.agent.workerprocess.WorkerParameters) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) Test(org.junit.Test)

Example 27 with SimulatorAddress

use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.

the class RegistryTest method testGetWorkers_getMemberWorkers_notEnoughWorkersFound.

@Test(expected = IllegalStateException.class)
public void testGetWorkers_getMemberWorkers_notEnoughWorkersFound() {
    SimulatorAddress agentAddress = addAgent();
    registry.addWorkers(newWorkerParametersList(agentAddress, 2, "member"));
    registry.addWorkers(newWorkerParametersList(agentAddress, 2, "javaclient"));
    assertEquals(4, registry.workerCount());
    registry.getWorkerAddresses(TargetType.MEMBER, 3);
}
Also used : SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) Test(org.junit.Test)

Example 28 with SimulatorAddress

use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.

the class RegistryTest method testGetWorkers_withHigherWorkerCountThanRegisteredWorkers.

@Test(expected = IllegalArgumentException.class)
public void testGetWorkers_withHigherWorkerCountThanRegisteredWorkers() {
    SimulatorAddress agentAddress = addAgent();
    registry.addWorkers(newWorkerParametersList(agentAddress, 2, "member"));
    registry.addWorkers(newWorkerParametersList(agentAddress, 2, "javaclient"));
    assertEquals(4, registry.workerCount());
    registry.getWorkerAddresses(TargetType.ALL, 5);
}
Also used : SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) Test(org.junit.Test)

Example 29 with SimulatorAddress

use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.

the class StartWorkersTaskTest method testCreateWorkers_withErrorResponse.

@Test(expected = CommandLineExitException.class)
public void testCreateWorkers_withErrorResponse() throws Exception {
    Map<SimulatorAddress, List<WorkerParameters>> deploymentPlan = getDeployment(0, 1, 0);
    Future f = mock(Future.class);
    when(f.get()).thenThrow(new ExecutionException(null));
    when(client.submit(eq(agent1.getAddress()), any(CreateWorkerOperation.class))).thenReturn(f);
    new StartWorkersTask(deploymentPlan, Collections.<String, String>emptyMap(), client, registry, 0).run();
}
Also used : CreateWorkerOperation(com.hazelcast.simulator.agent.operations.CreateWorkerOperation) Future(java.util.concurrent.Future) List(java.util.List) ExecutionException(java.util.concurrent.ExecutionException) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) Test(org.junit.Test)

Example 30 with SimulatorAddress

use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.

the class MessagingTest method sendCoordinator.

@Test
public void sendCoordinator() throws Exception {
    agentServer = new Server("agents").setBrokerURL(broker.getBrokerURL()).setSelfAddress(agentAddress).setProcessor(new OperationProcessor() {

        @Override
        public void process(SimulatorOperation op, SimulatorAddress source, Promise promise) throws Exception {
        }
    }).start();
    final OperationProcessor clientOperationProcessor = mock(OperationProcessor.class);
    client = new CoordinatorClient().setProcessor(clientOperationProcessor);
    client.getConnectionFactory().setMaxReconnectAttempts(1);
    client.start().connectToAgentBroker(agentAddress, localIp());
    agentServer.sendCoordinator(new LogOperation("Foo"));
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            verify(clientOperationProcessor).process(any(LogOperation.class), eq(agentAddress), any(Promise.class));
        }
    });
}
Also used : LogOperation(com.hazelcast.simulator.protocol.operation.LogOperation) SimulatorOperation(com.hazelcast.simulator.protocol.operation.SimulatorOperation) AssertTask(com.hazelcast.simulator.utils.AssertTask) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) JMSException(javax.jms.JMSException) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Aggregations

SimulatorAddress (com.hazelcast.simulator.protocol.core.SimulatorAddress)30 Test (org.junit.Test)20 WorkerParameters (com.hazelcast.simulator.agent.workerprocess.WorkerParameters)8 HashMap (java.util.HashMap)8 Future (java.util.concurrent.Future)7 PerformanceStats (com.hazelcast.simulator.worker.performance.PerformanceStats)6 List (java.util.List)5 LogOperation (com.hazelcast.simulator.protocol.operation.LogOperation)4 SimulatorOperation (com.hazelcast.simulator.protocol.operation.SimulatorOperation)4 ExecutionException (java.util.concurrent.ExecutionException)4 CreateWorkerOperation (com.hazelcast.simulator.agent.operations.CreateWorkerOperation)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 JMSException (javax.jms.JMSException)3 FailureOperation (com.hazelcast.simulator.coordinator.operations.FailureOperation)2 AssertTask (com.hazelcast.simulator.utils.AssertTask)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 AgentData (com.hazelcast.simulator.coordinator.registry.AgentData)1