Search in sources :

Example 6 with StubPromise

use of com.hazelcast.simulator.protocol.StubPromise 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 7 with StubPromise

use of com.hazelcast.simulator.protocol.StubPromise 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 8 with StubPromise

use of com.hazelcast.simulator.protocol.StubPromise in project hazelcast-simulator by hazelcast.

the class WorkerOperationProcessorTest method before.

@Before
public void before() {
    setupFakeUserDir();
    ExceptionReporter.reset();
    testManager = mock(TestManager.class);
    worker = mock(Worker.class);
    scriptExecutor = mock(ScriptExecutor.class);
    processor = new WorkerOperationProcessor(worker, testManager, scriptExecutor);
    promise = new StubPromise();
}
Also used : TestManager(com.hazelcast.simulator.worker.testcontainer.TestManager) StubPromise(com.hazelcast.simulator.protocol.StubPromise) Before(org.junit.Before)

Example 9 with StubPromise

use of com.hazelcast.simulator.protocol.StubPromise in project hazelcast-simulator by hazelcast.

the class ScriptExecutorTest method javascript.

@Test
public void javascript() {
    ExecuteScriptOperation scriptOperation = new ExecuteScriptOperation("js:java.lang.System.out.println();", false);
    StubPromise promise = new StubPromise();
    scriptExecutor.execute(scriptOperation, promise);
    promise.assertCompletesEventually();
    assertTrue(promise.getAnswer() instanceof String);
}
Also used : ExecuteScriptOperation(com.hazelcast.simulator.worker.operations.ExecuteScriptOperation) StubPromise(com.hazelcast.simulator.protocol.StubPromise) Test(org.junit.Test)

Example 10 with StubPromise

use of com.hazelcast.simulator.protocol.StubPromise 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)

Aggregations

StubPromise (com.hazelcast.simulator.protocol.StubPromise)10 Test (org.junit.Test)9 TestCase (com.hazelcast.simulator.common.TestCase)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 StartPhaseOperation (com.hazelcast.simulator.worker.operations.StartPhaseOperation)6 ExecuteScriptOperation (com.hazelcast.simulator.worker.operations.ExecuteScriptOperation)3 Promise (com.hazelcast.simulator.protocol.Promise)1 AssertTask (com.hazelcast.simulator.utils.AssertTask)1 StopRunOperation (com.hazelcast.simulator.worker.operations.StopRunOperation)1 TestManager (com.hazelcast.simulator.worker.testcontainer.TestManager)1 Before (org.junit.Before)1