Search in sources :

Example 6 with StartPhaseOperation

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

the class TestManagerTest method test_startTestPhase.

@Test
public void test_startTestPhase() throws Exception {
    TestCase testCase = new TestCase("foo").setProperty("threadCount", 1).setProperty("class", TestWithSlowSetup.class);
    manager.createTest(new CreateTestOperation(testCase));
    // then we call start; this call will not block
    StubPromise promise = new StubPromise();
    manager.startTestPhase(new StartPhaseOperation(SETUP, "foo"), promise);
    // give the test some time to enter the setup phase
    SECONDS.sleep(1);
    assertFalse(promise.hasAnswer());
    // but eventually the promise will complete.
    promise.assertCompletesEventually();
}
Also used : CreateTestOperation(com.hazelcast.simulator.worker.operations.CreateTestOperation) 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 7 with StartPhaseOperation

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

the class WorkerOperationProcessorTest method test_StartTestPhaseOperation.

@Test
public void test_StartTestPhaseOperation() throws Exception {
    StartPhaseOperation op = new StartPhaseOperation(TestPhase.GLOBAL_PREPARE, "foo");
    processor.process(op, sourceAddress, promise);
    verify(testManager).startTestPhase(op, promise);
}
Also used : StartPhaseOperation(com.hazelcast.simulator.worker.operations.StartPhaseOperation) Test(org.junit.Test)

Example 8 with StartPhaseOperation

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

the class TestManagerTest method test_startPhase_whenPreviousPhaseStillRunning.

@Test
public void test_startPhase_whenPreviousPhaseStillRunning() 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();
    // do the setup first (needed)
    StubPromise setupPromise = new StubPromise();
    manager.startTestPhase(new StartPhaseOperation(SETUP, "foo"), setupPromise);
    setupPromise.assertCompletesEventually();
    // then start with the run phase
    manager.startTestPhase(new StartPhaseOperation(RUN, "foo"), mock(Promise.class));
    awaitRunning(container);
    // and while the run phase is running, we'll try to do a tear down
    StubPromise promise = new StubPromise();
    manager.startTestPhase(new StartPhaseOperation(LOCAL_TEARDOWN, "foo"), promise);
    promise.assertCompletesEventually();
    assertTrue(promise.getAnswer() instanceof IllegalStateException);
}
Also used : CreateTestOperation(com.hazelcast.simulator.worker.operations.CreateTestOperation) StubPromise(com.hazelcast.simulator.protocol.StubPromise) Promise(com.hazelcast.simulator.protocol.Promise) 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 9 with StartPhaseOperation

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

the class TestCaseRunner method executePhase.

private void executePhase(TestPhase phase) {
    if (hasFailure()) {
        throw new TestCaseAbortedException("Skipping Test " + phase.desc() + " (critical failure)", phase);
    }
    log("Starting Test " + phase.desc());
    test.setTestPhase(phase);
    Map<WorkerData, Future> futures = submitToTargets(phase.isGlobal(), new StartPhaseOperation(phase, testCase.getId()));
    waitForPhaseCompletion(phase, futures);
    log("Completed Test " + phase.desc());
    waitForGlobalTestPhaseCompletion(phase);
}
Also used : Future(java.util.concurrent.Future) WorkerData(com.hazelcast.simulator.coordinator.registry.WorkerData) StartPhaseOperation(com.hazelcast.simulator.worker.operations.StartPhaseOperation)

Aggregations

StartPhaseOperation (com.hazelcast.simulator.worker.operations.StartPhaseOperation)9 Test (org.junit.Test)7 TestCase (com.hazelcast.simulator.common.TestCase)6 StubPromise (com.hazelcast.simulator.protocol.StubPromise)6 FailingTest (com.hazelcast.simulator.tests.FailingTest)6 StoppingTest (com.hazelcast.simulator.tests.StoppingTest)6 SuccessTest (com.hazelcast.simulator.tests.SuccessTest)6 CreateTestOperation (com.hazelcast.simulator.worker.operations.CreateTestOperation)6 WorkerData (com.hazelcast.simulator.coordinator.registry.WorkerData)1 Promise (com.hazelcast.simulator.protocol.Promise)1 AssertTask (com.hazelcast.simulator.utils.AssertTask)1 StopRunOperation (com.hazelcast.simulator.worker.operations.StopRunOperation)1 Future (java.util.concurrent.Future)1