Search in sources :

Example 91 with ListeningTestLogger

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

the class BasicIndexTest method testConditionsWithoutIndexes.

/**
 *  Checks index usage for full coverage.
 */
@Test
public void testConditionsWithoutIndexes() throws Exception {
    inlineSize = 10;
    srvLog = new ListeningTestLogger(log);
    IgniteEx ig0 = startGrid(0);
    GridQueryProcessor qryProc = ig0.context().query();
    populateTable(qryProc, TEST_TBL_NAME, 2, "FIRST_NAME", "LAST_NAME", "ADDRESS", "LANG");
    String sqlIdx = String.format("create index \"idx1\" on %s(LANG, ADDRESS)", TEST_TBL_NAME);
    qryProc.querySqlFields(new SqlFieldsQuery(sqlIdx), true).getAll();
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "LAST_NAME"));
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "ADDRESS"));
    assertTrue(checkIdxUsed(qryProc, "idx1", TEST_TBL_NAME, "LANG"));
    // first idx fields not belongs to request fields.
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "ADDRESS", "LAST_NAME"));
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "ADDRESS", "ADDRESS"));
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "LAST_NAME", "ADDRESS"));
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "ADDRESS"));
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) GridQueryProcessor(org.apache.ignite.internal.processors.query.GridQueryProcessor) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) Test(org.junit.Test)

Example 92 with ListeningTestLogger

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

the class BasicIndexTest method testConditionsWithoutIndexesUseProxy.

/**
 *  Checks proxy index usage.
 */
@Test
public void testConditionsWithoutIndexesUseProxy() throws Exception {
    inlineSize = 10;
    srvLog = new ListeningTestLogger(log);
    IgniteEx ig0 = startGrid(0);
    GridQueryProcessor qryProc = ig0.context().query();
    populateTable(qryProc, TEST_TBL_NAME, 1, "ID", "VAL0", "VAL1");
    String sqlIdx = String.format("create index \"idx1\" on %s(VAL0, VAL1)", TEST_TBL_NAME);
    qryProc.querySqlFields(new SqlFieldsQuery(sqlIdx), true).getAll();
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "VAL1"));
    assertTrue(checkIdxUsed(qryProc, "idx1", TEST_TBL_NAME, "VAL0"));
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) GridQueryProcessor(org.apache.ignite.internal.processors.query.GridQueryProcessor) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) Test(org.junit.Test)

Example 93 with ListeningTestLogger

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

the class BasicIndexTest method testCheckThreeFieldsInPk.

/**
 * Check three fields in pk index.
 */
@Test
public void testCheckThreeFieldsInPk() throws Exception {
    inlineSize = 10;
    srvLog = new ListeningTestLogger(log);
    IgniteEx ig0 = startGrid(0);
    GridQueryProcessor qryProc = ig0.context().query();
    populateTable(qryProc, TEST_TBL_NAME, 3, "c1", "c2", "c3", "c4", "c5", "c6");
    assertTrue(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "c1"));
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "c2"));
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "c3"));
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) GridQueryProcessor(org.apache.ignite.internal.processors.query.GridQueryProcessor) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) Test(org.junit.Test)

Example 94 with ListeningTestLogger

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

the class BasicIndexTest method runEqualFieldsDynamicIndexes.

/**
 */
private void runEqualFieldsDynamicIndexes(boolean persistEnabled) throws Exception {
    isPersistenceEnabled = persistEnabled;
    indexes = Collections.singletonList(new QueryIndex("valStr"));
    inlineSize = 10;
    srvLog = new ListeningTestLogger(log);
    clientLog = new ListeningTestLogger(log);
    String msg1 = "Index with the given set or subset of columns already exists";
    LogListener lsnr = LogListener.matches(msg1).andMatches(Pattern.compile(".*newIndexName=idx[0-9]")).build();
    LogListener staticCachesLsnr = LogListener.matches(msg1).build();
    srvLog.registerListener(staticCachesLsnr);
    IgniteEx ig0 = startGrid(0);
    if (persistEnabled)
        ig0.cluster().active(true);
    IgniteCache<Key, Val> cache = grid(0).cache(DEFAULT_CACHE_NAME);
    populateCache();
    cache.query(new SqlFieldsQuery("create index \"idx0\" on Val(valStr)"));
    assertTrue(staticCachesLsnr.check());
    srvLog.unregisterListener(staticCachesLsnr);
    srvLog.registerListener(lsnr);
    cache.query(new SqlFieldsQuery("create index \"idx1\" on Val(valStr, valLong)"));
    cache.query(new SqlFieldsQuery("create index \"idx2\" on Val(valStr desc, valLong)"));
    assertFalse(lsnr.check());
    cache.query(new SqlFieldsQuery("create index \"idx3\" on Val(valStr, valLong)"));
    cache.query(new SqlFieldsQuery("create index \"idx4\" on Val(valLong)"));
    String plan = cache.query(new SqlFieldsQuery("explain select min(_key), max(_key) from Val")).getAll().get(0).get(0).toString().toUpperCase();
    assertTrue(plan, plan.contains(PK_IDX_NAME.toUpperCase()));
    assertTrue(lsnr.check());
    srvLog.unregisterListener(lsnr);
    IgniteEx client = startClientGrid(CLIENT_NAME);
    cache = client.cache(DEFAULT_CACHE_NAME);
    LogListener lsnrIdx5 = LogListener.matches(msg1).andMatches("idx5").build();
    srvLog.registerListener(lsnrIdx5);
    cache.query(new SqlFieldsQuery("create index \"idx5\" on Val(valStr desc, valLong)"));
    assertTrue(lsnrIdx5.check());
    LogListener lsnrIdx7 = LogListener.matches(msg1).andMatches("idx7").build();
    srvLog.registerListener(lsnrIdx7);
    cache.query(new SqlFieldsQuery("create index \"idx6\" on Val(valLong)"));
    cache.query(new SqlFieldsQuery("create index \"idx7\" on Val(keyStr, keyLong, keyPojo, valLong)"));
    assertFalse(lsnrIdx7.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) QueryIndex(org.apache.ignite.cache.QueryIndex) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery)

Example 95 with ListeningTestLogger

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

the class LongRunningQueryTest method testLog.

/**
 * Setup and return test log.
 *
 * @return Test logger.
 */
private ListeningTestLogger testLog() {
    ListeningTestLogger testLog = new ListeningTestLogger(false, log);
    GridTestUtils.setFieldValue(((IgniteH2Indexing) grid().context().query().getIndexing()).longRunningQueries(), "log", testLog);
    GridTestUtils.setFieldValue(((IgniteH2Indexing) grid().context().query().getIndexing()).mapQueryExecutor(), "log", testLog);
    GridTestUtils.setFieldValue(grid().context().query().getIndexing(), "log", testLog);
    return testLog;
}
Also used : ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger)

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