Search in sources :

Example 6 with AssertTask

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);
}
Also used : AssertTask(com.hazelcast.simulator.utils.AssertTask) Verify(com.hazelcast.simulator.test.annotations.Verify)

Example 7 with AssertTask

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);
        }
    });
}
Also used : AssertTask(com.hazelcast.simulator.utils.AssertTask) Verify(com.hazelcast.simulator.test.annotations.Verify)

Example 8 with AssertTask

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());
        }
    });
}
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 9 with AssertTask

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);
}
Also used : DistributedObject(com.hazelcast.core.DistributedObject) AssertTask(com.hazelcast.simulator.utils.AssertTask) StopException(com.hazelcast.simulator.test.StopException) Verify(com.hazelcast.simulator.test.annotations.Verify)

Example 10 with AssertTask

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);
        }
    });
}
Also used : AssertTask(com.hazelcast.simulator.utils.AssertTask) Test(org.junit.Test)

Aggregations

AssertTask (com.hazelcast.simulator.utils.AssertTask)12 Verify (com.hazelcast.simulator.test.annotations.Verify)7 Test (org.junit.Test)5 SimulatorAddress (com.hazelcast.simulator.protocol.core.SimulatorAddress)2 LogOperation (com.hazelcast.simulator.protocol.operation.LogOperation)2 SimulatorOperation (com.hazelcast.simulator.protocol.operation.SimulatorOperation)2 SuccessTest (com.hazelcast.simulator.tests.SuccessTest)2 MapOperationCounter (com.hazelcast.simulator.tests.map.helpers.MapOperationCounter)2 DistributedObjectDestroyedException (com.hazelcast.spi.exception.DistributedObjectDestroyedException)2 ExecutionException (java.util.concurrent.ExecutionException)2 JMSException (javax.jms.JMSException)2 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 DistributedObject (com.hazelcast.core.DistributedObject)1 TestCase (com.hazelcast.simulator.common.TestCase)1 StubPromise (com.hazelcast.simulator.protocol.StubPromise)1 StopException (com.hazelcast.simulator.test.StopException)1 TestContext (com.hazelcast.simulator.test.TestContext)1 TestException (com.hazelcast.simulator.test.TestException)1 DummyTest (com.hazelcast.simulator.tests.DummyTest)1 FailingTest (com.hazelcast.simulator.tests.FailingTest)1