Search in sources :

Example 1 with StopRunOperation

use of com.hazelcast.simulator.worker.operations.StopRunOperation in project hazelcast-simulator by hazelcast.

the class TestCaseRunner method stopRun.

private void stopRun() {
    log("Stopping test");
    Map<WorkerData, Future> futures = submitToTargets(false, new StopRunOperation(testCase.getId()));
    try {
        waitForPhaseCompletion(RUN, futures);
        log("Stopping test completed");
    } catch (TestCaseAbortedException e) {
        log(e.getMessage());
    }
    recordTimestamp("stop");
}
Also used : StopRunOperation(com.hazelcast.simulator.worker.operations.StopRunOperation) Future(java.util.concurrent.Future) WorkerData(com.hazelcast.simulator.coordinator.registry.WorkerData)

Example 2 with StopRunOperation

use of com.hazelcast.simulator.worker.operations.StopRunOperation in project hazelcast-simulator by hazelcast.

the class TestManagerTest method test_stopRun.

@Test
public void test_stopRun() throws Exception {
    TestCase testCase = new TestCase("foo").setProperty("threadCount", 1).setProperty("class", SuccessTest.class);
    manager.createTest(new CreateTestOperation(testCase));
    final TestContainer container = manager.getContainers().iterator().next();
    // we need to call setup so the test is initialized correctly
    StubPromise setupPromise = new StubPromise();
    manager.startTestPhase(new StartPhaseOperation(SETUP, "foo"), setupPromise);
    setupPromise.assertCompletesEventually();
    // then we call start; this call will not block
    StubPromise runPromise = new StubPromise();
    manager.startTestPhase(new StartPhaseOperation(RUN, "foo"), runPromise);
    awaitRunning(container);
    // then we eventually call stop
    manager.stopRun(new StopRunOperation("foo"));
    // and now the test should complete.
    runPromise.assertCompletesEventually();
}
Also used : CreateTestOperation(com.hazelcast.simulator.worker.operations.CreateTestOperation) StopRunOperation(com.hazelcast.simulator.worker.operations.StopRunOperation) TestCase(com.hazelcast.simulator.common.TestCase) StubPromise(com.hazelcast.simulator.protocol.StubPromise) StartPhaseOperation(com.hazelcast.simulator.worker.operations.StartPhaseOperation) SuccessTest(com.hazelcast.simulator.tests.SuccessTest) FailingTest(com.hazelcast.simulator.tests.FailingTest) Test(org.junit.Test) StoppingTest(com.hazelcast.simulator.tests.StoppingTest)

Example 3 with StopRunOperation

use of com.hazelcast.simulator.worker.operations.StopRunOperation in project hazelcast-simulator by hazelcast.

the class WorkerOperationProcessorTest method test_unhandledException.

// make sure that unhandled exceptions are trapped.
@Test
public void test_unhandledException() throws Exception {
    StopRunOperation op = new StopRunOperation("foo");
    Exception e = new IndexOutOfBoundsException("");
    doThrow(e).when(testManager).stopRun(op);
    processor.process(op, sourceAddress, promise);
    assertTrue(promise.getAnswer() instanceof IndexOutOfBoundsException);
    File exceptionFile = new File(getUserDir(), "1.exception");
    assertTrue(exceptionFile.exists());
    assertFalse(new File(getUserDir(), "1.exception.tmp").exists());
    assertNotNull(fileAsText(exceptionFile));
}
Also used : StopRunOperation(com.hazelcast.simulator.worker.operations.StopRunOperation) File(java.io.File) ProcessException(com.hazelcast.simulator.protocol.exception.ProcessException) Test(org.junit.Test)

Example 4 with StopRunOperation

use of com.hazelcast.simulator.worker.operations.StopRunOperation in project hazelcast-simulator by hazelcast.

the class WorkerOperationProcessorTest method test_StopRunOperation.

@Test
public void test_StopRunOperation() throws Exception {
    StopRunOperation op = new StopRunOperation("foo");
    processor.process(op, sourceAddress, promise);
    verify(testManager).stopRun(op);
    assertTrue(promise.hasAnswer());
}
Also used : StopRunOperation(com.hazelcast.simulator.worker.operations.StopRunOperation) Test(org.junit.Test)

Aggregations

StopRunOperation (com.hazelcast.simulator.worker.operations.StopRunOperation)4 Test (org.junit.Test)3 TestCase (com.hazelcast.simulator.common.TestCase)1 WorkerData (com.hazelcast.simulator.coordinator.registry.WorkerData)1 StubPromise (com.hazelcast.simulator.protocol.StubPromise)1 ProcessException (com.hazelcast.simulator.protocol.exception.ProcessException)1 FailingTest (com.hazelcast.simulator.tests.FailingTest)1 StoppingTest (com.hazelcast.simulator.tests.StoppingTest)1 SuccessTest (com.hazelcast.simulator.tests.SuccessTest)1 CreateTestOperation (com.hazelcast.simulator.worker.operations.CreateTestOperation)1 StartPhaseOperation (com.hazelcast.simulator.worker.operations.StartPhaseOperation)1 File (java.io.File)1 Future (java.util.concurrent.Future)1