You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/06/01 11:27:59 UTC
[13/17] ignite git commit: IGNITE-2708: fix tests that don't create
unique IndexingSPI per node
IGNITE-2708: fix tests that don't create unique IndexingSPI per node
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f90e424d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f90e424d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f90e424d
Branch: refs/heads/ignite-3038
Commit: f90e424de6d482eafa64cd24ffb9edfd7911856d
Parents: 14403bb
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue May 31 13:50:06 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue May 31 13:50:06 2016 +0300
----------------------------------------------------------------------
.../IgniteTxExceptionAbstractSelfTest.java | 43 ++++++++++++--------
1 file changed, 27 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f90e424d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
index 4826c68..c867d52 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java
@@ -28,6 +28,7 @@ import javax.cache.processor.EntryProcessor;
import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -54,9 +55,6 @@ import static org.apache.ignite.cache.CacheMode.REPLICATED;
* Tests that transaction is invalidated in case of {@link IgniteTxHeuristicCheckedException}.
*/
public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstractSelfTest {
- /** Index SPI throwing exception. */
- private static TestIndexingSpi idxSpi = new TestIndexingSpi();
-
/** */
private static final int PRIMARY = 0;
@@ -78,7 +76,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- cfg.setIndexingSpi(idxSpi);
+ cfg.setIndexingSpi(new TestIndexingSpi());
cfg.getTransactionConfiguration().setTxSerializableEnabled(true);
@@ -108,7 +106,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
- idxSpi.forceFail(false);
+ failIndexingSpi(false);
Transaction tx = jcache().unwrap(Ignite.class).transactions().tx();
@@ -321,7 +319,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
IgniteCache<Integer, Integer> cache = grid(0).cache(null);
if (putBefore) {
- idxSpi.forceFail(false);
+ failIndexingSpi(false);
info("Start transaction.");
@@ -344,7 +342,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
grid(i).cache(null).get(key);
}
- idxSpi.forceFail(true);
+ failIndexingSpi(true);
try {
info("Start transaction.");
@@ -380,7 +378,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
*/
@SuppressWarnings("unchecked")
private void checkUnlocked(final Integer key) throws Exception {
- idxSpi.forceFail(false);
+ failIndexingSpi(false);
awaitPartitionMapExchange();
@@ -448,7 +446,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
*/
private void checkPut(boolean putBefore, final Integer key) throws Exception {
if (putBefore) {
- idxSpi.forceFail(false);
+ failIndexingSpi(false);
info("Put key: " + key);
@@ -459,7 +457,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
for (int i = 0; i < gridCount(); i++)
grid(i).cache(null).get(key);
- idxSpi.forceFail(true);
+ failIndexingSpi(true);
info("Going to put: " + key);
@@ -481,7 +479,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
*/
private void checkTransform(boolean putBefore, final Integer key) throws Exception {
if (putBefore) {
- idxSpi.forceFail(false);
+ failIndexingSpi(false);
info("Put key: " + key);
@@ -492,7 +490,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
for (int i = 0; i < gridCount(); i++)
grid(i).cache(null).get(key);
- idxSpi.forceFail(true);
+ failIndexingSpi(true);
info("Going to transform: " + key);
@@ -524,7 +522,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
assert keys.length > 1;
if (putBefore) {
- idxSpi.forceFail(false);
+ failIndexingSpi(false);
Map<Integer, Integer> m = new HashMap<>();
@@ -542,7 +540,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
grid(i).cache(null).get(key);
}
- idxSpi.forceFail(true);
+ failIndexingSpi(true);
final Map<Integer, Integer> m = new HashMap<>();
@@ -570,7 +568,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
*/
private void checkRemove(boolean putBefore, final Integer key) throws Exception {
if (putBefore) {
- idxSpi.forceFail(false);
+ failIndexingSpi(false);
info("Put key: " + key);
@@ -581,7 +579,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
for (int i = 0; i < gridCount(); i++)
grid(i).cache(null).get(key);
- idxSpi.forceFail(true);
+ failIndexingSpi(true);
info("Going to remove: " + key);
@@ -653,6 +651,19 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
}
/**
+ * Controls indexing SPI behavior.
+ *
+ * @param fail fail the SPI or not.
+ */
+ private void failIndexingSpi(boolean fail) {
+ for (Ignite ignite : Ignition.allGrids()) {
+ TestIndexingSpi idxSpi = (TestIndexingSpi)ignite.configuration().getIndexingSpi();
+
+ idxSpi.forceFail(fail);
+ }
+ }
+
+ /**
* Indexing SPI that can fail on demand.
*/
private static class TestIndexingSpi extends IgniteSpiAdapter implements IndexingSpi {