Search in sources :

Example 36 with WithSystemProperty

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

the class MetaStorageCompatibilityTest method testMigrationWithExceptionDuringTheProcess.

/**
 */
@Test
@WithSystemProperty(key = IGNITE_DISABLE_WAL_DURING_REBALANCING, value = "false")
public void testMigrationWithExceptionDuringTheProcess() throws Exception {
    try {
        U.delete(new File(U.defaultWorkDirectory()));
        startGrid(1, IGNITE_VERSION, new ConfigurationClosure(CONSISTENT_ID_1), new ActivateAndStopClosure());
        stopAllGrids();
        try (Ignite ig0 = IgnitionEx.start(prepareConfig(getConfiguration(), CONSISTENT_ID_1, PART_FILE))) {
            // trigger checkpoint on close()
            ig0.getOrCreateCache("default-cache").put(1, 1);
        }
        assertTrue(metastorageFileExists(INDEX_BIN_FILE));
        assertTrue(metastorageFileExists(PART_FILE));
        try (Ignite ig0 = IgnitionEx.start(prepareConfig(getConfiguration(), CONSISTENT_ID_1, INDEX_BIN_FILE))) {
            // trigger checkpoint on close()
            ig0.getOrCreateCache("default-cache").put(1, 1);
        }
        assertTrue(metastorageFileExists(INDEX_BIN_FILE));
        assertFalse(metastorageFileExists(PART_FILE));
        try (Ignite ig0 = IgnitionEx.start(prepareConfig(getConfiguration(), CONSISTENT_ID_1))) {
            try (Ignite ig1 = IgnitionEx.start(prepareConfig(getConfiguration(), CONSISTENT_ID_2))) {
                ig0.cluster().setBaselineTopology(ig1.cluster().topologyVersion());
            }
        }
        try (Ignite ig0 = IgnitionEx.start(prepareConfig(getConfiguration(), CONSISTENT_ID_1))) {
            try (Ignite ig1 = IgnitionEx.start(prepareConfig(getConfiguration(), CONSISTENT_ID_2))) {
                assertTrue(GridTestUtils.waitForCondition(() -> ig1.cluster().state() == ACTIVE, 10_000));
            }
        }
    } finally {
        stopAllGrids();
    }
}
Also used : Ignite(org.apache.ignite.Ignite) File(java.io.File) GridCacheAbstractFullApiSelfTest(org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 37 with WithSystemProperty

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

the class GridCommandHandlerTest method testDeactivateWithCheckClusterNameInConfirmationBySystemProperty.

/**
 * Test the deactivation command on the active and no cluster with checking
 * the cluster name(which is set through the system property) in
 * confirmation.
 *
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_CLUSTER_NAME, value = "TEST_CLUSTER_NAME")
public void testDeactivateWithCheckClusterNameInConfirmationBySystemProperty() throws Exception {
    IgniteEx igniteEx = startGrid(0);
    assertFalse(igniteEx.cluster().active());
    deactivateActiveOrNotClusterWithCheckClusterNameInConfirmation(igniteEx, "TEST_CLUSTER_NAME");
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCacheGroupsWithRestartsTest(org.apache.ignite.internal.processors.cache.persistence.db.IgniteCacheGroupsWithRestartsTest) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 38 with WithSystemProperty

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

the class BinaryConfigurationConsistencySelfTest method testSkipCheckConsistencyFlagEnabled.

/**
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, value = "true")
public void testSkipCheckConsistencyFlagEnabled() throws Exception {
    // Wrong usage of Ignite (done only in test purposes).
    binaryCfg = null;
    startGrid(0);
    binaryCfg = new BinaryConfiguration();
    startGrid(1);
    binaryCfg = customConfig(true);
    startClientGrid(2);
}
Also used : BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 39 with WithSystemProperty

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

the class CheckpointReadLockFailureTest method testWriteLockedByCurrentThread.

/**
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_PDS_LOG_CP_READ_LOCK_HOLDERS, value = "true")
public void testWriteLockedByCurrentThread() {
    ReentrantReadWriteLockWithTracking wrapped = new ReentrantReadWriteLockWithTracking(log, 1_000);
    wrapped.writeLock().lock();
    try {
        assertTrue(wrapped.isWriteLockedByCurrentThread());
    } finally {
        wrapped.writeLock().unlock();
    }
}
Also used : ReentrantReadWriteLockWithTracking(org.apache.ignite.internal.util.ReentrantReadWriteLockWithTracking) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 40 with WithSystemProperty

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

the class CommonPoolStarvationCheckpointTest method testCommonPoolStarvation.

/**
 * @throws Exception if failed.
 */
@Test
@WithSystemProperty(key = IgniteSystemProperties.CHECKPOINT_PARALLEL_SORT_THRESHOLD, value = "0")
public void testCommonPoolStarvation() throws Exception {
    IgniteEx grid = startGrid(0);
    grid.cluster().active(true);
    IgniteCache<Integer, OnePageValue> cache = grid.cache(CACHE_NAME);
    forceCheckpoint();
    for (int i = 0; i < ENTRIES_COUNT; i++) cache.put(i, new OnePageValue());
    CountDownLatch latch = new CountDownLatch(1);
    ForkJoinPool commonPool = ForkJoinPool.commonPool();
    for (int i = 0; i < Runtime.getRuntime().availableProcessors() * 10; i++) {
        commonPool.submit(() -> {
            try {
                latch.await();
            } catch (InterruptedException e) {
                throw new IgniteInterruptedException(e);
            }
        });
    }
    forceCheckpoint();
    latch.countDown();
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) ForkJoinPool(java.util.concurrent.ForkJoinPool) 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