Search in sources :

Example 11 with LogListener

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

the class GridCommandHandlerBrokenIndexTest method testIndexFindFail.

/**
 * Tests Cursor initialisation failure by adding artificial index that will fail in required way.
 *
 * @see H2TreeIndexBase#find(Session, SearchRow, SearchRow)
 */
@Test
public void testIndexFindFail() throws Exception {
    cleanPersistenceDir();
    prepareGridForTest();
    injectTestSystemOut();
    addBadIndex();
    assertEquals(EXIT_CODE_OK, execute("--cache", "validate_indexes", CACHE_NAME));
    assertTrue(!lsnrs.isEmpty());
    LogListener lsnrWithError = lsnrs.stream().filter(LogListener::check).findAny().orElse(null);
    assertNotNull("\"Failed to lookup key:\" message not found in ignite log", lsnrWithError);
    Pattern viErrMsgPattern = Pattern.compile(IDX_ISSUE_STR);
    assertTrue(viErrMsgPattern.matcher(testOut.toString()).find());
}
Also used : Pattern(java.util.regex.Pattern) LogListener(org.apache.ignite.testframework.LogListener) Test(org.junit.Test)

Example 12 with LogListener

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

the class AutoActivationPropertyTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    ListeningTestLogger testLog = new ListeningTestLogger(false, log);
    LogListener lsnr = LogListener.matches("Property autoActivation deprecated. Use clusterStateOnStart instead.").build();
    testLog.registerListener(lsnr);
    logListeners.put(igniteInstanceName, lsnr);
    return super.getConfiguration(igniteInstanceName).setGridLogger(testLog).setAutoActivationEnabled(autoActivation).setCacheConfiguration(new CacheConfiguration().setName(DEFAULT_CACHE_NAME)).setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) LogListener(org.apache.ignite.testframework.LogListener) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 13 with LogListener

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

the class CacheDataRegionConfigurationTest method testWarningIfDynamicCacheOverheadExceedsThreshold.

/**
 * Verifies that warning message is printed to the logs if user tries to start a dynamic cache in data region which
 * overhead (e.g. metapages for partitions) occupies more space of the region than a defined threshold.
 *
 * @throws Exception If failed.
 */
@Test
public void testWarningIfDynamicCacheOverheadExceedsThreshold() throws Exception {
    String filteredSrvName = "srv2";
    int numOfPartitions = 512;
    int partitionsMetaMemoryChunk = U.sizeInMegabytes(512 * DFLT_PAGE_SIZE);
    DataRegionConfiguration smallRegionCfg = new DataRegionConfiguration();
    smallRegionCfg.setName("smallRegion");
    smallRegionCfg.setInitialSize(DFLT_MEM_PLC_SIZE);
    smallRegionCfg.setMaxSize(DFLT_MEM_PLC_SIZE);
    smallRegionCfg.setPersistenceEnabled(true);
    // explicit default data region configuration to test possible NPE case
    DataRegionConfiguration defaultRegionCfg = new DataRegionConfiguration();
    defaultRegionCfg.setName("defaultRegion");
    defaultRegionCfg.setInitialSize(DFLT_MEM_PLC_SIZE);
    defaultRegionCfg.setMaxSize(DFLT_MEM_PLC_SIZE);
    defaultRegionCfg.setPersistenceEnabled(true);
    memCfg = new DataStorageConfiguration();
    memCfg.setDefaultDataRegionConfiguration(defaultRegionCfg);
    memCfg.setDataRegionConfigurations(smallRegionCfg);
    // one hour to guarantee that checkpoint will be triggered by 'dirty pages amount' trigger
    memCfg.setCheckpointFrequency(60 * 60 * 1000);
    ListeningTestLogger srv0Logger = new ListeningTestLogger(false, null);
    LogListener cacheGrpLsnr0 = matches("Cache group 'default' brings high overhead").build();
    LogListener dataRegLsnr0 = matches("metainformation in data region 'defaultRegion'").build();
    LogListener partsInfoLsnr0 = matches(numOfPartitions + " partitions, " + DFLT_PAGE_SIZE + " bytes per partition, " + partitionsMetaMemoryChunk + " MBs total").build();
    srv0Logger.registerAllListeners(cacheGrpLsnr0, dataRegLsnr0, partsInfoLsnr0);
    logger = srv0Logger;
    IgniteEx ignite0 = startGrid("srv0");
    ListeningTestLogger srv1Logger = new ListeningTestLogger(false, null);
    LogListener cacheGrpLsnr1 = matches("Cache group 'default' brings high overhead").build();
    LogListener dataRegLsnr1 = matches("metainformation in data region 'defaultRegion'").build();
    LogListener partsInfoLsnr1 = matches(numOfPartitions + " partitions, " + DFLT_PAGE_SIZE + " bytes per partition, " + partitionsMetaMemoryChunk + " MBs total").build();
    srv1Logger.registerAllListeners(cacheGrpLsnr1, dataRegLsnr1, partsInfoLsnr1);
    logger = srv1Logger;
    startGrid("srv1");
    ListeningTestLogger srv2Logger = new ListeningTestLogger(false, null);
    LogListener cacheGrpLsnr2 = matches("Cache group 'default' brings high overhead").build();
    srv2Logger.registerListener(cacheGrpLsnr2);
    logger = srv2Logger;
    startGrid("srv2");
    ignite0.cluster().active(true);
    IgniteEx cl = startGrid("client01");
    CacheConfiguration<Object, Object> manyPartitionsCache = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    manyPartitionsCache.setAffinity(new RendezvousAffinityFunction(false, numOfPartitions));
    manyPartitionsCache.setNodeFilter(new NodeNameNodeFilter(filteredSrvName));
    manyPartitionsCache.setBackups(1);
    cl.createCache(manyPartitionsCache);
    // srv0 and srv1 print warning into the log as the threshold for cache in default cache group is broken
    assertTrue(cacheGrpLsnr0.check());
    assertTrue(dataRegLsnr0.check());
    assertTrue(partsInfoLsnr0.check());
    assertTrue(cacheGrpLsnr1.check());
    assertTrue(dataRegLsnr1.check());
    assertTrue(partsInfoLsnr1.check());
    // srv2 doesn't print the warning as it is filtered by node filter from affinity nodes
    assertFalse(cacheGrpLsnr2.check());
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) 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 14 with LogListener

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

the class CacheDataRegionConfigurationTest method testNoWarningIfCacheConfigurationDoesntBreakThreshold.

/**
 * Negative test: verifies that no warning is printed to logs if user starts static and dynamic caches
 * in data region with enough capacity to host these caches;
 * in other words, no thresholds for metapages ration are broken.
 *
 * @throws Exception If failed.
 */
@Test
public void testNoWarningIfCacheConfigurationDoesntBreakThreshold() throws Exception {
    DataRegionConfiguration defaultRegionCfg = new DataRegionConfiguration();
    defaultRegionCfg.setInitialSize(DFLT_MEM_PLC_SIZE);
    defaultRegionCfg.setMaxSize(DFLT_MEM_PLC_SIZE);
    defaultRegionCfg.setPersistenceEnabled(true);
    memCfg = new DataStorageConfiguration();
    memCfg.setDefaultDataRegionConfiguration(defaultRegionCfg);
    // one hour to guarantee that checkpoint will be triggered by 'dirty pages amount' trigger
    memCfg.setCheckpointFrequency(60 * 60 * 1000);
    CacheConfiguration<Object, Object> fewPartitionsCache = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    // 512 partitions are enough only if primary and backups count
    fewPartitionsCache.setAffinity(new RendezvousAffinityFunction(false, 16));
    fewPartitionsCache.setBackups(1);
    ccfg = fewPartitionsCache;
    ListeningTestLogger srv0Logger = new ListeningTestLogger(false, null);
    LogListener cacheGrpLsnr0 = matches("Cache group 'default' brings high overhead").build();
    LogListener dynamicGrpLsnr = matches("Cache group 'dynamicCache' brings high overhead").build();
    srv0Logger.registerListener(cacheGrpLsnr0);
    srv0Logger.registerListener(dynamicGrpLsnr);
    logger = srv0Logger;
    IgniteEx ignite0 = startGrid("srv0");
    ignite0.cluster().active(true);
    assertFalse(cacheGrpLsnr0.check());
    ignite0.createCache(new CacheConfiguration<>("dynamicCache").setAffinity(new RendezvousAffinityFunction(false, 16)));
    assertFalse(dynamicGrpLsnr.check());
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) 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 15 with LogListener

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

the class CacheDataRegionConfigurationTest method testWarningIfStaticCacheOverheadExceedsThreshold.

/**
 * Verifies that warning message is printed to the logs if user tries to start a static cache in data region which
 * overhead (e.g. metapages for partitions) occupies more space of the region than a defined threshold (15%)
 *
 * @throws Exception If failed.
 */
@Test
public void testWarningIfStaticCacheOverheadExceedsThreshold() throws Exception {
    DataRegionConfiguration smallRegionCfg = new DataRegionConfiguration();
    int numOfPartitions = 512;
    int partitionsMetaMemoryChunk = U.sizeInMegabytes(512 * DFLT_PAGE_SIZE);
    smallRegionCfg.setInitialSize(DFLT_MEM_PLC_SIZE);
    smallRegionCfg.setMaxSize(DFLT_MEM_PLC_SIZE);
    smallRegionCfg.setPersistenceEnabled(true);
    smallRegionCfg.setName("smallRegion");
    memCfg = new DataStorageConfiguration();
    memCfg.setDefaultDataRegionConfiguration(smallRegionCfg);
    // one hour to guarantee that checkpoint will be triggered by 'dirty pages amount' trigger
    memCfg.setCheckpointFrequency(60 * 60 * 1000);
    CacheConfiguration<Object, Object> manyPartitionsCache = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    // 512 partitions are enough only if primary and backups count
    manyPartitionsCache.setAffinity(new RendezvousAffinityFunction(false, numOfPartitions));
    manyPartitionsCache.setBackups(1);
    ccfg = manyPartitionsCache;
    ListeningTestLogger srv0Logger = new ListeningTestLogger(false, null);
    LogListener cacheGrpLsnr0 = matches("Cache group 'default' brings high overhead").build();
    LogListener dataRegLsnr0 = matches("metainformation in data region 'smallRegion'").build();
    LogListener partsInfoLsnr0 = matches(numOfPartitions + " partitions, " + DFLT_PAGE_SIZE + " bytes per partition, " + partitionsMetaMemoryChunk + " MBs total").build();
    srv0Logger.registerAllListeners(cacheGrpLsnr0, dataRegLsnr0, partsInfoLsnr0);
    logger = srv0Logger;
    IgniteEx ignite0 = startGrid("srv0");
    ListeningTestLogger srv1Logger = new ListeningTestLogger(false, null);
    LogListener cacheGrpLsnr1 = matches("Cache group 'default' brings high overhead").build();
    LogListener dataRegLsnr1 = matches("metainformation in data region 'smallRegion'").build();
    LogListener partsInfoLsnr1 = matches(numOfPartitions + " partitions, " + DFLT_PAGE_SIZE + " bytes per partition, " + partitionsMetaMemoryChunk + " MBs total").build();
    srv1Logger.registerAllListeners(cacheGrpLsnr1, dataRegLsnr1, partsInfoLsnr1);
    logger = srv1Logger;
    startGrid("srv1");
    ignite0.cluster().active(true);
    // srv0 and srv1 print warning into the log as the threshold for cache in default cache group is broken
    assertTrue(cacheGrpLsnr0.check());
    assertTrue(dataRegLsnr0.check());
    assertTrue(partsInfoLsnr0.check());
    assertTrue(cacheGrpLsnr1.check());
    assertTrue(dataRegLsnr1.check());
    assertTrue(partsInfoLsnr1.check());
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) 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

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