ibessonov commented on code in PR #7512:
URL: https://github.com/apache/ignite-3/pull/7512#discussion_r2763530687


##########
modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java:
##########
@@ -4729,6 +4735,123 @@ private TestCluster createClusterOf(List<TestPeer> 
peers) {
         );
     }
 
+    /**
+     * Test that closure finished with error when byte size limit is exceeded.
+     */
+    @ParameterizedTest
+    @EnumSource(ApplyTaskMode.class)
+    public void testApplyQueueByteSizeThrottlingExceedsLimit(ApplyTaskMode 
mode) throws Exception {
+        RaftOptions raftOptions = new RaftOptions();
+        // Set limit to 300 KB
+        raftOptions.setMaxApplyQueueByteSize(300 * 1024);
+
+        Node node = setupSingleNodeClusterWithRaftOptions(raftOptions, mode);
+
+        int numTasks = 50;
+        AtomicInteger overloadCount = new AtomicInteger(0);
+        CountDownLatch latch = new CountDownLatch(numTasks);
+
+        List<Task> tasks = new ArrayList<>(numTasks);
+        for (int i = 0; i < numTasks; i++) {
+            byte[] bytes = new byte[100 * 1024]; // 100 KB each
+            ByteBuffer data = ByteBuffer.wrap(bytes);
+            Task task;
+            task = new Task(data, new JoinableClosure(status -> {
+                if (!status.isOk()) {
+                    assertEquals(RaftError.EBUSY, status.getRaftError());
+                    assertTrue(status.getErrorMsg().contains("Node is busy, 
apply queue byte size limit exceeded"));
+                    overloadCount.incrementAndGet();
+                }
+                latch.countDown();
+            }));
+
+            tasks.add(task);
+        }
+
+        for (Task task : tasks) {
+            node.apply(task);
+        }

Review Comment:
   Just a strange observation. Why does `List<Task> tasks = new 
ArrayList<>(numTasks);` exist? You only iterate it once right after its 
creation, is this a deliberate choice in the code? I would like to know that, 
because I don't think that I understand the reasons behind such a choice. It 
appears that in other tests you don't use this patterns. Thank you!



-- 
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