Search in sources :

Example 1 with AssertTask

use of com.hazelcast.simulator.utils.AssertTask in project hazelcast-simulator by hazelcast.

the class PerformanceMonitorTest method test_whenTestRunning_thenSendPerformanceStats.

@Test
public void test_whenTestRunning_thenSendPerformanceStats() {
    performanceMonitor.start();
    sleepMillis(300);
    DummyTest test = new DummyTest();
    TestContext testContext = addTest(test);
    Thread runTestThread = new RunTestThread();
    runTestThread.start();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertPerfStatsSend();
        }
    });
    testContext.stop();
    joinThread(runTestThread);
    performanceMonitor.close();
}
Also used : DummyTest(com.hazelcast.simulator.tests.DummyTest) TestContext(com.hazelcast.simulator.test.TestContext) AssertTask(com.hazelcast.simulator.utils.AssertTask) CommonUtils.joinThread(com.hazelcast.simulator.utils.CommonUtils.joinThread) SuccessTest(com.hazelcast.simulator.tests.SuccessTest) Test(org.junit.Test) DummyTest(com.hazelcast.simulator.tests.DummyTest)

Example 2 with AssertTask

use of com.hazelcast.simulator.utils.AssertTask in project hazelcast-simulator by hazelcast.

the class MapStoreTest method verify.

@Verify(global = false)
public void verify() {
    if (isClient(targetInstance)) {
        return;
    }
    MapStoreConfig mapStoreConfig = targetInstance.getConfig().getMapConfig(name).getMapStoreConfig();
    int writeDelayMs = (int) TimeUnit.SECONDS.toMillis(mapStoreConfig.getWriteDelaySeconds());
    int sleepMs = mapStoreMaxDelayMs * 2 + maxTTLExpiryMs * 2 + (writeDelayMs * 2);
    logger.info("Sleeping for " + TimeUnit.MILLISECONDS.toSeconds(sleepMs) + " seconds to wait for delay and TTL values.");
    sleepMillis(sleepMs);
    final MapStoreWithCounter mapStore = (MapStoreWithCounter) mapStoreConfig.getImplementation();
    logger.info(name + ": map size = " + map.size());
    logger.info(name + ": map store = " + mapStore);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            for (Integer key : map.localKeySet()) {
                assertEquals(map.get(key), mapStore.get(key));
            }
            assertEquals("Map entrySets should be equal", map.getAll(map.localKeySet()).entrySet(), mapStore.entrySet());
            for (int key = putTTlKeyDomain; key < putTTlKeyDomain + putTTlKeyRange; key++) {
                assertNull(name + ": TTL key should not be in the map", map.get(key));
            }
        }
    });
}
Also used : AssertTask(com.hazelcast.simulator.utils.AssertTask) MapStoreConfig(com.hazelcast.config.MapStoreConfig) MapStoreWithCounter(com.hazelcast.simulator.tests.map.helpers.MapStoreWithCounter) Verify(com.hazelcast.simulator.test.annotations.Verify)

Example 3 with AssertTask

use of com.hazelcast.simulator.utils.AssertTask in project hazelcast-simulator by hazelcast.

the class MapTTLTest method globalVerify.

@Verify
public void globalVerify() {
    MapOperationCounter total = new MapOperationCounter();
    for (MapOperationCounter counter : results) {
        total.add(counter);
    }
    logger.info(name + ": " + total + " total of " + results.size());
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(name + ": Map should be empty, some TTL events are not processed", 0, map.size());
        }
    });
}
Also used : AssertTask(com.hazelcast.simulator.utils.AssertTask) MapOperationCounter(com.hazelcast.simulator.tests.map.helpers.MapOperationCounter) DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) Verify(com.hazelcast.simulator.test.annotations.Verify)

Example 4 with AssertTask

use of com.hazelcast.simulator.utils.AssertTask in project hazelcast-simulator by hazelcast.

the class ReplicatedTTL method localVerify.

@Verify(global = false)
public void localVerify() {
    MapOperationCounter total = new MapOperationCounter();
    for (MapOperationCounter counter : results) {
        total.add(counter);
    }
    logger.info(name + ": " + total + " total of " + results.size());
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            logger.info(name + ": " + "assert map Size = " + map.size());
            assertEquals(name + ": Replicated Map should be empty, some TTL events are not processed", 0, map.size());
        }
    });
}
Also used : AssertTask(com.hazelcast.simulator.utils.AssertTask) MapOperationCounter(com.hazelcast.simulator.tests.map.helpers.MapOperationCounter) DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) Verify(com.hazelcast.simulator.test.annotations.Verify)

Example 5 with AssertTask

use of com.hazelcast.simulator.utils.AssertTask in project hazelcast-simulator by hazelcast.

the class ReliableTopicTest method verify.

@Verify(global = true)
public void verify() {
    final long expectedCount = listenersPerTopic * totalMessagesSend.get();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            long actualCount = 0;
            for (MessageListenerImpl topicListener : listeners) {
                actualCount += topicListener.received.get();
            }
            assertEquals("published messages don't match received messages", expectedCount, actualCount);
        }
    });
    assertEquals("Failures found", 0, failures.get());
}
Also used : AssertTask(com.hazelcast.simulator.utils.AssertTask) IOException(java.io.IOException) TestException(com.hazelcast.simulator.test.TestException) Verify(com.hazelcast.simulator.test.annotations.Verify)

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