Search in sources :

Example 16 with TestCase

use of com.hazelcast.simulator.common.TestCase 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 17 with TestCase

use of com.hazelcast.simulator.common.TestCase 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 18 with TestCase

use of com.hazelcast.simulator.common.TestCase 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)

Example 19 with TestCase

use of com.hazelcast.simulator.common.TestCase 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 20 with TestCase

use of com.hazelcast.simulator.common.TestCase 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)

Aggregations

TestCase (com.hazelcast.simulator.common.TestCase)74 Test (org.junit.Test)61 Server (com.hazelcast.simulator.protocol.Server)18 SuccessTest (com.hazelcast.simulator.tests.SuccessTest)13 Callable (java.util.concurrent.Callable)11 Future (java.util.concurrent.Future)11 FailingTest (com.hazelcast.simulator.tests.FailingTest)10 CreateTestOperation (com.hazelcast.simulator.worker.operations.CreateTestOperation)9 StoppingTest (com.hazelcast.simulator.tests.StoppingTest)8 TestPhase (com.hazelcast.simulator.common.TestPhase)7 StubPromise (com.hazelcast.simulator.protocol.StubPromise)6 StartPhaseOperation (com.hazelcast.simulator.worker.operations.StartPhaseOperation)6 StopException (com.hazelcast.simulator.test.StopException)5 TestSuite (com.hazelcast.simulator.coordinator.TestSuite)4 BusySpinningMetronome (com.hazelcast.simulator.worker.metronome.BusySpinningMetronome)4 EmptyMetronome (com.hazelcast.simulator.worker.metronome.EmptyMetronome)4 Metronome (com.hazelcast.simulator.worker.metronome.Metronome)4 SleepingMetronome (com.hazelcast.simulator.worker.metronome.SleepingMetronome)4 BaseThreadState (com.hazelcast.simulator.test.BaseThreadState)2 HashMap (java.util.HashMap)2