Search in sources :

Example 46 with ListeningTestLogger

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

the class BasicIndexTest method testAllTableFieldsCoveredByIdx.

/**
 *  Checks index usage for full coverage.
 */
@Test
public void testAllTableFieldsCoveredByIdx() 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");
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "LANG"));
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "LAST_NAME"));
    assertTrue(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "FIRST_NAME"));
    assertTrue(checkIdxUsed(qryProc, PK_IDX_NAME, TEST_TBL_NAME, "FIRST_NAME", "LAST_NAME", "LANG", "ADDRESS"));
    assertTrue(checkIdxAlreadyExistLog(qryProc, "idx1", TEST_TBL_NAME, "FIRST_NAME", "LAST_NAME"));
    String sqlIdx2 = String.format("create index \"idx2\" on %s(LANG, ADDRESS)", TEST_TBL_NAME);
    qryProc.querySqlFields(new SqlFieldsQuery(sqlIdx2), true).getAll();
    assertTrue(checkIdxUsed(qryProc, "idx2", TEST_TBL_NAME, "FIRST_NAME", "LAST_NAME", "LANG", "ADDRESS"));
    assertTrue(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "FIRST_NAME", "LAST_NAME", "ADDRESS", "LANG"));
}
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 47 with ListeningTestLogger

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

the class BasicIndexTest method testInlineSizeChange.

/**
 */
@Test
@WithSystemProperty(key = IGNITE_THROTTLE_INLINE_SIZE_CALCULATION, value = "1")
public void testInlineSizeChange() throws Exception {
    isPersistenceEnabled = true;
    indexes = Collections.singletonList(new QueryIndex("valStr"));
    inlineSize = 33;
    srvLog = new ListeningTestLogger(false, log);
    String msg1 = "curSize=1";
    String msg2 = "curSize=2";
    String msg3 = "curSize=3";
    LogListener lstn1 = LogListener.matches(msg1).build();
    LogListener lstn2 = LogListener.matches(msg2).build();
    LogListener lstn3 = LogListener.matches(msg3).build();
    srvLog.registerListener(lstn1);
    srvLog.registerListener(lstn2);
    srvLog.registerListener(lstn3);
    IgniteEx ig0 = startGrid(0);
    ig0.cluster().active(true);
    populateCache();
    IgniteCache<Key, Val> cache = grid(0).cache(DEFAULT_CACHE_NAME);
    execSql(cache, "create index \"idx1\" on Val(valLong) INLINE_SIZE 1 PARALLEL 28");
    List<List<?>> res = execSql(cache, "explain select * from Val where valLong > ?", 10);
    log.info("exp: " + res.get(0).get(0));
    assertTrue(lstn1.check());
    execSql(cache, "drop index \"idx1\"");
    execSql(cache, "create index \"idx1\" on Val(valLong) INLINE_SIZE 2 PARALLEL 28");
    execSql(cache, "explain select * from Val where valLong > ?", 10);
    assertTrue(lstn2.check());
    execSql(cache, "drop index \"idx1\"");
    stopAllGrids();
    ig0 = startGrid(0);
    ig0.cluster().active(true);
    cache = ig0.cache(DEFAULT_CACHE_NAME);
    execSql(cache, "create index \"idx1\" on Val(valLong) INLINE_SIZE 3 PARALLEL 28");
    execSql(cache, "explain select * from Val where valLong > ?", 10);
    assertTrue(lstn3.check());
    stopAllGrids();
    cleanPersistenceDir();
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) QueryIndex(org.apache.ignite.cache.QueryIndex) List(java.util.List) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 48 with ListeningTestLogger

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

the class BasicIndexTest method testCreateIdxWithDifferentIdxFldsSeq.

/**
 * Test composite indices with PK field in first place.
 *
 * There is no sense to create such indices:
 * 1. PK index will be enough for equality condition on PK field.
 * 2. None of these indices will be used for non-equality condition on PK field.
 */
@Test
public void testCreateIdxWithDifferentIdxFldsSeq() throws Exception {
    inlineSize = 10;
    srvLog = new ListeningTestLogger(false, log);
    IgniteEx ig0 = startGrid(0);
    IgniteEx client = startClientGrid(CLIENT_NAME);
    GridQueryProcessor qryProc = ig0.context().query();
    populateTable(qryProc, TEST_TBL_NAME, 1, "c1", "c2", "c3", "c4", "c5");
    assertFalse(checkIdxAlreadyExistLog(qryProc, "idx1", TEST_TBL_NAME, "c1", "c2", "c3", "c4", "c5"));
    assertFalse(checkIdxAlreadyExistLog(qryProc, "idx2", TEST_TBL_NAME, "c1", "c3", "c4", "c5"));
    assertTrue(checkIdxAlreadyExistLog(qryProc, "idx3", TEST_TBL_NAME, "c1", "c2"));
    assertTrue(checkIdxAlreadyExistLog(qryProc, "idx4", TEST_TBL_NAME, "c1", "c3"));
    assertFalse(checkIdxAlreadyExistLog(qryProc, "idx5", TEST_TBL_NAME, "c1", "c4", "c5"));
    GridQueryProcessor qryProcCl = client.context().query();
    assertTrue(checkIdxAlreadyExistLog(qryProcCl, "idx6", TEST_TBL_NAME, "c1", "c2"));
}
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 49 with ListeningTestLogger

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

the class BasicIndexTest method testPartialTableFieldsCoveredByIdx.

/**
 *  Checks index usage for partial coverage.
 *  Last field not participate in any index.
 */
@Test
public void testPartialTableFieldsCoveredByIdx() throws Exception {
    inlineSize = 10;
    String msg0 = "Index with the given set or subset of columns already exists";
    srvLog = new ListeningTestLogger(false, log);
    IgniteEx ig0 = startGrid(0);
    GridQueryProcessor qryProc = ig0.context().query();
    String cacheName = QueryUtils.createTableCacheName("PUBLIC", "TEST_TABLE");
    populateTable(qryProc, TEST_TBL_NAME, 2, "FIRST_NAME", "LAST_NAME", "ADDRESS", "LANG", "GENDER");
    IgniteCache<Object, Object> jcache = ig0.cache(cacheName);
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "LANG"));
    assertFalse(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "LAST_NAME"));
    assertTrue(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "FIRST_NAME"));
    assertTrue(checkIdxUsed(qryProc, PK_IDX_NAME, TEST_TBL_NAME, "FIRST_NAME", "LAST_NAME", "LANG", "ADDRESS"));
    assertTrue(checkIdxAlreadyExistLog(qryProc, "idx1", TEST_TBL_NAME, "FIRST_NAME", "LAST_NAME"));
    String sqlIdx2 = String.format("create index \"idx2\" on %s(LANG, ADDRESS)", TEST_TBL_NAME);
    qryProc.querySqlFields(new SqlFieldsQuery(sqlIdx2), true).getAll();
    // PK_IDX_NAME used.
    assertFalse(checkIdxUsed(qryProc, "idx2", TEST_TBL_NAME, "FIRST_NAME", "LAST_NAME", "LANG", "ADDRESS"));
    assertTrue(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "FIRST_NAME", "LAST_NAME", "LANG", "ADDRESS"));
    assertTrue(checkIdxUsed(qryProc, null, TEST_TBL_NAME, "FIRST_NAME", "LAST_NAME", "ADDRESS", "LANG"));
    // first idx fields not belongs to request fields.
    assertFalse(checkIdxUsed(qryProc, "idx2", TEST_TBL_NAME, "ADDRESS", "LAST_NAME"));
    assertFalse(checkIdxAlreadyExistLog(qryProc, "idx3", TEST_TBL_NAME, "ADDRESS", "LANG"));
    assertTrue(checkIdxAlreadyExistLog(qryProc, "idx4", TEST_TBL_NAME, "FIRST_NAME", "LAST_NAME", "ADDRESS", "LANG"));
    LogListener lsnrIdx4 = LogListener.matches(msg0).andMatches(PK_IDX_NAME).build();
    srvLog.registerListener(lsnrIdx4);
    String sqlIdx5 = String.format("create index \"idx5\" on %s(FIRST_NAME, LAST_NAME, LANG, ADDRESS)", TEST_TBL_NAME);
    jcache.query(new SqlFieldsQuery(sqlIdx5)).getAll();
    assertTrue(lsnrIdx4.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) 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 50 with ListeningTestLogger

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

the class WriteAheadLogManagerSelfTest method testAutoArchiveWithoutNullPointerException.

/**
 * Check that auto archive will execute without {@link NullPointerException}.
 *
 * @throws Exception If failed.
 */
@Test
public void testAutoArchiveWithoutNullPointerException() throws Exception {
    setRootLoggerDebugLevel();
    LogListener logLsnr0 = LogListener.matches("Checking if WAL rollover required").build();
    LogListener logLsnr1 = LogListener.matches(Pattern.compile("Rollover segment \\[\\d+ to \\d+\\], recordType=null")).build();
    IgniteEx n = startGrid(0, cfg -> {
        cfg.setGridLogger(new ListeningTestLogger(log, logLsnr0, logLsnr1)).getDataStorageConfiguration().setWalAutoArchiveAfterInactivity(100_000);
    });
    n.cluster().state(ACTIVE);
    awaitPartitionMapExchange();
    GridTimeoutObject timeoutObj = timeoutRollover(n);
    assertNotNull(timeoutObj);
    n.cache(DEFAULT_CACHE_NAME).put(current().nextInt(), new byte[16]);
    disableWal(n);
    lastRecordLoggedMs(n).set(1);
    timeoutObj.onTimeout();
    assertTrue(logLsnr0.check());
    assertTrue(logLsnr1.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) GridTimeoutObject(org.apache.ignite.internal.processors.timeout.GridTimeoutObject) 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