Search in sources :

Example 1 with TestPhase

use of com.hazelcast.simulator.common.TestPhase in project hazelcast-simulator by hazelcast.

the class RunTestSuiteTask method getTestPhaseSyncMap.

static Map<TestPhase, CountDownLatch> getTestPhaseSyncMap(int testCount, boolean parallel, TestPhase latestTestPhaseToSync) {
    if (!parallel) {
        return null;
    }
    Map<TestPhase, CountDownLatch> testPhaseSyncMap = new ConcurrentHashMap<TestPhase, CountDownLatch>();
    boolean setTestCount = true;
    for (TestPhase testPhase : TestPhase.values()) {
        testPhaseSyncMap.put(testPhase, new CountDownLatch(setTestCount ? testCount : 0));
        if (testPhase.equals(latestTestPhaseToSync)) {
            setTestCount = false;
        }
    }
    return testPhaseSyncMap;
}
Also used : TestPhase(com.hazelcast.simulator.common.TestPhase) CountDownLatch(java.util.concurrent.CountDownLatch) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 2 with TestPhase

use of com.hazelcast.simulator.common.TestPhase in project hazelcast-simulator by hazelcast.

the class TestContainer_TimeStep_MaxIterationsTest method test.

@Test
public void test() throws Exception {
    MaxIterationTest testInstance = new MaxIterationTest();
    TestCase testCase = new TestCase("stopRun").setProperty("threadCount", 1).setProperty("iterations", 100).setProperty("class", testInstance.getClass());
    TestContextImpl testContext = new TestContextImpl(testCase.getId(), "localhost", mock(Server.class));
    final TestContainer container = new TestContainer(testContext, testInstance, testCase);
    container.invoke(SETUP);
    for (TestPhase phase : TestPhase.values()) {
        container.invoke(phase);
    }
    assertNoExceptions();
    assertEquals(100, testInstance.runCount.get());
}
Also used : Server(com.hazelcast.simulator.protocol.Server) TestCase(com.hazelcast.simulator.common.TestCase) TestPhase(com.hazelcast.simulator.common.TestPhase) Test(org.junit.Test)

Example 3 with TestPhase

use of com.hazelcast.simulator.common.TestPhase in project hazelcast-simulator by hazelcast.

the class TestContainer_TimeStep_StartNanosTest method testWithoutMetronome.

@Test
public void testWithoutMetronome() throws Exception {
    StartNanosTest testInstance = new StartNanosTest();
    TestCase testCase = new TestCase("test").setProperty("iterations", 10).setProperty("threadCount", 1).setProperty("class", testInstance.getClass());
    TestContextImpl testContext = new TestContextImpl(testCase.getId(), "localhost", mock(Server.class));
    TestContainer container = new TestContainer(testContext, testInstance, testCase);
    for (TestPhase phase : TestPhase.values()) {
        container.invoke(phase);
    }
    List<Long> startNanosList = testInstance.startNanosList;
    assertEquals(10, startNanosList.size());
}
Also used : Server(com.hazelcast.simulator.protocol.Server) TestCase(com.hazelcast.simulator.common.TestCase) TestPhase(com.hazelcast.simulator.common.TestPhase) Test(org.junit.Test)

Example 4 with TestPhase

use of com.hazelcast.simulator.common.TestPhase in project hazelcast-simulator by hazelcast.

the class TestContainer_TimeStep_StartNanosTest method testWithMetronome.

@Test
public void testWithMetronome() throws Exception {
    long intervalUs = 50;
    StartNanosTest testInstance = new StartNanosTest();
    TestCase testCase = new TestCase("test").setProperty("iterations", 10).setProperty("interval", intervalUs + "us").setProperty("threadCount", 1).setProperty("class", testInstance.getClass());
    TestContextImpl testContext = new TestContextImpl(testCase.getId(), "localhost", mock(Server.class));
    TestContainer container = new TestContainer(testContext, testInstance, testCase);
    for (TestPhase phase : TestPhase.values()) {
        container.invoke(phase);
    }
    List<Long> startNanosList = testInstance.startNanosList;
    assertEquals(10, startNanosList.size());
    long firstNanos = startNanosList.get(0);
    for (int k = 1; k < startNanosList.size(); k++) {
        long startNanos = startNanosList.get(k);
        assertEquals(firstNanos + k * TimeUnit.MICROSECONDS.toNanos(intervalUs), startNanos);
    }
}
Also used : Server(com.hazelcast.simulator.protocol.Server) TestCase(com.hazelcast.simulator.common.TestCase) TestPhase(com.hazelcast.simulator.common.TestPhase) Test(org.junit.Test)

Example 5 with TestPhase

use of com.hazelcast.simulator.common.TestPhase in project hazelcast-simulator by hazelcast.

the class TestContainer_TimeStep_ThrottlingLoggerTest method test.

@Test
public void test() throws Exception {
    ThrottlingLoggerTest testInstance = new ThrottlingLoggerTest();
    TestCase testCase = new TestCase("exceptionTest").setProperty("logRateMs", 1000).setProperty("threadCount", 1).setProperty("class", testInstance.getClass());
    TestContextImpl testContext = new TestContextImpl(testCase.getId(), "localhost", mock(Server.class));
    final TestContainer container = new TestContainer(testContext, testInstance, testCase);
    for (TestPhase phase : TestPhase.values()) {
        container.invoke(phase);
    }
}
Also used : Server(com.hazelcast.simulator.protocol.Server) TestCase(com.hazelcast.simulator.common.TestCase) TestPhase(com.hazelcast.simulator.common.TestPhase) Test(org.junit.Test)

Aggregations

TestPhase (com.hazelcast.simulator.common.TestPhase)9 TestCase (com.hazelcast.simulator.common.TestCase)7 Server (com.hazelcast.simulator.protocol.Server)6 Test (org.junit.Test)5 CountDownLatch (java.util.concurrent.CountDownLatch)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 TestPhase.getLastTestPhase (com.hazelcast.simulator.common.TestPhase.getLastTestPhase)1 TestCaseRunner (com.hazelcast.simulator.coordinator.TestCaseRunner)1 TestData (com.hazelcast.simulator.coordinator.registry.TestData)1 AbstractTest (com.hazelcast.simulator.test.AbstractTest)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1