use of com.hazelcast.simulator.utils.AssertTask in project hazelcast-simulator by hazelcast.
the class ITopicTest method verify.
@Verify(global = true)
public void verify() {
if (maxVerificationTimeSeconds < 0) {
return;
}
final long expectedCount = totalExpectedCounter.get();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
long actualCount = 0;
for (TopicListener topicListener : listeners) {
actualCount += topicListener.count;
}
assertEquals("published messages don't match received messages", expectedCount, actualCount);
}
}, maxVerificationTimeSeconds);
}
use of com.hazelcast.simulator.utils.AssertTask in project hazelcast-simulator by hazelcast.
the class ExpiryICacheTest method globalVerify.
@Verify(global = true)
public void globalVerify() {
sleepSeconds(61);
// provoke expire after TTL
for (int i = 0; i < keyCount; i++) {
cache.containsKey(i);
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
int cacheSize = cache.size();
logger.info(name + " ICache size: " + cacheSize);
assertEquals(name + " ICache should be empty, but TTL events are not processed", 0, cacheSize);
}
});
}
use of com.hazelcast.simulator.utils.AssertTask 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());
}
});
}
use of com.hazelcast.simulator.utils.AssertTask in project hazelcast-simulator by hazelcast.
the class AsyncAtomicLongTest method verify.
@Verify
public void verify() {
if (isClient(targetInstance)) {
return;
}
final String serviceName = totalCounter.getServiceName();
final long expected = totalCounter.get();
// since the operations are asynchronous, we have no idea when they complete
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
// hack to prevent overloading the system with get calls, else it is done many times a second
sleepSeconds(10);
long actual = 0;
for (DistributedObject distributedObject : targetInstance.getDistributedObjects()) {
String key = distributedObject.getName();
if (serviceName.equals(distributedObject.getServiceName()) && key.startsWith(name)) {
actual += targetInstance.getAtomicLong(key).get();
}
}
assertEquals(expected, actual);
}
}, assertEventuallySeconds);
}
use of com.hazelcast.simulator.utils.AssertTask in project hazelcast-simulator by hazelcast.
the class WorkerProcessFailureMonitorTest method testRun_shouldContinueAfterExceptionDuringDetection.
@Test(timeout = DEFAULT_TIMEOUT)
public void testRun_shouldContinueAfterExceptionDuringDetection() {
WorkerProcess workerProcess = addRunningWorkerProcess();
Process process = workerProcess.getProcess();
reset(process);
when(process.exitValue()).thenThrow(new IllegalArgumentException("expected exception"));
sleepMillis(5 * DEFAULT_SLEEP_TIME);
// when we place an oome file; the processing will stop
ensureExistingFile(workerProcess.getWorkerHome(), "worker.oome");
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertFailureType(failureHandler, WORKER_OOME);
}
});
}
Aggregations