Search in sources :

Example 71 with ListeningTestLogger

use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.

the class GridCacheHashMapPutAllWarningsTest method testHashMapPutAllExplicitOptimistic.

/**
 * @throws Exception If failed.
 */
@Test
public void testHashMapPutAllExplicitOptimistic() throws Exception {
    if (MvccFeatureChecker.forcedMvcc())
        return;
    List<String> messages = Collections.synchronizedList(new ArrayList<>());
    testLog = new ListeningTestLogger(false, log());
    testLog.registerListener((s) -> {
        if (s.contains("deadlock"))
            messages.add(s);
    });
    Ignite ignite = startGrid(0);
    IgniteCache<Integer, String> c = ignite.getOrCreateCache(new CacheConfiguration<Integer, String>("explicitTx").setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
    ignite.transactions().txStart(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
    HashMap<Integer, String> m = new HashMap<>();
    m.put(1, "foo");
    m.put(2, "bar");
    c.putAllAsync(m);
    ignite.transactions().tx().commit();
    assertEquals(2, c.size());
    for (String message : messages) {
        assertFalse(message.contains("Unordered map"));
        assertFalse(message.contains("operation on cache"));
    }
}
Also used : HashMap(java.util.HashMap) Ignite(org.apache.ignite.Ignite) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 72 with ListeningTestLogger

use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.

the class GridCacheHashMapPutAllWarningsTest method testHashSetGetAllReplicated.

/**
 * @throws Exception If failed.
 */
@Test
public void testHashSetGetAllReplicated() throws Exception {
    List<String> messages = Collections.synchronizedList(new ArrayList<>());
    testLog = new ListeningTestLogger(false, log());
    testLog.registerListener((s) -> {
        if (s.contains("deadlock"))
            messages.add(s);
    });
    Ignite ignite = startGrid(0);
    IgniteCache<Integer, String> c = ignite.getOrCreateCache(new CacheConfiguration<Integer, String>("get").setCacheMode(CacheMode.REPLICATED));
    c.put(1, "foo");
    c.put(2, "bar");
    assertEquals(1, c.getAll(new HashSet<>(Arrays.asList(1, 3))).size());
    int found = 0;
    for (String message : messages) {
        if (message.contains("Unordered collection "))
            found++;
        if (message.contains("operation on cache"))
            found++;
    }
    assertEquals(0, found);
}
Also used : Ignite(org.apache.ignite.Ignite) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 73 with ListeningTestLogger

use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.

the class GridCacheHashMapPutAllWarningsTest method testTreeMapRemoveAll.

/**
 * @throws Exception If failed.
 */
@Test
public void testTreeMapRemoveAll() throws Exception {
    List<String> messages = Collections.synchronizedList(new ArrayList<>());
    testLog = new ListeningTestLogger(false, log());
    testLog.registerListener((s) -> {
        if (s.contains("deadlock"))
            messages.add(s);
    });
    Ignite ignite = startGrid(0);
    IgniteCache<Integer, String> c = ignite.getOrCreateCache(new CacheConfiguration<Integer, String>("remove").setCacheMode(CacheMode.PARTITIONED));
    c.put(1, "foo");
    c.put(2, "bar");
    c.removeAll(new TreeSet<>(Arrays.asList(1, 3)));
    assertEquals(1, c.size());
    int found = 0;
    for (String message : messages) {
        if (message.contains("Unordered collection "))
            found++;
        if (message.contains("operation on cache"))
            found++;
    }
    assertEquals(0, found);
}
Also used : Ignite(org.apache.ignite.Ignite) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 74 with ListeningTestLogger

use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.

the class GridCacheHashMapPutAllWarningsTest method testTreeMapRemoveAllEntries.

/**
 * @throws Exception If failed.
 */
@Test
public void testTreeMapRemoveAllEntries() throws Exception {
    List<String> messages = Collections.synchronizedList(new ArrayList<>());
    testLog = new ListeningTestLogger(false, log());
    testLog.registerListener((s) -> {
        if (s.contains("deadlock"))
            messages.add(s);
    });
    Ignite ignite = startGrid(0);
    startGrid(1);
    IgniteCache<Integer, String> c = ignite.getOrCreateCache(new CacheConfiguration<Integer, String>("entries").setCacheMode(CacheMode.REPLICATED).setAtomicityMode(CacheAtomicityMode.ATOMIC).setBackups(1));
    for (int i = 0; i < 1000; i++) {
        c.put(i, "foo");
        c.put(i * 2, "bar");
    }
    c.removeAll();
    assertEquals(0, c.size());
    for (String message : messages) {
        assertFalse(message.contains("Unordered collection "));
        assertFalse(message.contains("operation on cache"));
    }
}
Also used : Ignite(org.apache.ignite.Ignite) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 75 with ListeningTestLogger

use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.

the class GridCacheHashMapPutAllWarningsTest method testHashMapAtomic.

/**
 * @throws Exception If failed.
 */
@Test
public void testHashMapAtomic() throws Exception {
    List<String> messages = Collections.synchronizedList(new ArrayList<>());
    testLog = new ListeningTestLogger(log());
    testLog.registerListener((s) -> {
        if (s.contains("deadlock"))
            messages.add(s);
    });
    Ignite ignite = startGrid(0);
    IgniteCache<Integer, String> c = ignite.getOrCreateCache(new CacheConfiguration<Integer, String>("atomic").setAtomicityMode(CacheAtomicityMode.ATOMIC));
    HashMap<Integer, String> m = new HashMap<>();
    m.put(1, "foo");
    m.put(2, "bar");
    c.putAll(m);
    c.invokeAll(m.keySet(), (k, v) -> v);
    c.removeAll(m.keySet());
    c.removeAll();
    assertEquals(0, c.size());
    for (String message : messages) {
        assertFalse(message.contains("Unordered "));
        assertFalse(message.contains("operation on cache"));
    }
}
Also used : HashMap(java.util.HashMap) Ignite(org.apache.ignite.Ignite) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

ListeningTestLogger (org.apache.ignite.testframework.ListeningTestLogger)101 Test (org.junit.Test)51 LogListener (org.apache.ignite.testframework.LogListener)48 IgniteEx (org.apache.ignite.internal.IgniteEx)36 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)32 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)30 Ignite (org.apache.ignite.Ignite)21 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)21 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)17 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)14 CountDownLatch (java.util.concurrent.CountDownLatch)9 IgniteCache (org.apache.ignite.IgniteCache)9 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)9 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)9 List (java.util.List)8 Pattern (java.util.regex.Pattern)8 ClusterState (org.apache.ignite.cluster.ClusterState)7 GridQueryProcessor (org.apache.ignite.internal.processors.query.GridQueryProcessor)7 Collections (java.util.Collections)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6