You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2020/02/14 16:23:13 UTC
[ignite] branch master updated: IGNITE-12681 Fix flaky
IgniteShutdownOnSupplyMessageFailureTest - Fixes #7427.
This is an automated email from the ASF dual-hosted git repository.
agoncharuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 0f6be58 IGNITE-12681 Fix flaky IgniteShutdownOnSupplyMessageFailureTest - Fixes #7427.
0f6be58 is described below
commit 0f6be5819cf4ba22e34da319836e5a1a8d0806fd
Author: Alexey Goncharuk <al...@gmail.com>
AuthorDate: Fri Feb 14 19:22:27 2020 +0300
IGNITE-12681 Fix flaky IgniteShutdownOnSupplyMessageFailureTest - Fixes #7427.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
---
.../IgniteShutdownOnSupplyMessageFailureTest.java | 52 ++++++++++------------
1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteShutdownOnSupplyMessageFailureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteShutdownOnSupplyMessageFailureTest.java
index c7e3e22..2bc7fc7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteShutdownOnSupplyMessageFailureTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteShutdownOnSupplyMessageFailureTest.java
@@ -20,22 +20,22 @@ import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.OpenOption;
-import java.util.HashMap;
-import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+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.configuration.WALMode;
-import org.apache.ignite.events.Event;
+import org.apache.ignite.failure.FailureContext;
import org.apache.ignite.failure.StopNodeFailureHandler;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager;
@@ -43,12 +43,11 @@ import org.apache.ignite.internal.processors.cache.persistence.file.FileIO;
import org.apache.ignite.internal.processors.cache.persistence.file.FileIODecorator;
import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory;
import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory;
-import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
-import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
-
/** */
public class IgniteShutdownOnSupplyMessageFailureTest extends GridCommonAbstractTest {
/** Rebalance cache name. */
@@ -60,9 +59,6 @@ public class IgniteShutdownOnSupplyMessageFailureTest extends GridCommonAbstract
/** Node name with test file factory. */
private static final int NODE_NAME_WITH_TEST_FILE_FACTORY = 0;
- /** Node name listen to a left event. */
- private static final int NODE_NAME_LISTEN_TO_LEFT_EVENT = 1;
-
/** Wait on supply message failure. */
private static final CountDownLatch WAIT_ON_SUPPLY_MESSAGE_FAILURE = new CountDownLatch(1);
@@ -85,16 +81,16 @@ public class IgniteShutdownOnSupplyMessageFailureTest extends GridCommonAbstract
.setWalMode(WALMode.FSYNC)
.setCheckpointFrequency(500);
- if (name.equals(getTestIgniteInstanceName(NODE_NAME_WITH_TEST_FILE_FACTORY)))
+ if (name.equals(getTestIgniteInstanceName(NODE_NAME_WITH_TEST_FILE_FACTORY))) {
conf.setFileIOFactory(new FailingFileIOFactory(canFailFirstNode));
- if (name.equals(getTestIgniteInstanceName(NODE_NAME_LISTEN_TO_LEFT_EVENT)))
- registerLeftEvent(cfg);
+ cfg.setFailureHandler(new TestFailureHandler());
+ }
+ else
+ cfg.setFailureHandler(new StopNodeFailureHandler());
cfg.setDataStorageConfiguration(conf);
- cfg.setFailureHandler(new StopNodeFailureHandler());
-
return cfg;
}
@@ -126,7 +122,7 @@ public class IgniteShutdownOnSupplyMessageFailureTest extends GridCommonAbstract
IgniteEx ig = startGrid(0);
IgniteEx awayNode = startGrid(1);
- ig.cluster().active(true);
+ ig.cluster().state(ClusterState.ACTIVE);
createCache(ig, TEST_REBALANCE_CACHE);
@@ -142,7 +138,9 @@ public class IgniteShutdownOnSupplyMessageFailureTest extends GridCommonAbstract
WAIT_ON_SUPPLY_MESSAGE_FAILURE.await();
- assertEquals(1, grid(1).context().discovery().aliveServerNodes().size());
+ assertTrue(GridTestUtils.waitForCondition(() -> grid(1).context().discovery().aliveServerNodes().size() == 1,
+ getTestTimeout()));
+
assertFalse(awayNode.context().discovery().alive(ig.context().localNodeId())); // Only second node is alive
}
@@ -177,22 +175,18 @@ public class IgniteShutdownOnSupplyMessageFailureTest extends GridCommonAbstract
}
/**
- * @param cfg Config.
+ * Test failure handler.
*/
- private void registerLeftEvent(IgniteConfiguration cfg) {
- int[] evts = {EVT_NODE_LEFT};
-
- cfg.setIncludeEventTypes(evts);
-
- Map<IgnitePredicate<? extends Event>, int[]> lsnrs = new HashMap<>();
-
- lsnrs.put((IgnitePredicate<Event>)event -> {
- WAIT_ON_SUPPLY_MESSAGE_FAILURE.countDown();
+ private static class TestFailureHandler extends StopNodeFailureHandler {
+ /** {@inheritDoc} */
+ @Override public boolean handle(Ignite ignite, FailureContext failureCtx) {
+ Throwable err = X.cause(failureCtx.error(), IOException.class);
- return true;
- }, evts);
+ if (err != null && err.getMessage() != null && err.getMessage().contains("Test crash"))
+ WAIT_ON_SUPPLY_MESSAGE_FAILURE.countDown();
- cfg.setLocalEventListeners(lsnrs);
+ return super.handle(ignite, failureCtx);
+ }
}
/**