This is an automated email from the ASF dual-hosted git repository. sboikov pushed a commit to branch ignite-11704 in repository https://gitbox.apache.org/repos/asf/ignite.git
commit 8fd5815ff20c7fc22cae3b0230b787184e1863c4 Author: sboikov <sboi...@apache.org> AuthorDate: Mon Aug 26 21:07:54 2019 +0300 Added tests --- .../org/apache/ignite/IgniteSystemProperties.java | 3 +++ .../processors/cache/CacheGroupContext.java | 10 ++++++++ .../processors/cache/GridCacheMapEntry.java | 5 ++-- .../cache/IgniteCacheOffheapManagerImpl.java | 15 +++-------- .../CacheRemoveWithTombstonesLoadTest.java | 4 +-- .../distributed/CacheRemoveWithTombstonesTest.java | 18 ++++++------- ...onedNearDisabledFullApiForceTombstonesTest.java | 30 ++++++++++++++++++++++ ...CachePartitionedFullApiForceTombstonesTest.java | 30 ++++++++++++++++++++++ .../IgniteCacheFullApiSelfTestSuite.java | 6 +++++ 9 files changed, 95 insertions(+), 26 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java index 746c7a2..084a83d 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java @@ -1071,6 +1071,9 @@ public final class IgniteSystemProperties { /** For test purposes only. Force Mvcc mode. */ public static final String IGNITE_FORCE_MVCC_MODE_IN_TESTS = "IGNITE_FORCE_MVCC_MODE_IN_TESTS"; + /** For test purposes only. Forces tombstones creation for all removes. */ + public static final String IGNITE_FORCE_TOMBSTONES_TESTS = "IGNITE_FORCE_TOMBSTONES_IN_TESTS"; + /** * Allows to log additional information about all restored partitions after binary and logical recovery phases. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java index c2cba6b..8ea23e0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java @@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReadWriteLock; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.cache.affinity.AffinityFunction; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; @@ -190,6 +191,9 @@ public class CacheGroupContext { /** Cache group metrics. */ private final CacheGroupMetricsImpl metrics; + /** */ + private final boolean forceTombstones = IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_FORCE_TOMBSTONES_TESTS, false); + /** * @param ctx Context. * @param grpId Group ID. @@ -1296,6 +1300,9 @@ public class CacheGroupContext { * @return {@code True} if need create temporary tombstones entries for removed data. */ public boolean supportsTombstone() { + if (forceTombstones) + return true; + return !mvccEnabled && !isLocal(); } @@ -1304,6 +1311,9 @@ public class CacheGroupContext { * @return {@code True} if need create tombstone for remove in given partition. */ public boolean createTombstone(@Nullable GridDhtLocalPartition part) { + if (forceTombstones && part != null) + return true; + return part != null && supportsTombstone() && part.state() == GridDhtPartitionState.MOVING; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java index e372003..ae63434 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java @@ -1712,9 +1712,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme interceptRes = cctx.config().getInterceptor().onBeforeRemove(entry0); - if (cctx.cancelRemove(interceptRes)) { + if (cctx.cancelRemove(interceptRes)) return new GridCacheUpdateTxResult(false, logPtr); - } } if (cctx.group().createTombstone(localPartition())) { @@ -5856,7 +5855,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme * @param val New value. * @param ver New version. * @param expireTime New expire time. - * @param predicate Optional predicate. + * @param p Optional predicate. */ UpdateClosure(GridCacheMapEntry entry, @Nullable CacheObject val, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java index 44f0227..e1d28c1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java @@ -1718,10 +1718,6 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager @Nullable CacheDataRow oldRow) throws IgniteCheckedException { int cacheId = grp.storeCacheIdInDataPage() ? cctx.cacheId() : CU.UNDEFINED_CACHE_ID; - // Set real stored cacheId to properly calculate row size. - if (oldRow != null) - oldRow.cacheId(cacheId); - DataRow dataRow = makeDataRow(key, val, ver, expireTime, cacheId); if (canUpdateOldRow(cctx, oldRow, dataRow) && rowStore.updateRow(oldRow.link(), dataRow, grp.statisticsHolderData())) @@ -1737,13 +1733,8 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager assert dataRow.link() != 0 : dataRow; - if (grp.sharedGroup()) { - if (dataRow.cacheId() == CU.UNDEFINED_CACHE_ID) - dataRow.cacheId(cctx.cacheId()); - - if (oldRow != null && oldRow.cacheId() == CU.UNDEFINED_CACHE_ID) - oldRow.cacheId(cctx.cacheId()); - } + if (grp.sharedGroup() && dataRow.cacheId() == CU.UNDEFINED_CACHE_ID) + dataRow.cacheId(cctx.cacheId()); return dataRow; } @@ -2750,7 +2741,7 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager * @param cctx Cache context. * @param key Key. * @param oldRow Removed row. - * @tombstoneRow Tombstone row (if tombstone was created for remove). + * @param tombstoneRow Tombstone row (if tombstone was created for remove). * @throws IgniteCheckedException If failed. */ private void finishRemove(GridCacheContext cctx, diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheRemoveWithTombstonesLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheRemoveWithTombstonesLoadTest.java index 6b0aefd..39dcd31 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheRemoveWithTombstonesLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheRemoveWithTombstonesLoadTest.java @@ -280,11 +280,11 @@ public class CacheRemoveWithTombstonesLoadTest extends GridCommonAbstractTest { GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { - return tombstones.get() == 0; + return tombstones.value() == 0; } }, 30_000); - assertEquals("Failed to wait for tombstone cleanup: " + node.name(), 0, tombstones.get()); + assertEquals("Failed to wait for tombstone cleanup: " + node.name(), 0, tombstones.value()); } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheRemoveWithTombstonesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheRemoveWithTombstonesTest.java index daab924..7646569 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheRemoveWithTombstonesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheRemoveWithTombstonesTest.java @@ -190,12 +190,12 @@ public class CacheRemoveWithTombstonesTest extends GridCommonAbstractTest { cacheMetricsRegistryName(DEFAULT_CACHE_NAME, false)).findMetric("Tombstones"); // On first node there should not be tombstones. - assertEquals(0, tombstoneMetric0.get()); + assertEquals(0, tombstoneMetric0.value()); if (expTombstone) - assertEquals(removed.size(), tombstoneMetric1.get()); + assertEquals(removed.size(), tombstoneMetric1.value()); else - assertEquals(0, tombstoneMetric1.get()); + assertEquals(0, tombstoneMetric1.value()); // Update some of removed keys, this should remove tombstones. for (int i = 0; i < KEYS; i++) { @@ -208,12 +208,12 @@ public class CacheRemoveWithTombstonesTest extends GridCommonAbstractTest { assert !removed.isEmpty(); - assertEquals(0, tombstoneMetric0.get()); + assertEquals(0, tombstoneMetric0.value()); if (expTombstone) - assertEquals(removed.size(), tombstoneMetric1.get()); + assertEquals(removed.size(), tombstoneMetric1.value()); else - assertEquals(0, tombstoneMetric1.get()); + assertEquals(0, tombstoneMetric1.value()); TestRecordingCommunicationSpi.spi(ignite0).stopBlock(); @@ -231,15 +231,15 @@ public class CacheRemoveWithTombstonesTest extends GridCommonAbstractTest { // Tombstones should be removed after once rebalance is completed. GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { - return tombstoneMetric1.get() == 0; + return tombstoneMetric1.value() == 0; } }, 30_000); - assertEquals(0, tombstoneMetric1.get()); + assertEquals(0, tombstoneMetric1.value()); } /** - * + * @param node Node. */ private void blockRebalance(Ignite node) { final int grpId = groupIdForCache(ignite(0), DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledFullApiForceTombstonesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledFullApiForceTombstonesTest.java new file mode 100644 index 0000000..65c3a7c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledFullApiForceTombstonesTest.java @@ -0,0 +1,30 @@ +/* + * 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.distributed.dht; + +import org.apache.ignite.testframework.junits.WithSystemProperty; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_FORCE_TOMBSTONES_TESTS; + +/** + * + */ +@WithSystemProperty(key = IGNITE_FORCE_TOMBSTONES_TESTS, value = "true") +public class GridCachePartitionedNearDisabledFullApiForceTombstonesTest extends GridCachePartitionedNearDisabledFullApiSelfTest { + // No-op. +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFullApiForceTombstonesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFullApiForceTombstonesTest.java new file mode 100644 index 0000000..9cc558c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFullApiForceTombstonesTest.java @@ -0,0 +1,30 @@ +/* + * 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.distributed.near; + +import org.apache.ignite.testframework.junits.WithSystemProperty; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_FORCE_TOMBSTONES_TESTS; + +/** + * + */ +@WithSystemProperty(key = IGNITE_FORCE_TOMBSTONES_TESTS, value = "true") +public class GridCachePartitionedFullApiForceTombstonesTest extends GridCachePartitionedFullApiSelfTest { + // No-op. +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java index 30d8d63..01c1f59 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java @@ -24,6 +24,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheAtom import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedReloadAllSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledAtomicOnheapFullApiSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledAtomicOnheapMultiNodeFullApiSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledFullApiForceTombstonesTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledFullApiSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledMultiNodeFullApiSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledMultiNodeP2PDisabledFullApiSelfTest; @@ -56,6 +57,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePar import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedFilteredPutSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedFullApiMultithreadedSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedFullApiSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedFullApiForceTombstonesTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMultiNodeCounterSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMultiNodeFullApiSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMultiNodeP2PDisabledFullApiSelfTest; @@ -149,6 +151,10 @@ import org.junit.runners.Suite; GridCachePartitionedNearDisabledAtomicOnheapMultiNodeFullApiSelfTest.class, GridCacheAtomicOnheapMultiNodeFullApiSelfTest.class, + // With forced tombstones. + GridCachePartitionedFullApiForceTombstonesTest.class, + GridCachePartitionedNearDisabledFullApiForceTombstonesTest.class, + // Multithreaded. GridCacheLocalFullApiMultithreadedSelfTest.class, GridCacheReplicatedFullApiMultithreadedSelfTest.class,