adityamukho commented on code in PR #7255:
URL: https://github.com/apache/ignite-3/pull/7255#discussion_r2625765032


##########
modules/raft-api/src/test/java/org/apache/ignite/internal/raft/configuration/LogStorageConfigurationValidatorTest.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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.UNSPECIFIED_MAX_LOG_ENTRY_SIZE;
+import static org.mockito.Mockito.mock;
+
+import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
+import org.junit.jupiter.api.Test;
+
+class LogStorageConfigurationValidatorTest extends BaseIgniteAbstractTest {
+    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
+        );
+
+        validate(
+                validator,
+                mock(ValidLogStorageConfiguration.class),
+                mockValidationContext(null, config)
+        );
+    }
+
+    @Test
+    void zeroLogEntrySizeIsNotValid() {
+        var config = new MockLogStorageView(
+                DEFAULT_MAX_CHECKPOINT_QUEUE_SIZE,
+                DEFAULT_SEGMENT_FILE_SIZE_BYTES,
+                0
+        );
+
+        validate(
+                validator,
+                mock(ValidLogStorageConfiguration.class),
+                mockValidationContext(null, config),
+                "Maximum log entry size must be positive, got 0."
+        );
+    }
+
+    @Test
+    void logEntrySizeEqualToSegmentFileSizeIsNotValid() {
+        var config = new MockLogStorageView(
+                DEFAULT_MAX_CHECKPOINT_QUEUE_SIZE,
+                10,
+                10
+        );
+
+        validate(
+                validator,
+                mock(ValidLogStorageConfiguration.class),
+                mockValidationContext(null, config),
+                "Maximum log entry size is too big (10 bytes), maximum allowed 
log entry size is 9 bytes."
+        );
+    }

Review Comment:
   Should there be a test to verify that a valid positive log entry size (<= 
90% of segment file size) is considered valid?



##########
modules/raft-api/src/main/java/org/apache/ignite/internal/raft/configuration/LogStorageConfigurationSchema.java:
##########
@@ -26,18 +26,42 @@
 /** Configuration of the Raft log storage. */
 @Config
 public class LogStorageConfigurationSchema {
+    public static final int DEFAULT_MAX_CHECKPOINT_QUEUE_SIZE = 10;
+
+    public static final int DEFAULT_SEGMENT_FILE_SIZE_BYTES = 
Integer.MAX_VALUE;
+
+    public static final int UNSPECIFIED_MAX_LOG_ENTRY_SIZE = -1;
+
     /**
      * Maximum size of the log storage checkpoint queue.
      */
     @Value(hasDefault = true)
     @Range(min = 1)
-    public int maxCheckpointQueueSize = 10;
+    public int maxCheckpointQueueSize = DEFAULT_MAX_CHECKPOINT_QUEUE_SIZE;
 
     /**
      * Size of a segment file in bytes.
      */
-    @SuppressWarnings("PointlessArithmeticExpression") // Suppressed for 
better readability.
     @Value(hasDefault = true)
-    @Range(min = 1 * KiB, max = Integer.MAX_VALUE)
-    public long segmentFileSizeBytes = Integer.MAX_VALUE;
+    @Range(min = 4 * KiB, max = Integer.MAX_VALUE)

Review Comment:
   Either an explicit max value is unnecessary here, or an explicit max value 
should be specified for the `maxCheckpointQueueSize`, for consistency.



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