shishkovilja commented on code in PR #12161:
URL: https://github.com/apache/ignite/pull/12161#discussion_r2930338381


##########
modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerWarningsTest.java:
##########
@@ -131,6 +137,74 @@ public class GridCachePartitionExchangeManagerWarningsTest 
extends GridCommonAbs
         return cfg;
     }
 
+    /**
+     *
+     */
+    @Test
+    public void testSingleMessageErrorWarnings() throws Exception {
+        long waitingTimeout = 5_000;

Review Comment:
   Why 5 seconds, not 1, not 10? What if GC pause or other freeze happens? I 
suggest to remove timeout.



##########
modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerWarningsTest.java:
##########
@@ -131,6 +137,74 @@ public class GridCachePartitionExchangeManagerWarningsTest 
extends GridCommonAbs
         return cfg;
     }
 
+    /**
+     *
+     */
+    @Test
+    public void testSingleMessageErrorWarnings() throws Exception {
+        long waitingTimeout = 5_000;
+        String logSubstr = "Failed to send local partitions to node because it 
left grid [nodeId=";
+
+        LogListener logListener = 
LogListener.matches(logSubstr).atLeast(1).build();
+        testLog = new ListeningTestLogger(log, logListener);
+
+        CountDownLatch beforeSend = new CountDownLatch(1);
+        CountDownLatch proceed = new CountDownLatch(1);
+
+        AtomicReference<UUID> crdIdRef = new AtomicReference<>();
+
+        spiSupp = () -> new TcpCommunicationSpi() {
+            /** {@inheritDoc} */
+            @Override public void sendMessage(ClusterNode node, Message msg, 
IgniteInClosure<IgniteException> ackC)
+                throws IgniteSpiException {
+                boolean isSingleMsg = ((GridIoMessage)msg).message() 
instanceof GridDhtPartitionsSingleMessage;
+                UUID crdId = crdIdRef.get();
+
+                if (isSingleMsg && node != null && crdId != null && 
crdId.equals(node.id())) {
+                    beforeSend.countDown();
+
+                    try {
+                        if (!proceed.await(waitingTimeout, 
TimeUnit.MILLISECONDS))

Review Comment:
   ```suggestion
                          nodeStopLatch.await();
   ```



##########
modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerWarningsTest.java:
##########
@@ -131,6 +137,74 @@ public class GridCachePartitionExchangeManagerWarningsTest 
extends GridCommonAbs
         return cfg;
     }
 
+    /**
+     *
+     */
+    @Test
+    public void testSingleMessageErrorWarnings() throws Exception {
+        long waitingTimeout = 5_000;
+        String logSubstr = "Failed to send local partitions to node because it 
left grid [nodeId=";
+
+        LogListener logListener = 
LogListener.matches(logSubstr).atLeast(1).build();
+        testLog = new ListeningTestLogger(log, logListener);
+
+        CountDownLatch beforeSend = new CountDownLatch(1);
+        CountDownLatch proceed = new CountDownLatch(1);
+
+        AtomicReference<UUID> crdIdRef = new AtomicReference<>();
+
+        spiSupp = () -> new TcpCommunicationSpi() {
+            /** {@inheritDoc} */
+            @Override public void sendMessage(ClusterNode node, Message msg, 
IgniteInClosure<IgniteException> ackC)
+                throws IgniteSpiException {
+                boolean isSingleMsg = ((GridIoMessage)msg).message() 
instanceof GridDhtPartitionsSingleMessage;
+                UUID crdId = crdIdRef.get();
+
+                if (isSingleMsg && node != null && crdId != null && 
crdId.equals(node.id())) {
+                    beforeSend.countDown();
+
+                    try {
+                        if (!proceed.await(waitingTimeout, 
TimeUnit.MILLISECONDS))
+                            throw new IgniteSpiException("Test timeout waiting 
to proceed");

Review Comment:
   ```suggestion
   ```



##########
modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerWarningsTest.java:
##########
@@ -131,6 +137,74 @@ public class GridCachePartitionExchangeManagerWarningsTest 
extends GridCommonAbs
         return cfg;
     }
 
+    /**
+     *
+     */
+    @Test
+    public void testSingleMessageErrorWarnings() throws Exception {
+        long waitingTimeout = 5_000;
+        String logSubstr = "Failed to send local partitions to node because it 
left grid [nodeId=";
+
+        LogListener logListener = 
LogListener.matches(logSubstr).atLeast(1).build();
+        testLog = new ListeningTestLogger(log, logListener);
+
+        CountDownLatch beforeSend = new CountDownLatch(1);
+        CountDownLatch proceed = new CountDownLatch(1);
+
+        AtomicReference<UUID> crdIdRef = new AtomicReference<>();
+
+        spiSupp = () -> new TcpCommunicationSpi() {
+            /** {@inheritDoc} */
+            @Override public void sendMessage(ClusterNode node, Message msg, 
IgniteInClosure<IgniteException> ackC)
+                throws IgniteSpiException {
+                boolean isSingleMsg = ((GridIoMessage)msg).message() 
instanceof GridDhtPartitionsSingleMessage;
+                UUID crdId = crdIdRef.get();
+
+                if (isSingleMsg && node != null && crdId != null && 
crdId.equals(node.id())) {
+                    beforeSend.countDown();
+
+                    try {
+                        if (!proceed.await(waitingTimeout, 
TimeUnit.MILLISECONDS))
+                            throw new IgniteSpiException("Test timeout waiting 
to proceed");
+                    }
+                    catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
+
+                        throw new IgniteSpiException("Interrupted while 
waiting to proceed", e);
+                    }
+                }
+
+                super.sendMessage(node, msg, ackC);
+            }
+        };
+
+        IgniteEx crd = startGrid(0);
+        IgniteEx node1 = startGrid(1);
+
+        awaitPartitionMapExchange();
+
+        crdIdRef.set(crd.localNode().id());
+
+        IgniteInternalFuture<?> fut = GridTestUtils.runAsync(() ->
+            node1.context().cache().context().exchange().refreshPartitions());
+
+        try {
+            assertTrue("Did not enter sendMessage() in time", 
beforeSend.await(waitingTimeout, TimeUnit.MILLISECONDS));
+
+            stopGrid(0);
+
+            proceed.countDown();
+
+            fut.get(waitingTimeout);
+
+            assertTrue("Expected log not found", 
GridTestUtils.waitForCondition(logListener::check, waitingTimeout));

Review Comment:
   ```suggestion
               assertTrue("Expected log not found", 
GridTestUtils.waitForCondition(logListener::check, getTestTimeout()));
   ```



##########
modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerWarningsTest.java:
##########
@@ -131,6 +137,74 @@ public class GridCachePartitionExchangeManagerWarningsTest 
extends GridCommonAbs
         return cfg;
     }
 
+    /**
+     *
+     */
+    @Test
+    public void testSingleMessageErrorWarnings() throws Exception {
+        long waitingTimeout = 5_000;
+        String logSubstr = "Failed to send local partitions to node because it 
left grid [nodeId=";
+
+        LogListener logListener = 
LogListener.matches(logSubstr).atLeast(1).build();
+        testLog = new ListeningTestLogger(log, logListener);
+
+        CountDownLatch beforeSend = new CountDownLatch(1);
+        CountDownLatch proceed = new CountDownLatch(1);
+
+        AtomicReference<UUID> crdIdRef = new AtomicReference<>();
+
+        spiSupp = () -> new TcpCommunicationSpi() {
+            /** {@inheritDoc} */
+            @Override public void sendMessage(ClusterNode node, Message msg, 
IgniteInClosure<IgniteException> ackC)
+                throws IgniteSpiException {
+                boolean isSingleMsg = ((GridIoMessage)msg).message() 
instanceof GridDhtPartitionsSingleMessage;
+                UUID crdId = crdIdRef.get();
+
+                if (isSingleMsg && node != null && crdId != null && 
crdId.equals(node.id())) {
+                    beforeSend.countDown();
+
+                    try {
+                        if (!proceed.await(waitingTimeout, 
TimeUnit.MILLISECONDS))
+                            throw new IgniteSpiException("Test timeout waiting 
to proceed");
+                    }
+                    catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
+
+                        throw new IgniteSpiException("Interrupted while 
waiting to proceed", e);
+                    }
+                }
+
+                super.sendMessage(node, msg, ackC);
+            }
+        };
+
+        IgniteEx crd = startGrid(0);
+        IgniteEx node1 = startGrid(1);
+
+        awaitPartitionMapExchange();
+
+        crdIdRef.set(crd.localNode().id());
+
+        IgniteInternalFuture<?> fut = GridTestUtils.runAsync(() ->
+            node1.context().cache().context().exchange().refreshPartitions());
+
+        try {
+            assertTrue("Did not enter sendMessage() in time", 
beforeSend.await(waitingTimeout, TimeUnit.MILLISECONDS));

Review Comment:
   ```suggestion
               singleMsgLatch.await();
   ```



##########
modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerWarningsTest.java:
##########
@@ -131,6 +137,74 @@ public class GridCachePartitionExchangeManagerWarningsTest 
extends GridCommonAbs
         return cfg;
     }
 
+    /**
+     *
+     */
+    @Test
+    public void testSingleMessageErrorWarnings() throws Exception {
+        long waitingTimeout = 5_000;
+        String logSubstr = "Failed to send local partitions to node because it 
left grid [nodeId=";
+
+        LogListener logListener = 
LogListener.matches(logSubstr).atLeast(1).build();
+        testLog = new ListeningTestLogger(log, logListener);
+
+        CountDownLatch beforeSend = new CountDownLatch(1);
+        CountDownLatch proceed = new CountDownLatch(1);
+
+        AtomicReference<UUID> crdIdRef = new AtomicReference<>();
+
+        spiSupp = () -> new TcpCommunicationSpi() {
+            /** {@inheritDoc} */
+            @Override public void sendMessage(ClusterNode node, Message msg, 
IgniteInClosure<IgniteException> ackC)
+                throws IgniteSpiException {
+                boolean isSingleMsg = ((GridIoMessage)msg).message() 
instanceof GridDhtPartitionsSingleMessage;
+                UUID crdId = crdIdRef.get();
+
+                if (isSingleMsg && node != null && crdId != null && 
crdId.equals(node.id())) {
+                    beforeSend.countDown();
+
+                    try {
+                        if (!proceed.await(waitingTimeout, 
TimeUnit.MILLISECONDS))
+                            throw new IgniteSpiException("Test timeout waiting 
to proceed");
+                    }
+                    catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
+
+                        throw new IgniteSpiException("Interrupted while 
waiting to proceed", e);
+                    }
+                }
+
+                super.sendMessage(node, msg, ackC);
+            }
+        };
+
+        IgniteEx crd = startGrid(0);
+        IgniteEx node1 = startGrid(1);
+
+        awaitPartitionMapExchange();
+
+        crdIdRef.set(crd.localNode().id());
+
+        IgniteInternalFuture<?> fut = GridTestUtils.runAsync(() ->
+            node1.context().cache().context().exchange().refreshPartitions());
+
+        try {
+            assertTrue("Did not enter sendMessage() in time", 
beforeSend.await(waitingTimeout, TimeUnit.MILLISECONDS));
+
+            stopGrid(0);
+
+            proceed.countDown();

Review Comment:
   ```suggestion
               nodeStopLatch.countDown();
   ```



##########
modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerWarningsTest.java:
##########
@@ -131,6 +137,74 @@ public class GridCachePartitionExchangeManagerWarningsTest 
extends GridCommonAbs
         return cfg;
     }
 
+    /**
+     *
+     */
+    @Test
+    public void testSingleMessageErrorWarnings() throws Exception {
+        long waitingTimeout = 5_000;
+        String logSubstr = "Failed to send local partitions to node because it 
left grid [nodeId=";
+
+        LogListener logListener = 
LogListener.matches(logSubstr).atLeast(1).build();
+        testLog = new ListeningTestLogger(log, logListener);
+
+        CountDownLatch beforeSend = new CountDownLatch(1);
+        CountDownLatch proceed = new CountDownLatch(1);

Review Comment:
   ```suggestion
           CountDownLatch nodeStopLatch = new CountDownLatch(1);
   ```



##########
modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerWarningsTest.java:
##########
@@ -131,6 +137,74 @@ public class GridCachePartitionExchangeManagerWarningsTest 
extends GridCommonAbs
         return cfg;
     }
 
+    /**
+     *
+     */
+    @Test
+    public void testSingleMessageErrorWarnings() throws Exception {
+        long waitingTimeout = 5_000;
+        String logSubstr = "Failed to send local partitions to node because it 
left grid [nodeId=";
+
+        LogListener logListener = 
LogListener.matches(logSubstr).atLeast(1).build();
+        testLog = new ListeningTestLogger(log, logListener);
+
+        CountDownLatch beforeSend = new CountDownLatch(1);

Review Comment:
   ```suggestion
           CountDownLatch singleMsgLatch = new CountDownLatch(1);
   ```



##########
modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerWarningsTest.java:
##########
@@ -131,6 +137,74 @@ public class GridCachePartitionExchangeManagerWarningsTest 
extends GridCommonAbs
         return cfg;
     }
 
+    /**
+     *
+     */
+    @Test
+    public void testSingleMessageErrorWarnings() throws Exception {
+        long waitingTimeout = 5_000;
+        String logSubstr = "Failed to send local partitions to node because it 
left grid [nodeId=";
+
+        LogListener logListener = 
LogListener.matches(logSubstr).atLeast(1).build();
+        testLog = new ListeningTestLogger(log, logListener);
+
+        CountDownLatch beforeSend = new CountDownLatch(1);
+        CountDownLatch proceed = new CountDownLatch(1);
+
+        AtomicReference<UUID> crdIdRef = new AtomicReference<>();
+
+        spiSupp = () -> new TcpCommunicationSpi() {
+            /** {@inheritDoc} */
+            @Override public void sendMessage(ClusterNode node, Message msg, 
IgniteInClosure<IgniteException> ackC)
+                throws IgniteSpiException {
+                boolean isSingleMsg = ((GridIoMessage)msg).message() 
instanceof GridDhtPartitionsSingleMessage;
+                UUID crdId = crdIdRef.get();
+
+                if (isSingleMsg && node != null && crdId != null && 
crdId.equals(node.id())) {
+                    beforeSend.countDown();

Review Comment:
   ```suggestion
                       singleMsgLatch.countDown();
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to