Search in sources :

Example 1 with StubPromise

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

the class ScriptExecutorTest method whenFireSndForget_thenErrorNotNoticed.

@Test
public void whenFireSndForget_thenErrorNotNoticed() {
    ExecuteScriptOperation scriptOperation = new ExecuteScriptOperation("bash:foobar", true);
    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 2 with StubPromise

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

the class ScriptExecutorTest method bash.

@Test
public void bash() {
    ExecuteScriptOperation scriptOperation = new ExecuteScriptOperation("bash:ls", 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 3 with StubPromise

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

the class TestManagerTest method test_startRun.

@Test
public void test_startRun() throws Exception {
    TestCase testCase = new TestCase("foo").setProperty("threadCount", 1).setProperty("class", StoppingTest.class);
    manager.createTest(new CreateTestOperation(testCase));
    StubPromise promise = new StubPromise();
    manager.startTestPhase(new StartPhaseOperation(RUN, "foo"), promise);
    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 4 with StubPromise

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

the class TestManagerTest method test_whenProblemDuringPhase.

@Test
public void test_whenProblemDuringPhase() throws Exception {
    TestCase testCase = new TestCase("foo").setProperty("threadCount", 1).setProperty("class", FailingTest.class);
    manager.createTest(new CreateTestOperation(testCase));
    StubPromise setupPromise = new StubPromise();
    manager.startTestPhase(new StartPhaseOperation(SETUP, "foo"), setupPromise);
    setupPromise.assertCompletesEventually();
    StubPromise runPromise = new StubPromise();
    manager.startTestPhase(new StartPhaseOperation(RUN, "foo"), runPromise);
    runPromise.assertCompletesEventually();
    System.out.println(runPromise.getAnswer());
    assertTrue(runPromise.getAnswer() instanceof Exception);
}
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 5 with StubPromise

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

the class TestManagerTest method test_whenLastPhaseCompletes_thenTestRemoved.

@Test
public void test_whenLastPhaseCompletes_thenTestRemoved() throws Exception {
    final 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(TestPhase.LOCAL_TEARDOWN, "foo"), promise);
    // but eventually the promise will complete.
    promise.assertCompletesEventually();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(0, manager.getContainers().size());
        }
    });
}
Also used : CreateTestOperation(com.hazelcast.simulator.worker.operations.CreateTestOperation) TestCase(com.hazelcast.simulator.common.TestCase) AssertTask(com.hazelcast.simulator.utils.AssertTask) 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