Search in sources :

Example 41 with WithSystemProperty

use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.

the class IgniteCacheDatabaseSharedManagerSelfTest method testCheckMinWalArchiveSize.

/**
 * Checking the correctness of validation {@link DataStorageConfiguration#getMinWalArchiveSize()}.
 *
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE, value = "-1")
public void testCheckMinWalArchiveSize() throws Exception {
    DataStorageConfiguration cfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)).setMaxWalArchiveSize(UNLIMITED_WAL_ARCHIVE);
    for (long i : F.asList(10L, 100L, HALF_MAX_WAL_ARCHIVE_SIZE)) checkWalArchiveSizeConfiguration(cfg.setMinWalArchiveSize(i), log);
    int max = DFLT_WAL_SEGMENT_SIZE;
    cfg.setMaxWalArchiveSize(max);
    for (long i : F.asList(1L, 10L, HALF_MAX_WAL_ARCHIVE_SIZE, (long) max)) checkWalArchiveSizeConfiguration(cfg.setMinWalArchiveSize(i), log);
    for (long i : F.asList(max * 2, max * 3)) {
        assertThrows(log, () -> {
            checkWalArchiveSizeConfiguration(cfg.setMinWalArchiveSize(i), log);
            return null;
        }, IgniteCheckedException.class, null);
    }
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 42 with WithSystemProperty

use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.

the class PerformanceStatisticsPropertiesTest method testFileMaxSize.

/**
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_PERF_STAT_FILE_MAX_SIZE, value = "" + TEST_FILE_MAX_SIZE)
public void testFileMaxSize() throws Exception {
    long initLen = srv.context().cache().cacheDescriptors().values().stream().mapToInt(desc -> 1 + cacheStartRecordSize(desc.cacheName().getBytes().length, false)).sum();
    long expOpsCnt = (TEST_FILE_MAX_SIZE - initLen) / (/*typeOp*/
    1 + OperationType.cacheRecordSize());
    startCollectStatistics();
    for (int i = 0; i < expOpsCnt * 2; i++) srv.cache(DEFAULT_CACHE_NAME).get(i);
    AtomicInteger opsCnt = new AtomicInteger();
    stopCollectStatisticsAndRead(new TestHandler() {

        @Override
        public void cacheOperation(UUID nodeId, OperationType type, int cacheId, long startTime, long duration) {
            opsCnt.incrementAndGet();
        }
    });
    assertEquals(expOpsCnt, opsCnt.get());
    long expLen = initLen + opsCnt.get() * (/*typeOp*/
    1 + OperationType.cacheRecordSize());
    List<File> files = statisticsFiles();
    assertEquals(1, files.size());
    long statFileLen = files.get(0).length();
    assertEquals(expLen, statFileLen);
    assertTrue(statFileLen <= TEST_FILE_MAX_SIZE);
}
Also used : OperationType.taskRecordSize(org.apache.ignite.internal.processors.performancestatistics.OperationType.taskRecordSize) IGNITE_PERF_STAT_FILE_MAX_SIZE(org.apache.ignite.IgniteSystemProperties.IGNITE_PERF_STAT_FILE_MAX_SIZE) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) UUID(java.util.UUID) File(java.io.File) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IGNITE_PERF_STAT_CACHED_STRINGS_THRESHOLD(org.apache.ignite.IgniteSystemProperties.IGNITE_PERF_STAT_CACHED_STRINGS_THRESHOLD) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) OperationType.jobRecordSize(org.apache.ignite.internal.processors.performancestatistics.OperationType.jobRecordSize) OperationType.cacheStartRecordSize(org.apache.ignite.internal.processors.performancestatistics.OperationType.cacheStartRecordSize) IGNITE_PERF_STAT_FLUSH_SIZE(org.apache.ignite.IgniteSystemProperties.IGNITE_PERF_STAT_FLUSH_SIZE) IgniteUuid(org.apache.ignite.lang.IgniteUuid) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) UUID(java.util.UUID) File(java.io.File) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 43 with WithSystemProperty

use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.

the class PendingExchangeTest method testWithShortAfinityHistory.

/**
 * Thats starts several caches in order to affinity history is exhausted.
 *
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_AFFINITY_HISTORY_SIZE, value = "2")
public void testWithShortAfinityHistory() throws Exception {
    createClusterWithPendingExchnageDuringRebalance((ignite, exchangeManager) -> {
        GridCompoundFuture compFut = new GridCompoundFuture();
        for (int i = 0; i < 20; i++) {
            int finalNum = i;
            compFut.add(GridTestUtils.runAsync(() -> ignite.createCache(DEFAULT_CACHE_NAME + "_new" + finalNum)));
        }
        compFut.markInitialized();
        waitForExchnagesBegin(exchangeManager, 20);
        return compFut;
    });
}
Also used : GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 44 with WithSystemProperty

use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.

the class TransactionsMXBeanImplTest method testChangeLongOperationsDumpTimeoutOnImmutableCluster.

/**
 * Test to verify the correct change of {@link TransactionsMXBean#getLongOperationsDumpTimeout()}
 * in an immutable cluster.
 *
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, value = "100")
public void testChangeLongOperationsDumpTimeoutOnImmutableCluster() throws Exception {
    Map<IgniteEx, TransactionsMXBean> allNodes = startGridAndActivate(2);
    Map<IgniteEx, TransactionsMXBean> clientNodes = new HashMap<>();
    Map<IgniteEx, TransactionsMXBean> srvNodes = new HashMap<>(allNodes);
    clientNode = true;
    for (int i = 2; i < 4; i++) {
        IgniteEx igniteEx = startGrid(i);
        TransactionsMXBean transactionsMXBean = txMXBean(i);
        allNodes.put(igniteEx, transactionsMXBean);
        clientNodes.put(igniteEx, transactionsMXBean);
    }
    // check for default value
    checkPropertyValueViaTxMxBean(allNodes, 100L, TransactionsMXBean::getLongOperationsDumpTimeout);
    // create property update latches for client nodes
    Map<IgniteEx, List<CountDownLatch>> updateLatches = new HashMap<>();
    clientNodes.keySet().forEach(ignite -> updateLatches.put(ignite, F.asList(new CountDownLatch(1), new CountDownLatch(1))));
    clientNodes.forEach((igniteEx, bean) -> igniteEx.context().distributedMetastorage().listen((key) -> key.startsWith(DIST_CONF_PREFIX), (String key, Serializable oldVal, Serializable newVal) -> {
        if ((long) newVal == 200)
            updateLatches.get(igniteEx).get(0).countDown();
        if ((long) newVal == 300)
            updateLatches.get(igniteEx).get(1).countDown();
    }));
    long newTimeout = 200L;
    // update value via server node
    updatePropertyViaTxMxBean(allNodes, TransactionsMXBean::setLongOperationsDumpTimeout, newTimeout);
    // check new value in server nodes
    checkPropertyValueViaTxMxBean(srvNodes, newTimeout, TransactionsMXBean::getLongOperationsDumpTimeout);
    // check new value in client nodes
    for (List<CountDownLatch> list : updateLatches.values()) {
        CountDownLatch countDownLatch = list.get(0);
        countDownLatch.await(100, TimeUnit.MILLISECONDS);
    }
    newTimeout = 300L;
    // update value via server node
    updatePropertyViaTxMxBean(clientNodes, TransactionsMXBean::setLongOperationsDumpTimeout, newTimeout);
    // check new value in server nodes
    checkPropertyValueViaTxMxBean(srvNodes, newTimeout, TransactionsMXBean::getLongOperationsDumpTimeout);
    // check new value on client nodes
    for (List<CountDownLatch> list : updateLatches.values()) {
        CountDownLatch countDownLatch = list.get(1);
        countDownLatch.await(100, TimeUnit.MILLISECONDS);
    }
}
Also used : ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) Transaction(org.apache.ignite.transactions.Transaction) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) HashMap(java.util.HashMap) CacheRebalanceMode(org.apache.ignite.cache.CacheRebalanceMode) Function(java.util.function.Function) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) IGNITE_LONG_TRANSACTION_TIME_DUMP_THRESHOLD(org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_TRANSACTION_TIME_DUMP_THRESHOLD) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) LogListener.matches(org.apache.ignite.testframework.LogListener.matches) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) Collections.singletonMap(java.util.Collections.singletonMap) IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_COEFFICIENT(org.apache.ignite.IgniteSystemProperties.IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_COEFFICIENT) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) F(org.apache.ignite.internal.util.typedef.F) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMIT(org.apache.ignite.IgniteSystemProperties.IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMIT) IGNITE_TX_OWNER_DUMP_REQUESTS_ALLOWED(org.apache.ignite.IgniteSystemProperties.IGNITE_TX_OWNER_DUMP_REQUESTS_ALLOWED) IGNITE_DUMP_TX_COLLISIONS_INTERVAL(org.apache.ignite.IgniteSystemProperties.IGNITE_DUMP_TX_COLLISIONS_INTERVAL) Test(org.junit.Test) TransactionProxyImpl(org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) TransactionsMXBean(org.apache.ignite.mxbean.TransactionsMXBean) TRANSACTIONAL(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL) Serializable(java.io.Serializable) TimeUnit(java.util.concurrent.TimeUnit) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT(org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) Serializable(java.io.Serializable) HashMap(java.util.HashMap) CountDownLatch(java.util.concurrent.CountDownLatch) TransactionsMXBean(org.apache.ignite.mxbean.TransactionsMXBean) List(java.util.List) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 45 with WithSystemProperty

use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.

the class CacheMetricsManageTest method testTxContentionMetric.

/**
 * Test correct metric for tx key contention.
 */
@Test
@WithSystemProperty(key = IGNITE_DUMP_TX_COLLISIONS_INTERVAL, value = "30000")
public void testTxContentionMetric() throws Exception {
    Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-9224", MvccFeatureChecker.forcedMvcc());
    backups = 1;
    useTestCommSpi = true;
    Ignite ig = startGridsMultiThreaded(2);
    int contCnt = (int) U.staticField(IgniteTxManager.class, "COLLISIONS_QUEUE_THRESHOLD") * 20;
    CountDownLatch txLatch = new CountDownLatch(contCnt * 2);
    CountDownLatch txLatch0 = new CountDownLatch(contCnt * 2);
    ig.cluster().active(true);
    client = true;
    Ignite cl = startGrid();
    CacheConfiguration<?, ?> dfltCacheCfg = getCacheConfiguration();
    dfltCacheCfg.setStatisticsEnabled(true);
    String cacheName = dfltCacheCfg.getName();
    IgniteCache<Integer, Integer> cache = ig.cache(cacheName);
    IgniteCache<Integer, Integer> cache0 = cl.cache(cacheName);
    CacheMetricsMXBean mxBeanCache = mxBean(0, cacheName, CacheLocalMetricsMXBeanImpl.class);
    final List<Integer> priKeys = primaryKeys(cache, 3, 1);
    final Integer backKey = backupKey(cache);
    IgniteTransactions txMgr = cl.transactions();
    CountDownLatch blockOnce = new CountDownLatch(1);
    for (Ignite ig0 : G.allGrids()) {
        TestRecordingCommunicationSpi commSpi0 = (TestRecordingCommunicationSpi) ig0.configuration().getCommunicationSpi();
        commSpi0.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {

            @Override
            public boolean apply(ClusterNode node, Message msg) {
                if (msg instanceof GridNearTxPrepareResponse && blockOnce.getCount() > 0) {
                    blockOnce.countDown();
                    return true;
                }
                return false;
            }
        });
    }
    IgniteInternalFuture f = GridTestUtils.runAsync(() -> {
        try (Transaction tx = txMgr.txStart(PESSIMISTIC, READ_COMMITTED)) {
            cache0.put(priKeys.get(0), 0);
            cache0.put(priKeys.get(2), 0);
            tx.commit();
        }
    });
    blockOnce.await();
    GridCompoundFuture<?, ?> finishFut = new GridCompoundFuture<>();
    for (int i = 0; i < contCnt; ++i) {
        IgniteInternalFuture f0 = GridTestUtils.runAsync(() -> {
            try (Transaction tx = txMgr.txStart(PESSIMISTIC, READ_COMMITTED)) {
                cache0.put(priKeys.get(0), 0);
                cache0.put(priKeys.get(1), 0);
                txLatch0.countDown();
                tx.commit();
                txLatch.countDown();
            }
            try (Transaction tx = txMgr.txStart(PESSIMISTIC, READ_COMMITTED)) {
                cache0.put(priKeys.get(2), 0);
                cache0.put(backKey, 0);
                txLatch0.countDown();
                tx.commit();
                txLatch.countDown();
            }
        });
        finishFut.add(f0);
    }
    finishFut.markInitialized();
    txLatch0.await();
    for (Ignite ig0 : G.allGrids()) {
        TestRecordingCommunicationSpi commSpi0 = (TestRecordingCommunicationSpi) ig0.configuration().getCommunicationSpi();
        commSpi0.stopBlock();
    }
    IgniteTxManager txManager = ((IgniteEx) ig).context().cache().context().tm();
    assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {

        @Override
        public boolean apply() {
            try {
                U.invoke(IgniteTxManager.class, txManager, "collectTxCollisionsInfo");
            } catch (IgniteCheckedException e) {
                fail(e.toString());
            }
            String coll = mxBeanCache.getTxKeyCollisions();
            if (coll.contains("val=" + priKeys.get(2)) || coll.contains("val=" + priKeys.get(0)))
                ;
            return true;
        }
    }, 10_000));
    f.get();
    finishFut.get();
    txLatch.await();
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) Message(org.apache.ignite.plugin.extensions.communication.Message) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) CacheMetricsMXBean(org.apache.ignite.mxbean.CacheMetricsMXBean) IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteTransactions(org.apache.ignite.IgniteTransactions) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Transaction(org.apache.ignite.transactions.Transaction) GridNearTxPrepareResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse) Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Aggregations

WithSystemProperty (org.apache.ignite.testframework.junits.WithSystemProperty)71 Test (org.junit.Test)71 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)59 IgniteEx (org.apache.ignite.internal.IgniteEx)46 Ignite (org.apache.ignite.Ignite)20 LogListener (org.apache.ignite.testframework.LogListener)16 CountDownLatch (java.util.concurrent.CountDownLatch)15 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)12 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)11 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)10 File (java.io.File)9 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)9 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)8 ListeningTestLogger (org.apache.ignite.testframework.ListeningTestLogger)8 List (java.util.List)7 IgniteCache (org.apache.ignite.IgniteCache)7 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)7 ClusterNode (org.apache.ignite.cluster.ClusterNode)7 TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)7