Search in sources :

Example 1 with FailureOperation

use of com.hazelcast.simulator.coordinator.operations.FailureOperation in project hazelcast-simulator by hazelcast.

the class FailureCollectorTest method notify_whenNonExistingWorker_thenIgnore.

@Test
public void notify_whenNonExistingWorker_thenIgnore() {
    SimulatorAddress nonExistingWorkerAddress = workerAddress(agentAddress.getAgentIndex(), 100);
    FailureOperation failure = new FailureOperation("exception", WORKER_EXCEPTION, nonExistingWorkerAddress, agentAddress.toString(), "workerId", "testId", null);
    failureCollector.notify(failure);
    assertEquals(0, failureCollector.getFailureCount());
}
Also used : SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) FailureOperation(com.hazelcast.simulator.coordinator.operations.FailureOperation) Test(org.junit.Test)

Example 2 with FailureOperation

use of com.hazelcast.simulator.coordinator.operations.FailureOperation in project hazelcast-simulator by hazelcast.

the class FailureCollectorTest method notify_enrich.

@Test
public void notify_enrich() {
    TestCase testCase = new TestCase("test1");
    TestSuite suite1 = new TestSuite().addTest(testCase);
    TestSuite suite2 = new TestSuite().addTest(new TestCase("test2"));
    registry.addTests(suite1);
    registry.addTests(suite2);
    FailureOperation failure = new FailureOperation("exception", WORKER_EXCEPTION, workerAddress, agentAddress.toString(), "workerId", testCase.getId(), null);
    FailureListener listener = mock(FailureListener.class);
    failureCollector.addListener(listener);
    failureCollector.notify(failure);
    ArgumentCaptor<FailureOperation> failureCaptor = ArgumentCaptor.forClass(FailureOperation.class);
    verify(listener).onFailure(failureCaptor.capture(), eq(false), eq(true));
    assertSame(suite1.getTestCaseList().get(0), failureCaptor.getValue().getTestCase());
}
Also used : TestCase(com.hazelcast.simulator.common.TestCase) FailureOperation(com.hazelcast.simulator.coordinator.operations.FailureOperation) Test(org.junit.Test)

Example 3 with FailureOperation

use of com.hazelcast.simulator.coordinator.operations.FailureOperation in project hazelcast-simulator by hazelcast.

the class WorkerProcessFailureHandler method handle.

public void handle(String message, FailureType type, WorkerProcess workerProcess, String testId, String cause) {
    SimulatorAddress workerAddress = workerProcess.getAddress();
    String workerId = workerProcess.getId();
    FailureOperation failure = new FailureOperation(message, type, workerAddress, agentAddress, workerId, testId, cause);
    if (type.isPoisonPill()) {
        LOGGER.info(format("Worker %s (%s) finished.", workerId, workerAddress));
    } else {
        LOGGER.error(format("Detected failure on Worker %s (%s): %s", workerId, workerAddress, failure.getLogMessage(++failureCount)));
    }
    server.sendCoordinator(failure);
}
Also used : SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) FailureOperation(com.hazelcast.simulator.coordinator.operations.FailureOperation)

Example 4 with FailureOperation

use of com.hazelcast.simulator.coordinator.operations.FailureOperation in project hazelcast-simulator by hazelcast.

the class FailureCollectorTest method before.

@Before
public void before() {
    outputDirectory = TestUtils.createTmpDirectory();
    registry = new Registry();
    failureCollector = new FailureCollector(outputDirectory, registry);
    agentAddress = registry.addAgent("192.168.0.1", "192.168.0.1").getAddress();
    workerAddress = workerAddress(agentAddress.getAgentIndex(), 1);
    WorkerParameters workerParameters = new WorkerParameters().set("WORKER_ADDRESS", workerAddress);
    registry.addWorkers(singletonList(workerParameters));
    exceptionFailure = new FailureOperation("exception", WORKER_EXCEPTION, workerAddress, agentAddress.toString(), "workerId", "testId", null);
    abnormalExitFailure = new FailureOperation("exception", WORKER_ABNORMAL_EXIT, workerAddress, agentAddress.toString(), "workerId", "testId", null);
    oomeFailure = new FailureOperation("oom", WORKER_OOME, workerAddress, agentAddress.toString(), "workerId", "testId", null);
    normalExitFailure = new FailureOperation("finished", WORKER_NORMAL_EXIT, workerAddress, agentAddress.toString(), "workerId", "testId", null);
}
Also used : Registry(com.hazelcast.simulator.coordinator.registry.Registry) WorkerParameters(com.hazelcast.simulator.agent.workerprocess.WorkerParameters) FailureOperation(com.hazelcast.simulator.coordinator.operations.FailureOperation) Before(org.junit.Before)

Example 5 with FailureOperation

use of com.hazelcast.simulator.coordinator.operations.FailureOperation in project hazelcast-simulator by hazelcast.

the class CoordinatorOperationProcessor method process.

@Override
public void process(SimulatorOperation op, SimulatorAddress source, Promise promise) throws Exception {
    if (op instanceof FailureOperation) {
        failureCollector.notify((FailureOperation) op);
    } else if (op instanceof PerformanceStatsOperation) {
        performanceStatsCollector.update(source, ((PerformanceStatsOperation) op).getPerformanceStats());
    } else if (op instanceof LogOperation) {
        LogOperation logOperation = (LogOperation) op;
        LOGGER.log(logOperation.getLevel(), logOperation.getMessage());
    } else {
        throw new ProcessException("Unknown operation:" + op);
    }
    promise.answer("ok");
}
Also used : ProcessException(com.hazelcast.simulator.protocol.exception.ProcessException) LogOperation(com.hazelcast.simulator.protocol.operation.LogOperation) PerformanceStatsOperation(com.hazelcast.simulator.worker.operations.PerformanceStatsOperation) FailureOperation(com.hazelcast.simulator.coordinator.operations.FailureOperation)

Aggregations

FailureOperation (com.hazelcast.simulator.coordinator.operations.FailureOperation)6 Test (org.junit.Test)3 SimulatorAddress (com.hazelcast.simulator.protocol.core.SimulatorAddress)2 WorkerParameters (com.hazelcast.simulator.agent.workerprocess.WorkerParameters)1 TestCase (com.hazelcast.simulator.common.TestCase)1 Registry (com.hazelcast.simulator.coordinator.registry.Registry)1 ProcessException (com.hazelcast.simulator.protocol.exception.ProcessException)1 LogOperation (com.hazelcast.simulator.protocol.operation.LogOperation)1 PerformanceStatsOperation (com.hazelcast.simulator.worker.operations.PerformanceStatsOperation)1 Before (org.junit.Before)1