use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class StartWorkersTaskTest method testCreateWorkers_noClients.
@Test
public void testCreateWorkers_noClients() throws Exception {
Map<SimulatorAddress, List<WorkerParameters>> deploymentPlan = getDeployment(0, 6, 0);
Future f = mock(Future.class);
when(f.get()).thenReturn("SUCCESS");
when(client.submit(eq(agent1.getAddress()), any(CreateWorkerOperation.class))).thenReturn(f);
when(client.submit(eq(agent2.getAddress()), any(CreateWorkerOperation.class))).thenReturn(f);
when(client.submit(eq(agent3.getAddress()), any(CreateWorkerOperation.class))).thenReturn(f);
new StartWorkersTask(deploymentPlan, Collections.<String, String>emptyMap(), client, registry, 0).run();
assertComponentRegistry(registry, 6, 0);
}
use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class MessagingTest method test.
@Test
public void test() 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 {
System.out.println(op);
promise.answer("OK");
}
}).start();
client = new CoordinatorClient().setProcessor(mock(OperationProcessor.class)).start().connectToAgentBroker(agentAddress, localIp());
final Future f = client.submit(agentAddress, new LogOperation("", Level.DEBUG));
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrue(f.isDone());
assertEquals("OK", f.get());
}
});
}
use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class MessagingTest method testWhenAgentConnectionFails.
@Test
public void testWhenAgentConnectionFails() throws Exception {
final CountDownLatch received = new CountDownLatch(1);
agentServer = new Server("agents").setBrokerURL(broker.getBrokerURL()).setSelfAddress(agentAddress).setProcessor(new OperationProcessor() {
@Override
public void process(SimulatorOperation op, SimulatorAddress source, Promise promise) throws Exception {
// we don't do anything to let the future wait
received.countDown();
}
}).start();
client = new CoordinatorClient().setProcessor(mock(OperationProcessor.class));
client.getConnectionFactory().setMaxReconnectAttempts(1);
client.start().connectToAgentBroker(agentAddress, localIp());
final Future f = client.submit(agentAddress, new LogOperation("", Level.DEBUG));
received.await();
broker.close();
assertCompletesEventually(f);
try {
f.get();
fail();
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof JMSException);
}
}
use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class CoordinatorCliTest method count.
private int count(DeploymentPlan deploymentPlan, String workerType) {
Map<SimulatorAddress, List<WorkerParameters>> deployment = deploymentPlan.getWorkerDeployment();
int result = 0;
for (List<WorkerParameters> list : deployment.values()) {
for (WorkerParameters settings : list) {
if (settings.getWorkerType().equals(workerType)) {
result++;
}
}
}
return result;
}
use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class FailureCollector method notify.
public void notify(FailureOperation failure) {
failure = enrich(failure);
SimulatorAddress workerAddress = failure.getWorkerAddress();
if (workerAddress != null && failure.getType() != WORKER_CREATE_ERROR) {
WorkerData worker = registry.findWorker(workerAddress);
if (worker == null) {
// we are not interested in failures of workers that aren't registered any longer.
return;
}
// if the failure is the terminal for that workers, we need to remove it from the component registry
if (failure.getType().isTerminal()) {
LOGGER.info("Removing worker " + worker.getAddress() + " from registry due to [" + failure.getType() + "]");
registry.removeWorker(worker.getAddress());
}
// if we don't care for the failure, we are done; no need to log anything.
if (worker.isIgnoreFailures() || failure.getType() == WORKER_NORMAL_EXIT) {
return;
}
}
int failureCount = criticalFailureCounter.incrementAndGet();
String testId = failure.getTestId();
if (testId != null) {
hasCriticalFailuresMap.put(testId, true);
}
logFailure(failure, failureCount);
appendText(failure.getFileMessage(), file);
for (FailureListener failureListener : listenerMap.keySet()) {
failureListener.onFailure(failure, failure.getType().isTerminal(), true);
}
}
Aggregations