IGNITE-7677 Fixing failing tests
authorAlexey Goncharuk <alexey.goncharuk@gmail.com>
Mon, 12 Feb 2018 15:58:00 +0000 (18:58 +0300)
committerAlexey Goncharuk <alexey.goncharuk@gmail.com>
Mon, 12 Feb 2018 15:58:00 +0000 (18:58 +0300)
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBaselineTopologyTest.java
modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java

index 6ccb450..e1ffc61 100644 (file)
@@ -47,6 +47,7 @@ import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.TestDelayingCommunicationSpi;
 import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage;
@@ -54,6 +55,8 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.Gri
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
@@ -75,7 +78,10 @@ public class CacheBaselineTopologyTest extends GridCommonAbstractTest {
     private static final int NODE_COUNT = 4;
 
     /** */
-    private static boolean delayRebalance = false;
+    private boolean delayRebalance;
+
+    /** */
+    private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
 
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
@@ -99,6 +105,11 @@ public class CacheBaselineTopologyTest extends GridCommonAbstractTest {
     @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
 
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+        discoSpi.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(discoSpi);
+
         cfg.setConsistentId(igniteInstanceName);
 
         cfg.setDataStorageConfiguration(
@@ -350,6 +361,9 @@ public class CacheBaselineTopologyTest extends GridCommonAbstractTest {
                 .setPartitionLossPolicy(READ_ONLY_SAFE)
         );
 
+        for (int i = 0; i < NODE_COUNT; i++)
+            grid(i).cache(CACHE_NAME).rebalance().get();
+
         int key = -1;
 
         for (int k = 0; k < 100_000; k++) {
@@ -471,6 +485,8 @@ public class CacheBaselineTopologyTest extends GridCommonAbstractTest {
         IgniteEx backup = null;
 
         for (int i = 0; i < NODE_COUNT; i++) {
+            grid(i).cache(CACHE_NAME).rebalance().get();
+
             if (grid(i).localNode().equals(affNodes.get(0))) {
                 primaryIdx = i;
                 primary = grid(i);
@@ -498,6 +514,8 @@ public class CacheBaselineTopologyTest extends GridCommonAbstractTest {
 
         primary.close();
 
+        backup.context().cache().context().exchange().affinityReadyFuture(new AffinityTopologyVersion(5, 0)).get();
+
         assertEquals(backup.localNode(), ig.affinity(CACHE_NAME).mapKeyToNode(key));
 
         cache.put(key, val2);
@@ -553,6 +571,8 @@ public class CacheBaselineTopologyTest extends GridCommonAbstractTest {
         IgniteEx backup = null;
 
         for (int i = 0; i < NODE_COUNT; i++) {
+            grid(i).cache(CACHE_NAME).rebalance().get();
+
             if (grid(i).localNode().equals(affNodes.get(0))) {
                 primaryIdx = i;
                 primary = grid(i);
index e39d482..28c6364 100755 (executable)
@@ -850,7 +850,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
                     .append(" res=").append(f.isDone() ? f.get() : "N/A")
                     .append(" topVer=")
                     .append((U.hasField(f, "topVer") ?
-                        U.field(f, "topVer") : "[unknown] may be it is finished future"))
+                        String.valueOf(U.field(f, "topVer")) : "[unknown] may be it is finished future"))
                     .append("\n");
 
                 Map<UUID, T2<Long, Collection<Integer>>> remaining = U.field(f, "remaining");