# ignite-sprint-4 avoid infinite loop in test

Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/5fb79489
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5fb79489
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5fb79489

Branch: refs/heads/ignite-728
Commit: 5fb79489f7f9df895ce9044e3e87e30445be19f6
Parents: 7d69c39
Author: sboikov <sboi...@gridgain.com>
Authored: Mon Apr 27 16:40:50 2015 +0300
Committer: sboikov <sboi...@gridgain.com>
Committed: Mon Apr 27 16:49:45 2015 +0300

----------------------------------------------------------------------
 .../DataStreamerMultiThreadedSelfTest.java       | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5fb79489/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java
index 5eedd8d..2382a66 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.datastreamer;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
@@ -68,33 +69,41 @@ public class DataStreamerMultiThreadedSelfTest extends 
GridCommonAbstractTest {
      */
     public void testStartStopIgnites() throws Exception {
         for (int attempt = 0; attempt < 3; ++attempt) {
+            log.info("Iteration: " + attempt);
+            
             final Ignite ignite = startGrid(0);
 
             Set<IgniteFuture> futs = new HashSet<>();
 
+            IgniteInternalFuture<?> fut;
+
             try (final DataStreamerImpl dataLdr = 
(DataStreamerImpl)ignite.dataStreamer(null)) {
                 dataLdr.maxRemapCount(0);
 
                 final AtomicInteger igniteId = new AtomicInteger(1);
 
-                IgniteInternalFuture<?> fut = 
GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
+                fut = GridTestUtils.runMultiThreadedAsync(new 
Callable<Object>() {
                     @Override public Object call() throws Exception {
                         for (int i = 1; i < 5; ++i)
                             startGrid(igniteId.incrementAndGet());
 
                         return true;
                     }
-                }, 2, "startedGridThread");
+                }, 2, "start-node-thread");
+
+                Random random = new Random();
 
-               Random random = new Random();
+                long endTime = U.currentTimeMillis() + 15_000;
 
-                while (!fut.isDone())
-                    futs.add(dataLdr.addData(random.nextInt(100000), 
random.nextInt(100000)));
+                while (!fut.isDone() && U.currentTimeMillis() < endTime)
+                    futs.add(dataLdr.addData(random.nextInt(100_000), 
random.nextInt(100_000)));
             }
 
             for (IgniteFuture f : futs)
                 f.get();
 
+            fut.get();
+
             stopAllGrids();
         }
     }

Reply via email to