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 2018/11/06 16:47:45 UTC

ignite git commit: IGNITE-9997 Fixed flaky IgniteDiagnosticMessagesTest.testLongRunningTx - Fixes #5081.

Repository: ignite
Updated Branches:
  refs/heads/master 5459469c4 -> dbff7e263


IGNITE-9997 Fixed flaky IgniteDiagnosticMessagesTest.testLongRunningTx - Fixes #5081.

Signed-off-by: Alexey Goncharuk <al...@gmail.com>


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

Branch: refs/heads/master
Commit: dbff7e263d7e91c64241123f26588080941c4ddd
Parents: 5459469
Author: NSAmelchev <ns...@gmail.com>
Authored: Tue Nov 6 19:46:13 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Nov 6 19:46:13 2018 +0300

----------------------------------------------------------------------
 .../managers/IgniteDiagnosticMessagesTest.java  | 53 +++++++++++++-------
 1 file changed, 35 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dbff7e26/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java
index a29d572..69bc6e9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java
@@ -48,6 +48,8 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.GridStringLogger;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.apache.ignite.transactions.Transaction;
 
@@ -56,6 +58,7 @@ import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
 import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
 import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
 
@@ -78,6 +81,9 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest {
     /** */
     private GridStringLogger strLog;
 
+    /** */
+    private ListeningTestLogger testLog;
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -98,6 +104,12 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest {
             strLog = null;
         }
 
+        if (testLog != null) {
+            cfg.setGridLogger(testLog);
+
+            testLog = null;
+        }
+
         return cfg;
     }
 
@@ -295,18 +307,12 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testLongRunningTx() throws Exception {
-        System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, "3500");
-
-        try {
-            startGrid(0);
-
-            GridStringLogger strLog = this.strLog = new GridStringLogger();
-
-            strLog.logLength(65536);
+        final int longOpDumpTimeout = 1000;
 
-            startGrid(1);
+        System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, String.valueOf(longOpDumpTimeout));
 
-            awaitPartitionMapExchange();
+        try {
+            final Ignite node0 = startGrid(0);
 
             CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
 
@@ -314,13 +320,25 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest {
             ccfg.setCacheMode(PARTITIONED);
             ccfg.setAtomicityMode(TRANSACTIONAL);
 
-            final Ignite node0 = ignite(0);
-            final Ignite node1 = ignite(1);
-
             node0.createCache(ccfg);
 
             UUID id0 = node0.cluster().localNode().id();
 
+            ListeningTestLogger testLog = this.testLog = new ListeningTestLogger(false, log);
+
+            String msg1 = "Cache entries [cacheId=" + CU.cacheId(DEFAULT_CACHE_NAME) +
+                ", cacheName=" + DEFAULT_CACHE_NAME + "]:";
+
+            String msg2 = "General node info [id=" + id0;
+
+            LogListener lsnr = LogListener.matches(msg1).andMatches(msg2).build();
+
+            testLog.registerListener(lsnr);
+
+            final Ignite node1 = startGrid(1);
+
+            awaitPartitionMapExchange();
+
             final CountDownLatch l1 = new CountDownLatch(1);
             final CountDownLatch l2 = new CountDownLatch(1);
 
@@ -365,18 +383,17 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest {
 
             fut.markInitialized();
 
-            U.sleep(10_000);
+            U.sleep(longOpDumpTimeout);
 
             assertFalse(fut.isDone());
 
+            boolean wait = waitForCondition(lsnr::check, longOpDumpTimeout * 2);
+
             l2.countDown();
 
             fut.get();
 
-            String log = strLog.toString();
-
-            assertTrue(log.contains("Cache entries [cacheId=" + CU.cacheId(DEFAULT_CACHE_NAME) + ", cacheName=" + DEFAULT_CACHE_NAME + "]:"));
-            assertTrue(log.contains("General node info [id=" + id0));
+            assertTrue("Unable to found diagnostic messages.", wait);
         }
         finally {
             System.clearProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT);