use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class TimeStepRunStrategyIntegrationTest method testWithAllRunPhases.
@Test
public void testWithAllRunPhases() throws Exception {
int threadCount = 2;
TestWithAllRunPhases testInstance = new TestWithAllRunPhases();
TestCase testCase = new TestCase(TEST_ID).setProperty("threadCount", threadCount).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);
Future runFuture = spawn(new Callable() {
@Override
public Object call() throws Exception {
container.invoke(RUN);
return null;
}
});
sleepSeconds(5);
testContext.stop();
runFuture.get();
container.invoke(TestPhase.LOCAL_TEARDOWN);
System.out.println("done");
assertEquals(threadCount, testInstance.beforeRunCount.get());
assertEquals(threadCount, testInstance.afterRunCount.get());
System.out.println(testInstance.timeStepCount);
}
use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class RunTestSuiteTask method run0.
private boolean run0(List<TestData> tests, List<WorkerData> targets) {
int testCount = testSuite.size();
boolean parallel = testSuite.isParallel() && testCount > 1;
Map<TestPhase, CountDownLatch> testPhaseSyncMap = getTestPhaseSyncMap(testCount, parallel, coordinatorParameters.getLastTestPhaseToSync());
LOGGER.info("Starting TestSuite");
echoTestSuiteDuration(parallel);
for (TestData test : tests) {
int testIndex = test.getTestIndex();
TestCase testCase = test.getTestCase();
LOGGER.info(format("Configuration for %s (T%d):%n%s", testCase.getId(), testIndex, testCase));
TestCaseRunner runner = new TestCaseRunner(test, coordinatorParameters, targets, client, testPhaseSyncMap, failureCollector, registry, performanceStatsCollector);
runners.add(runner);
}
echoTestSuiteStart(testCount, parallel);
long started = System.nanoTime();
boolean success = parallel ? runParallel() : runSequential();
echoTestSuiteEnd(testCount, started);
return success;
}
use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class CoordinatorCli method loadTestSuite.
private TestSuite loadTestSuite() {
TestSuite testSuite = loadRawTestSuite();
if (testSuite == null) {
return null;
}
WorkerQuery workerQuery = new WorkerQuery().setTargetType(options.valueOf(targetTypeSpec));
int targetCount = options.valueOf(targetCountSpec);
if (targetCount > 0) {
workerQuery.setMaxCount(targetCount);
}
int durationSeconds = getDurationSeconds(options, durationSpec);
testSuite.setDurationSeconds(durationSeconds).setFailFast(options.valueOf(failFastSpec)).setVerifyEnabled(options.valueOf(verifyEnabledSpec)).setParallel(options.has(parallelSpec)).setWorkerQuery(workerQuery);
// if the coordinator is not monitoring performance, we don't care for measuring latencies
if (coordinatorParameters.getSimulatorProperties().getInt("WORKER_PERFORMANCE_MONITOR_INTERVAL_SECONDS") == 0) {
for (TestCase testCase : testSuite.getTestCaseList()) {
testCase.setProperty("measureLatency", "false");
}
}
return testSuite;
}
use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class TestSuite method createTestCases.
private static Map<String, TestCase> createTestCases(Properties properties) {
Map<String, TestCase> testCases = new HashMap<String, TestCase>();
for (String property : properties.stringPropertyNames()) {
String value = (String) properties.get(property);
int indexOfAt = property.indexOf('@');
String testId = "";
String field = property;
if (indexOfAt > -1) {
testId = property.substring(0, indexOfAt);
field = property.substring(indexOfAt + 1);
}
if (!testId.isEmpty() && !isValidTestId(testId)) {
throw new IllegalArgumentException(format("TestId [%s] is not a valid id", testId));
}
if (value.isEmpty()) {
throw new IllegalArgumentException(format("Value of property %s in testId [%s] is empty!", property, testId));
}
TestCase testCase = getOrCreateTestCase(testCases, testId);
testCase.setProperty(field, value);
}
return testCases;
}
use of com.hazelcast.simulator.common.TestCase in project hazelcast-simulator by hazelcast.
the class TestManager method createTest.
public void createTest(CreateTestOperation operation) {
TestCase testCase = operation.getTestCase();
String testId = testCase.getId();
TestContainer testContainer = tests.get(testId);
if (testContainer != null) {
throw new IllegalStateException(format("Can't init TestCase: %s, another test with testId %s already exists", operation, testId));
}
LOGGER.info(format("%s Initializing test %s %s%n%s", DASHES, testId, DASHES, testCase));
TestContextImpl testContext = new TestContextImpl(testId, null, server);
testContainer = new TestContainer(testContext, testCase, vendorDriver.getVendorInstance());
tests.put(testId, testContainer);
}
Aggregations