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;
}
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());
}
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());
}
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);
}
}
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);
}
}
Aggregations