Search in sources :

Example 16 with Verify

use of com.hazelcast.simulator.test.annotations.Verify in project hazelcast-simulator by hazelcast.

the class ListenerICacheTest method globalVerify.

@Verify
public void globalVerify() {
    ThreadState totalCounter = new ThreadState();
    for (ThreadState counter : results) {
        totalCounter.add(counter);
    }
    logger.info(name + " " + totalCounter + " from " + results.size() + " Worker threads");
    ICacheEntryListener totalEvents = new ICacheEntryListener();
    for (ICacheEntryListener entryListener : listeners) {
        totalEvents.add(entryListener);
    }
    logger.info(name + " totalEvents: " + totalEvents);
    assertEquals(name + " unexpected events found", 0, totalEvents.getUnexpected());
}
Also used : ICacheEntryListener(com.hazelcast.simulator.tests.icache.helpers.ICacheEntryListener) BaseThreadState(com.hazelcast.simulator.test.BaseThreadState) Verify(com.hazelcast.simulator.test.annotations.Verify)

Example 17 with Verify

use of com.hazelcast.simulator.test.annotations.Verify in project hazelcast-simulator by hazelcast.

the class ReadWriteICacheTest method globalVerify.

@Verify(global = true)
public void globalVerify() {
    ICacheReadWriteCounter total = new ICacheReadWriteCounter();
    for (ICacheReadWriteCounter counter : counters) {
        total.add(counter);
    }
    logger.info(name + ": " + total + " from " + counters.size() + " worker threads");
}
Also used : ICacheReadWriteCounter(com.hazelcast.simulator.tests.icache.helpers.ICacheReadWriteCounter) Verify(com.hazelcast.simulator.test.annotations.Verify)

Example 18 with Verify

use of com.hazelcast.simulator.test.annotations.Verify in project hazelcast-simulator by hazelcast.

the class LeaseLockTest method verify.

@Verify
public void verify() {
    for (int i = 0; i < lockCount; i++) {
        ILock lock = targetInstance.getLock(name + i);
        boolean isLocked = lock.isLocked();
        long remainingLeaseTime = lock.getRemainingLeaseTime();
        if (isLocked) {
            String message = format("%s is locked with remainingLeaseTime: %d ms", lock, remainingLeaseTime);
            if (allowZeroMillisRemainingLeaseLockTime && remainingLeaseTime == 0) {
                logger.warn(message);
            } else {
                fail(message);
            }
        }
        if (remainingLeaseTime > 0) {
            fail(format("%s has remainingLeaseTime: %d ms", lock, remainingLeaseTime));
        }
    }
}
Also used : ILock(com.hazelcast.core.ILock) Verify(com.hazelcast.simulator.test.annotations.Verify)

Example 19 with Verify

use of com.hazelcast.simulator.test.annotations.Verify 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 20 with Verify

use of com.hazelcast.simulator.test.annotations.Verify in project hazelcast-simulator by hazelcast.

the class LockTest method verify.

@Verify
public void verify() {
    long actual = 0;
    for (long i = 0; i < lockCounter.get(); i++) {
        ILock lock = targetInstance.getLock(getLockId(i));
        assertFalse("Lock should be unlocked", lock.isLocked());
        long accountAmount = targetInstance.getAtomicLong(getAccountId(i)).get();
        assertTrue("Amount on account can't be smaller than 0", accountAmount >= 0);
        actual += accountAmount;
    }
    long expected = initialAmount * lockCounter.get();
    assertEquals(format("%s: Money was lost or created (%d)", name, expected - actual), expected, actual);
}
Also used : ILock(com.hazelcast.core.ILock) Verify(com.hazelcast.simulator.test.annotations.Verify)

Aggregations

Verify (com.hazelcast.simulator.test.annotations.Verify)31 AssertTask (com.hazelcast.simulator.utils.AssertTask)7 ILock (com.hazelcast.core.ILock)4 MapOperationCounter (com.hazelcast.simulator.tests.map.helpers.MapOperationCounter)4 TxnCounter (com.hazelcast.simulator.tests.helpers.TxnCounter)3 MapStoreConfig (com.hazelcast.config.MapStoreConfig)2 DistributedObject (com.hazelcast.core.DistributedObject)2 DistributedObjectDestroyedException (com.hazelcast.spi.exception.DistributedObjectDestroyedException)2 CardinalityEstimator (com.hazelcast.cardinality.CardinalityEstimator)1 MapConfig (com.hazelcast.config.MapConfig)1 IAtomicLong (com.hazelcast.core.IAtomicLong)1 IQueue (com.hazelcast.core.IQueue)1 BaseThreadState (com.hazelcast.simulator.test.BaseThreadState)1 StopException (com.hazelcast.simulator.test.StopException)1 TestException (com.hazelcast.simulator.test.TestException)1 ICacheCreateDestroyCounter (com.hazelcast.simulator.tests.icache.helpers.ICacheCreateDestroyCounter)1 ICacheEntryListener (com.hazelcast.simulator.tests.icache.helpers.ICacheEntryListener)1 ICacheListenerOperationCounter (com.hazelcast.simulator.tests.icache.helpers.ICacheListenerOperationCounter)1 ICacheOperationCounter (com.hazelcast.simulator.tests.icache.helpers.ICacheOperationCounter)1 ICacheReadWriteCounter (com.hazelcast.simulator.tests.icache.helpers.ICacheReadWriteCounter)1