IGNITE-15355 Fix method corruptDataEntry used for tests (#9347)
diff --git a/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerClusterByClassTest.java b/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerClusterByClassTest.java
index 762ac0c..f39baf5 100644
--- a/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerClusterByClassTest.java
+++ b/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerClusterByClassTest.java
@@ -61,13 +61,8 @@
import org.apache.ignite.internal.commandline.CommonArgParser;
import org.apache.ignite.internal.commandline.argument.CommandArg;
import org.apache.ignite.internal.commandline.cache.CacheSubcommands;
-import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
import org.apache.ignite.internal.processors.cache.CacheGroupContext;
-import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.GridCacheOperation;
-import org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl;
-import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -112,6 +107,7 @@
import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
+import static org.apache.ignite.util.TestStorageUtils.corruptDataEntry;
/**
* Command line handler test.
@@ -483,7 +479,7 @@
* Tests that both update counter and hash conflicts are detected.
*/
@Test
- public void testCacheIdleVerifyTwoConflictTypes() {
+ public void testCacheIdleVerifyTwoConflictTypes() throws Exception {
IgniteEx ignite = crd;
createCacheAndPreload(ignite, 100);
@@ -823,7 +819,11 @@
* @param cacheFilter cacheFilter.
* @param dump Whether idle_verify should be launched with dump option or not.
*/
- private void corruptingAndCheckDefaultCache(IgniteEx ignite, String cacheFilter, boolean dump) throws IOException {
+ private void corruptingAndCheckDefaultCache(
+ IgniteEx ignite,
+ String cacheFilter,
+ boolean dump
+ ) throws IOException, IgniteCheckedException {
injectTestSystemOut();
GridCacheContext<Object, Object> cacheCtx = ignite.cachex(DEFAULT_CACHE_NAME).context();
@@ -913,7 +913,6 @@
U.log(log, dumpWithConflicts);
- // Non-persistent caches do not have counter conflicts
assertContains(log, dumpWithConflicts, "found 4 conflict partitions: [counterConflicts=2, " +
"hashConflicts=2]");
}
@@ -1488,63 +1487,6 @@
}
/**
- * Corrupts data entry.
- *
- * @param ctx Context.
- * @param key Key.
- * @param breakCntr Break counter.
- * @param breakData Break data.
- */
- private void corruptDataEntry(
- GridCacheContext<Object, Object> ctx,
- Object key,
- boolean breakCntr,
- boolean breakData
- ) {
- int partId = ctx.affinity().partition(key);
-
- try {
- long updateCntr = ctx.topology().localPartition(partId).updateCounter();
-
- Object valToPut = ctx.cache().keepBinary().get(key);
-
- if (breakCntr)
- updateCntr++;
-
- if (breakData)
- valToPut = valToPut.toString() + " broken";
-
- // Create data entry
- DataEntry dataEntry = new DataEntry(
- ctx.cacheId(),
- new KeyCacheObjectImpl(key, null, partId),
- new CacheObjectImpl(valToPut, null),
- GridCacheOperation.UPDATE,
- new GridCacheVersion(),
- new GridCacheVersion(),
- 0L,
- partId,
- updateCntr,
- DataEntry.EMPTY_FLAGS
- );
-
- GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager)ctx.shared().database();
-
- db.checkpointReadLock();
-
- try {
- U.invoke(GridCacheDatabaseSharedManager.class, db, "applyUpdate", ctx, dataEntry);
- }
- finally {
- db.checkpointReadUnlock();
- }
- }
- catch (IgniteCheckedException e) {
- e.printStackTrace();
- }
- }
-
- /**
* Test is that when the --help control.sh command is executed, output
* will contain non-experimental commands. In case system property
* {@link IgniteSystemProperties#IGNITE_ENABLE_EXPERIMENTAL_COMMAND} =
diff --git a/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java b/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
index 22c5fcd..eb4e4ba 100644
--- a/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
+++ b/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
@@ -79,14 +79,10 @@
import org.apache.ignite.internal.commandline.CommandHandler;
import org.apache.ignite.internal.commandline.cache.argument.FindAndDeleteGarbageArg;
import org.apache.ignite.internal.managers.communication.GridIoMessage;
-import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
-import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
import org.apache.ignite.internal.processors.cache.ClusterStateTestUtils;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate;
-import org.apache.ignite.internal.processors.cache.GridCacheOperation;
-import org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest;
@@ -99,7 +95,6 @@
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
import org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpConfiguration;
import org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpStrategy;
import org.apache.ignite.internal.processors.cache.warmup.WarmUpTestPluginProvider;
@@ -172,6 +167,7 @@
import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
+import static org.apache.ignite.util.TestStorageUtils.corruptDataEntry;
/**
* Command line handler test.
@@ -2622,63 +2618,6 @@
}
}
- /**
- * Corrupts data entry.
- *
- * @param ctx Context.
- * @param key Key.
- * @param breakCntr Break counter.
- * @param breakData Break data.
- */
- private void corruptDataEntry(
- GridCacheContext<Object, Object> ctx,
- Object key,
- boolean breakCntr,
- boolean breakData
- ) {
- int partId = ctx.affinity().partition(key);
-
- try {
- long updateCntr = ctx.topology().localPartition(partId).updateCounter();
-
- Object valToPut = ctx.cache().keepBinary().get(key);
-
- if (breakCntr)
- updateCntr++;
-
- if (breakData)
- valToPut = valToPut.toString() + " broken";
-
- // Create data entry
- DataEntry dataEntry = new DataEntry(
- ctx.cacheId(),
- new KeyCacheObjectImpl(key, null, partId),
- new CacheObjectImpl(valToPut, null),
- GridCacheOperation.UPDATE,
- new GridCacheVersion(),
- new GridCacheVersion(),
- 0L,
- partId,
- updateCntr,
- DataEntry.EMPTY_FLAGS
- );
-
- GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager)ctx.shared().database();
-
- db.checkpointReadLock();
-
- try {
- U.invoke(GridCacheDatabaseSharedManager.class, db, "applyUpdate", ctx, dataEntry);
- }
- finally {
- db.checkpointReadUnlock();
- }
- }
- catch (IgniteCheckedException e) {
- e.printStackTrace();
- }
- }
-
/** */
@Test
public void testKillHangingLocalTransactions() throws Exception {
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
index 36a077e..a9ab274 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
@@ -2881,7 +2881,9 @@
* @param dataEntry Data entry to apply.
* @throws IgniteCheckedException If failed to restore.
*/
- private void applyUpdate(GridCacheContext cacheCtx, DataEntry dataEntry) throws IgniteCheckedException {
+ private void applyUpdate(GridCacheContext<?, ?> cacheCtx, DataEntry dataEntry) throws IgniteCheckedException {
+ assert cacheCtx.offheap() instanceof GridCacheOffheapManager;
+
int partId = dataEntry.partitionId();
if (partId == -1)
diff --git a/modules/core/src/test/java/org/apache/ignite/TestStorageUtils.java b/modules/core/src/test/java/org/apache/ignite/TestStorageUtils.java
deleted file mode 100644
index c9282b4..0000000
--- a/modules/core/src/test/java/org/apache/ignite/TestStorageUtils.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite;
-
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.cache.CacheEntry;
-import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
-import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.GridCacheOperation;
-import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-import org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl;
-import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager;
-import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.util.typedef.internal.U;
-
-/**
- * Test methods for storage manipulation.
- */
-public class TestStorageUtils {
- /**
- * Corrupts data entry.
- *
- * @param ctx Context.
- * @param key Key.
- * @param breakCntr Break counter.
- * @param breakData Break data.
- * @param ver GridCacheVersion to use.
- * @param brokenValPostfix Postfix to add to value if breakData flag is set to true.
- */
- public static void corruptDataEntry(
- GridCacheContext<?, ?> ctx,
- Object key,
- boolean breakCntr,
- boolean breakData,
- GridCacheVersion ver,
- String brokenValPostfix
- ) {
- int partId = ctx.affinity().partition(key);
-
- try {
- long updateCntr = ctx.topology().localPartition(partId).updateCounter();
-
- CacheEntry<Object, Object> e = ctx.cache().keepBinary().getEntry(key);
-
- Object valToPut = e.getValue();
-
- KeyCacheObject keyCacheObj = e.getKey() instanceof BinaryObject ?
- (KeyCacheObject)e.getKey() :
- new KeyCacheObjectImpl(e.getKey(), null, partId);
-
- if (breakCntr)
- updateCntr++;
-
- if (breakData)
- valToPut = e.getValue().toString() + brokenValPostfix;
-
- // Create data entry
-
- DataEntry dataEntry = new DataEntry(
- ctx.cacheId(),
- keyCacheObj,
- new CacheObjectImpl(valToPut, null),
- GridCacheOperation.UPDATE,
- new GridCacheVersion(),
- ver,
- 0L,
- partId,
- updateCntr,
- DataEntry.EMPTY_FLAGS
- );
-
- IgniteCacheDatabaseSharedManager db = ctx.shared().database();
-
- db.checkpointReadLock();
-
- try {
- U.invoke(GridCacheDatabaseSharedManager.class, db, "applyUpdate", ctx, dataEntry,
- false);
- }
- finally {
- db.checkpointReadUnlock();
- }
- }
- catch (IgniteCheckedException e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/NoUnnecessaryRebalancesTest.java b/modules/core/src/test/java/org/apache/ignite/cache/NoUnnecessaryRebalancesTest.java
deleted file mode 100644
index a972c6d..0000000
--- a/modules/core/src/test/java/org/apache/ignite/cache/NoUnnecessaryRebalancesTest.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.cluster.ClusterState;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.DataRegionConfiguration;
-import org.apache.ignite.configuration.DataStorageConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.TestRecordingCommunicationSpi;
-import org.apache.ignite.internal.managers.communication.GridIoMessage;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.lang.IgniteInClosure;
-import org.apache.ignite.plugin.extensions.communication.Message;
-import org.apache.ignite.spi.IgniteSpiException;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.junit.Assert;
-import org.junit.Test;
-
-import static org.apache.ignite.TestStorageUtils.corruptDataEntry;
-
-/**
- * Tests check that unnecessary rebalances doesn't happen
- */
-public class NoUnnecessaryRebalancesTest extends GridCommonAbstractTest {
- /** */
- private static final String CACHE_NAME = "testCache";
-
- /** */
- private static final int nodeCount = 3;
-
- /**
- * @return Grid test configuration.
- * @throws Exception If failed.
- */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- cfg.setCommunicationSpi(new SpecialSpi());
-
- cfg.setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(
- new DataRegionConfiguration().setPersistenceEnabled(true).setMaxSize(200 * 1024 * 1024)
- ));
-
- return cfg;
- }
-
- /**
- * Test check that cache creation doesn't invoke rebalance on cache in other cache group
- * @throws Exception If failed.
- */
- @Test
- public void testNoRebalancesOnCacheCreation() throws Exception {
- startGrids(nodeCount);
-
- Ignite g0 = grid(0);
-
- g0.cluster().state(ClusterState.ACTIVE);
-
- g0.createCache(getCacheConfiguration(0));
-
- awaitPartitionMapExchange();
-
- IgniteCache<Object, Object> cache0 = g0.cache(CACHE_NAME + 0);
-
- for (int i = 0; i < 100; i++)
- cache0.put(i, i);
-
- awaitPartitionMapExchange();
-
- GridCacheContext<Object, Object> cacheCtx0 = grid(0).cachex(CACHE_NAME + 0).context();
-
- corruptDataEntry(cacheCtx0, 1, true, false, new GridCacheVersion(0, 0, 0), "broken");
-
- g0.createCache(getCacheConfiguration(1));
-
- awaitPartitionMapExchange(true, true, null);
-
- Assert.assertFalse(SpecialSpi.rebGrpIds.contains(CU.cacheId(CACHE_NAME + 0)));
- }
-
- /** */
- private CacheConfiguration<Object, Object> getCacheConfiguration(int idx) {
- return new CacheConfiguration<>(CACHE_NAME + idx)
- .setBackups(2)
- .setAffinity(new RendezvousAffinityFunction().setPartitions(8));
- }
-
- /**
- * Wrapper of communication spi to detect on which cache groups rebalances were happened.
- */
- public static class SpecialSpi extends TestRecordingCommunicationSpi {
- /** Cache groups on which rebalances were happened */
- public static final Set<Integer> rebGrpIds = new HashSet<>();
-
- /** Lock object. */
- private static final Object mux = new Object();
-
- /** */
- public static Set<Integer> allRebalances() {
- synchronized (mux) {
- return Collections.unmodifiableSet(rebGrpIds);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC) throws IgniteSpiException {
- if (((GridIoMessage)msg).message() instanceof GridDhtPartitionSupplyMessage) {
- GridDhtPartitionSupplyMessage supplyMsg = (GridDhtPartitionSupplyMessage) ((GridIoMessage)msg).message();
-
- synchronized (mux) {
- rebGrpIds.add(supplyMsg.groupId());
- }
- }
-
- super.sendMessage(node, msg, ackC);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- super.beforeTest();
-
- stopAllGrids();
-
- cleanPersistenceDir();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- stopAllGrids();
-
- cleanPersistenceDir();
- }
-}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/NoUnnecessaryRebalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/NoUnnecessaryRebalanceTest.java
new file mode 100644
index 0000000..3096490
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/NoUnnecessaryRebalanceTest.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.TestRecordingCommunicationSpi;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.util.TestStorageUtils.corruptDataEntry;
+
+/**
+ * Tests check that unnecessary rebalance doesn't happen.
+ */
+public class NoUnnecessaryRebalanceTest extends GridCommonAbstractTest {
+ /** Cache configuration name prefix. */
+ private static final String CACHE_NAME = "testCache";
+
+ /** Number of cluster nodes. */
+ private static final int NODE_COUNT = 3;
+
+ /**
+ * @return Grid test configuration.
+ * @throws Exception If failed.
+ */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());
+
+ cfg.setDataStorageConfiguration(new DataStorageConfiguration()
+ .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
+ .setPersistenceEnabled(true)));
+
+ return cfg;
+ }
+
+ /**
+ * Test check that cache creation doesn't invoke rebalance on cache in other cache group.
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testNoRebalanceOnCacheCreation() throws Exception {
+ Ignite g0 = startGrids(NODE_COUNT);
+
+ g0.cluster().state(ClusterState.ACTIVE);
+ g0.createCache(getCacheConfiguration(0));
+
+ awaitPartitionMapExchange();
+
+ IgniteCache<Object, Object> cache0 = g0.cache(CACHE_NAME + 0);
+
+ for (int i = 0; i < 100; i++)
+ cache0.put(i, i);
+
+ awaitPartitionMapExchange();
+
+ GridCacheContext<Object, Object> cacheCtx0 = grid(0).cachex(CACHE_NAME + 0).context();
+
+ corruptDataEntry(cacheCtx0, 1, true, false);
+
+ G.allGrids().forEach(n -> TestRecordingCommunicationSpi.spi(n)
+ .record((node, msg) -> msg instanceof GridDhtPartitionSupplyMessage));
+
+ g0.createCache(getCacheConfiguration(1));
+
+ awaitPartitionMapExchange(true, true, null);
+
+ List<Object> msgs = new ArrayList<>();
+
+ G.allGrids().forEach(n -> msgs.addAll(TestRecordingCommunicationSpi.spi(n).recordedMessages(true)));
+
+ assertFalse(msgs.stream().map(o -> ((GridCacheGroupIdMessage)o).groupId()).collect(Collectors.toSet())
+ .contains(CU.cacheId(CACHE_NAME + 0)));
+ }
+
+ /**
+ * @param postFix Cache name postfix.
+ * @return Cache configuration.
+ */
+ private CacheConfiguration<Object, Object> getCacheConfiguration(int postFix) {
+ return new CacheConfiguration<>(CACHE_NAME + postFix).setBackups(2);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ stopAllGrids();
+
+ cleanPersistenceDir();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+
+ cleanPersistenceDir();
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite4.java
index c0972b6..1a70180 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite4.java
@@ -23,7 +23,6 @@
import org.apache.ignite.cache.AutoReleaseSegmentSelfTest;
import org.apache.ignite.cache.BreakRebalanceChainTest;
import org.apache.ignite.cache.CircledRebalanceTest;
-import org.apache.ignite.cache.NoUnnecessaryRebalancesTest;
import org.apache.ignite.cache.NotOptimizedRebalanceTest;
import org.apache.ignite.cache.RebalanceAfterResettingLostPartitionTest;
import org.apache.ignite.cache.RebalanceCancellationTest;
@@ -47,6 +46,7 @@
import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsRestartAfterFailedToWriteMetaPageTest;
import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsSpuriousRebalancingOnNodeJoinTest;
import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsTaskCancelingTest;
+import org.apache.ignite.internal.processors.cache.persistence.NoUnnecessaryRebalanceTest;
import org.apache.ignite.internal.processors.cache.persistence.PendingTreeCorruptionTest;
import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsCacheWalDisabledOnRebalancingTest;
import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsPageReplacementDuringPartitionClearTest;
@@ -124,7 +124,7 @@
GridTestUtils.addTestIfNeeded(suite, OffHeapLockStackTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, HistoricalReservationTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, CircledRebalanceTest.class, ignoredTests);
- GridTestUtils.addTestIfNeeded(suite, NoUnnecessaryRebalancesTest.class, ignoredTests);
+ GridTestUtils.addTestIfNeeded(suite, NoUnnecessaryRebalanceTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, ToStringDumpHelperTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, PageLockTrackerResourcesTest.class, ignoredTests);
diff --git a/modules/core/src/test/java/org/apache/ignite/util/TestStorageUtils.java b/modules/core/src/test/java/org/apache/ignite/util/TestStorageUtils.java
new file mode 100644
index 0000000..535b1cb
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/util/TestStorageUtils.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.util;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
+import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.GridCacheOperation;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl;
+import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+
+/**
+ * Test methods for storage manipulation.
+ */
+public class TestStorageUtils {
+ /**
+ * Corrupts data entry.
+ *
+ * @param ctx Context.
+ * @param key Key.
+ * @param breakCntr Break counter.
+ * @param breakData Break data.
+ */
+ public static void corruptDataEntry(
+ GridCacheContext<?, ?> ctx,
+ Object key,
+ boolean breakCntr,
+ boolean breakData
+ ) throws IgniteCheckedException {
+ assert !ctx.isLocal();
+
+ int partId = ctx.affinity().partition(key);
+ GridDhtLocalPartition locPart = ctx.topology().localPartition(partId);
+
+ CacheEntry<Object, Object> e = ctx.cache().keepBinary().getEntry(key);
+
+ KeyCacheObject keyCacheObj = e.getKey() instanceof BinaryObject ?
+ (KeyCacheObject)e.getKey() :
+ new KeyCacheObjectImpl(e.getKey(), null, partId);
+
+ DataEntry dataEntry = new DataEntry(ctx.cacheId(),
+ keyCacheObj,
+ new CacheObjectImpl(breakData ? e.getValue().toString() + "brokenValPostfix" : e.getValue(), null),
+ GridCacheOperation.UPDATE,
+ new GridCacheVersion(),
+ new GridCacheVersion(),
+ 0L,
+ partId,
+ breakCntr ? locPart.updateCounter() + 1 : locPart.updateCounter(),
+ DataEntry.EMPTY_FLAGS);
+
+ IgniteCacheDatabaseSharedManager db = ctx.shared().database();
+
+ db.checkpointReadLock();
+
+ try {
+ assert dataEntry.op() == GridCacheOperation.UPDATE;
+
+ ctx.offheap().update(ctx,
+ dataEntry.key(),
+ dataEntry.value(),
+ dataEntry.writeVersion(),
+ dataEntry.expireTime(),
+ locPart,
+ null);
+
+ ctx.offheap().dataStore(locPart).updateInitialCounter(dataEntry.partitionCounter() - 1, 1);
+ }
+ finally {
+ db.checkpointReadUnlock();
+ }
+ }
+}