Search in sources :

Example 66 with LogListener

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

the class GridTcpCommunicationSpiLogTest method testClientDisconnectDebugLogMessage.

/**
 * @throws Exception If failed.
 */
@Test
public void testClientDisconnectDebugLogMessage() throws Exception {
    LogListener logLsnr0 = LogListener.matches("The node was disconnected").atLeast(1).atMost(1).build();
    srvTestLog.registerListener(logLsnr0);
    Ignite srv = startGrid(0);
    Ignite client = startGrid(1);
    client.close();
    U.sleep(1000);
    assertTrue(logLsnr0.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 67 with LogListener

use of org.apache.ignite.testframework.LogListener 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 68 with LogListener

use of org.apache.ignite.testframework.LogListener 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 69 with LogListener

use of org.apache.ignite.testframework.LogListener 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)

Example 70 with LogListener

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

the class IgniteWalRebalanceLoggingTest method testFullRebalanceLogMsgs.

/**
 * Check that in case of Full rebalance we log appropriate messages.
 * <p>
 *     <b>Steps:</b>
 *     <ol>
 *         <li>restore IGNITE_PDS_WAL_REBALANCE_THRESHOLD to default 500000</li>
 *         <li>Start two nodes.</li>
 *         <li>Create two caches each in it's own cache group and populate them with some data.</li>
 *         <li>Stop second node and add more data to both caches.</li>
 *         <li>Wait checkpoint frequency * 2. This is required to guarantee that at least one checkpoint would be
 *         created.</li>
 *         <li>Start, previously stopped node and await for PME.</li>
 *     </ol>
 * <p>
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_PDS_WAL_REBALANCE_THRESHOLD, value = "500000")
public void testFullRebalanceLogMsgs() throws Exception {
    LogListener expMsgsLsnr = LogListener.matches("Partitions weren't present in any history reservation: " + "[[grp=cache_group2 part=[[0-7]]], [grp=cache_group1 part=[[0-7]]]]").andMatches(str -> str.startsWith("Starting rebalance routine") && (str.contains("cache_group1") || str.contains("cache_group2")) && str.contains("fullPartitions=[0-7], histPartitions=[]")).times(2).build();
    checkFollowingPartitionsWereReservedForPotentialHistoryRebalanceMsg(expMsgsLsnr);
    assertTrue(expMsgsLsnr.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Aggregations

LogListener (org.apache.ignite.testframework.LogListener)144 Test (org.junit.Test)116 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)93 ListeningTestLogger (org.apache.ignite.testframework.ListeningTestLogger)68 IgniteEx (org.apache.ignite.internal.IgniteEx)65 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)35 Ignite (org.apache.ignite.Ignite)32 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)31 IgniteCache (org.apache.ignite.IgniteCache)24 WithSystemProperty (org.apache.ignite.testframework.junits.WithSystemProperty)23 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)18 GridTestUtils (org.apache.ignite.testframework.GridTestUtils)16 List (java.util.List)15 CountDownLatch (java.util.concurrent.CountDownLatch)15 Pattern (java.util.regex.Pattern)15 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)14 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)13 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)13 UUID (java.util.UUID)12 Collections (java.util.Collections)11