Search in sources :

Example 1 with TxnCounter

use of com.hazelcast.simulator.tests.helpers.TxnCounter in project hazelcast-simulator by hazelcast.

the class MapTransactionGetForUpdateTest method verify.

@Verify(global = false)
public void verify() {
    IList<TxnCounter> counts = targetInstance.getList(name + "report");
    TxnCounter total = new TxnCounter();
    for (TxnCounter c : counts) {
        total.add(c);
    }
    logger.info(name + ": " + total + " from " + counts.size() + " workers");
    IList<long[]> allIncrements = targetInstance.getList(name + "res");
    long[] expected = new long[keyCount];
    for (long[] incs : allIncrements) {
        for (int i = 0; i < incs.length; i++) {
            expected[i] += incs[i];
        }
    }
    IMap<Integer, Long> map = targetInstance.getMap(name);
    int failures = 0;
    for (int i = 0; i < keyCount; i++) {
        if (expected[i] != map.get(i)) {
            failures++;
            logger.info(name + ": key=" + i + " expected " + expected[i] + " != " + "actual " + map.get(i));
        }
    }
    assertEquals(name + ": " + failures + " key=>values have been incremented unExpected", 0, failures);
}
Also used : TxnCounter(com.hazelcast.simulator.tests.helpers.TxnCounter) Verify(com.hazelcast.simulator.test.annotations.Verify)

Example 2 with TxnCounter

use of com.hazelcast.simulator.tests.helpers.TxnCounter in project hazelcast-simulator by hazelcast.

the class MapTransactionContextConflictTest method verify.

@Verify(global = false)
public void verify() {
    IList<TxnCounter> counts = targetInstance.getList(name + "count");
    TxnCounter total = new TxnCounter();
    for (TxnCounter c : counts) {
        total.add(c);
    }
    logger.info(name + ": " + total + " from " + counts.size() + " worker threads");
    IList<long[]> allIncrements = targetInstance.getList(name + "inc");
    long[] expected = new long[keyCount];
    for (long[] incs : allIncrements) {
        for (int i = 0; i < incs.length; i++) {
            expected[i] += incs[i];
        }
    }
    IMap<Integer, Long> map = targetInstance.getMap(name);
    int failures = 0;
    for (int i = 0; i < keyCount; i++) {
        if (expected[i] != map.get(i)) {
            failures++;
            logger.info(name + ": key=" + i + " expected " + expected[i] + " != " + "actual " + map.get(i));
        }
    }
    assertEquals(name + ": " + failures + " key=>values have been incremented unExpected", 0, failures);
}
Also used : TxnCounter(com.hazelcast.simulator.tests.helpers.TxnCounter) Verify(com.hazelcast.simulator.test.annotations.Verify)

Example 3 with TxnCounter

use of com.hazelcast.simulator.tests.helpers.TxnCounter in project hazelcast-simulator by hazelcast.

the class TxnQueueWithLockTest method globalVerify.

@Verify
public void globalVerify() {
    IQueue queue = targetInstance.getQueue(name + 'q');
    IList<TxnCounter> results = targetInstance.getList(name + "results");
    TxnCounter total = new TxnCounter();
    for (TxnCounter counter : results) {
        total.add(counter);
    }
    logger.info(name + ": " + total + " from " + results.size() + " worker Threads  Queue size=" + queue.size());
    assertFalse(name + ": firstLock.isLocked()", firstLock.isLocked());
    assertFalse(name + ": secondLock.isLocked()", secondLock.isLocked());
// TODO: check if this assert can be re-enabled: assertEquals(total.committed - total.rolled, queue.size())
}
Also used : IQueue(com.hazelcast.core.IQueue) TxnCounter(com.hazelcast.simulator.tests.helpers.TxnCounter) Verify(com.hazelcast.simulator.test.annotations.Verify)

Aggregations

Verify (com.hazelcast.simulator.test.annotations.Verify)3 TxnCounter (com.hazelcast.simulator.tests.helpers.TxnCounter)3 IQueue (com.hazelcast.core.IQueue)1