sashapolo commented on code in PR #7885:
URL: https://github.com/apache/ignite-3/pull/7885#discussion_r2999373853


##########
modules/raft-api/src/test/java/org/apache/ignite/internal/raft/configuration/LogStorageConfigurationValidatorTest.java:
##########
@@ -18,91 +18,127 @@
 package org.apache.ignite.internal.raft.configuration;
 
 import static 
org.apache.ignite.internal.configuration.validation.TestValidationUtil.mockValidationContext;
-import static 
org.apache.ignite.internal.configuration.validation.TestValidationUtil.validate;
 import static 
org.apache.ignite.internal.raft.configuration.LogStorageConfigurationSchema.DEFAULT_MAX_CHECKPOINT_QUEUE_SIZE;
 import static 
org.apache.ignite.internal.raft.configuration.LogStorageConfigurationSchema.DEFAULT_SEGMENT_FILE_SIZE_BYTES;
+import static 
org.apache.ignite.internal.raft.configuration.LogStorageConfigurationSchema.DEFAULT_SOFT_LOG_SIZE_LIMIT_BYTES;
 import static 
org.apache.ignite.internal.raft.configuration.LogStorageConfigurationSchema.UNSPECIFIED_MAX_LOG_ENTRY_SIZE;
-import static org.mockito.Mockito.mock;
+import static org.apache.ignite.internal.util.ArrayUtils.STRING_EMPTY_ARRAY;
 
+import org.apache.ignite.internal.configuration.validation.TestValidationUtil;
 import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
+import org.jetbrains.annotations.Nullable;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
 
+@ExtendWith(MockitoExtension.class)
 class LogStorageConfigurationValidatorTest extends BaseIgniteAbstractTest {
+    @Mock
+    private static ValidLogStorageConfiguration 
VALID_LOG_STORAGE_CONFIGURATION;
+
     private final LogStorageConfigurationValidator validator = new 
LogStorageConfigurationValidator();
 
     @Test
     void unspecifiedLogEntrySizeIsValid() {
         var config = new MockLogStorageView(
                 DEFAULT_MAX_CHECKPOINT_QUEUE_SIZE,
                 DEFAULT_SEGMENT_FILE_SIZE_BYTES,
-                UNSPECIFIED_MAX_LOG_ENTRY_SIZE
+                UNSPECIFIED_MAX_LOG_ENTRY_SIZE,
+                DEFAULT_SOFT_LOG_SIZE_LIMIT_BYTES
         );
 
-        validate(
-                validator,
-                mock(ValidLogStorageConfiguration.class),
-                mockValidationContext(null, config)
-        );
+        validate(config);
     }
 
     @Test
     void correctLogEntrySizeIsValid() {
         var config = new MockLogStorageView(
                 DEFAULT_MAX_CHECKPOINT_QUEUE_SIZE,
                 DEFAULT_SEGMENT_FILE_SIZE_BYTES,
-                (int) (DEFAULT_SEGMENT_FILE_SIZE_BYTES * 0.9)
+                (int) (DEFAULT_SEGMENT_FILE_SIZE_BYTES * 0.9),
+                DEFAULT_SOFT_LOG_SIZE_LIMIT_BYTES
         );
 
-        validate(
-                validator,
-                mock(ValidLogStorageConfiguration.class),
-                mockValidationContext(null, config)
-        );
+        validate(config);
     }
 
     @Test
     void zeroLogEntrySizeIsNotValid() {
         var config = new MockLogStorageView(
                 DEFAULT_MAX_CHECKPOINT_QUEUE_SIZE,
                 DEFAULT_SEGMENT_FILE_SIZE_BYTES,
-                0
+                0,
+                DEFAULT_SOFT_LOG_SIZE_LIMIT_BYTES
         );
 
-        validate(
-                validator,
-                mock(ValidLogStorageConfiguration.class),
-                mockValidationContext(null, config),
-                "Maximum log entry size must be positive, got 0."
-        );
+        validate(config, "Maximum log entry size must be positive 
[maxEntrySize=0 bytes].");
     }
 
     @Test
     void logEntrySizeEqualToSegmentFileSizeIsNotValid() {
         var config = new MockLogStorageView(
                 DEFAULT_MAX_CHECKPOINT_QUEUE_SIZE,
                 10,
-                10
+                10,
+                DEFAULT_SOFT_LOG_SIZE_LIMIT_BYTES
+        );
+
+        validate(config, "Maximum log entry size is too big [maxEntrySize=10 
bytes, maxAllowedEntrySize=9 bytes].");
+    }
+
+    @Test
+    void softLimitLessThanSegmentFileSizeIsNotValid() {
+        var config = new MockLogStorageView(
+                DEFAULT_MAX_CHECKPOINT_QUEUE_SIZE,
+                1000,
+                UNSPECIFIED_MAX_LOG_ENTRY_SIZE,
+                500
         );
 
-        validate(
+        validate(config, "Soft log size limit must be at least the segment 
file size [softLimit=500 bytes, segmentFileSize=1000 bytes].");
+    }
+
+    @Test
+    void softLimitEqualToSegmentFileSizeIsValid() {
+        var config = new MockLogStorageView(
+                DEFAULT_MAX_CHECKPOINT_QUEUE_SIZE,
+                1000,
+                UNSPECIFIED_MAX_LOG_ENTRY_SIZE,
+                1000
+        );
+
+        validate(config);
+    }
+
+    private void validate(LogStorageView config) {
+        validate(config, STRING_EMPTY_ARRAY);
+    }
+
+    private void validate(LogStorageView config, String @Nullable ... 
errorMessagePrefixes) {
+        TestValidationUtil.validate(
                 validator,
-                mock(ValidLogStorageConfiguration.class),
+                VALID_LOG_STORAGE_CONFIGURATION,
                 mockValidationContext(null, config),
-                "Maximum log entry size is too big (10 bytes), maximum allowed 
log entry size is 9 bytes."
+                errorMessagePrefixes
         );
     }
 
     private static class MockLogStorageView implements LogStorageView {

Review Comment:
   Can you clarify please? Seems that there's an approach I don't know about



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