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"));
}
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"));
}
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"));
}
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());
}
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;
}
Aggregations