muralibasani commented on code in PR #16199:
URL: https://github.com/apache/kafka/pull/16199#discussion_r1628950242


##########
storage/src/test/java/org/apache/kafka/server/log/remote/storage/RemoteLogManagerConfigTest.java:
##########
@@ -16,184 +16,105 @@
  */
 package org.apache.kafka.server.log.remote.storage;
 
-import org.apache.kafka.common.config.AbstractConfig;
+import org.apache.kafka.common.config.ConfigException;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
 
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+import static 
org.apache.kafka.server.log.remote.storage.RemoteLogManagerConfig.DEFAULT_REMOTE_LOG_MANAGER_COPY_QUOTA_WINDOW_NUM;
+import static 
org.apache.kafka.server.log.remote.storage.RemoteLogManagerConfig.DEFAULT_REMOTE_LOG_MANAGER_THREAD_POOL_SIZE;
 import static 
org.apache.kafka.server.log.remote.storage.RemoteLogManagerConfig.DEFAULT_REMOTE_LOG_METADATA_MANAGER_CLASS_NAME;
 import static 
org.apache.kafka.server.log.remote.storage.RemoteLogManagerConfig.REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP;
+import static 
org.apache.kafka.server.log.remote.storage.RemoteLogManagerConfig.REMOTE_LOG_METADATA_MANAGER_LISTENER_NAME_PROP;
+import static 
org.apache.kafka.server.log.remote.storage.RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP;
+import static 
org.apache.kafka.server.log.remote.storage.RemoteLogManagerConfig.REMOTE_STORAGE_MANAGER_CLASS_PATH_PROP;
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class RemoteLogManagerConfigTest {
 
-    private static class TestConfig extends AbstractConfig {
-        public TestConfig(Map<?, ?> originals) {
-            super(RemoteLogManagerConfig.CONFIG_DEF, originals, true);
-        }
-    }
-
-    @ParameterizedTest
-    @ValueSource(booleans = {true, false})
-    public void testValidConfigs(boolean 
useDefaultRemoteLogMetadataManagerClass) {
+    @Test
+    public void testValidConfigs() {
         String rsmPrefix = "__custom.rsm.";
         String rlmmPrefix = "__custom.rlmm.";
         Map<String, Object> rsmProps = Collections.singletonMap("rsm.prop", 
"val");
         Map<String, Object> rlmmProps = Collections.singletonMap("rlmm.prop", 
"val");
-        RemoteLogManagerConfig expectedRemoteLogManagerConfig = 
getRemoteLogManagerConfig(useDefaultRemoteLogMetadataManagerClass,
-                rsmPrefix,
-                rlmmPrefix,
-                rsmProps,
-                rlmmProps);
 
-        Map<String, Object> props = 
extractProps(expectedRemoteLogManagerConfig);
+        Map<String, Object> props = getRLMProps(rsmPrefix, rlmmPrefix);
         rsmProps.forEach((k, v) -> props.put(rsmPrefix + k, v));
         rlmmProps.forEach((k, v) -> props.put(rlmmPrefix + k, v));
+
+        RemoteLogManagerConfig expectedRemoteLogManagerConfig = new 
RemoteLogManagerConfig(props);
+
         // Removing remote.log.metadata.manager.class.name so that the default 
value gets picked up.
-        if (useDefaultRemoteLogMetadataManagerClass) {
-            props.remove(REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP);
-        }
-        TestConfig config = new TestConfig(props);
-        RemoteLogManagerConfig remoteLogManagerConfig = new 
RemoteLogManagerConfig(config);
-        assertEquals(expectedRemoteLogManagerConfig, remoteLogManagerConfig);
+        props.remove(REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP);
+
+        RemoteLogManagerConfig remoteLogManagerConfig = new 
RemoteLogManagerConfig(props);
+        assertEquals(expectedRemoteLogManagerConfig.values(), 
remoteLogManagerConfig.values());
+
+        assertEquals(rsmProps, 
remoteLogManagerConfig.remoteStorageManagerProps());
+        assertEquals(rlmmProps, 
remoteLogManagerConfig.remoteLogMetadataManagerProps());
     }
 
-    private static RemoteLogManagerConfig getRemoteLogManagerConfig(boolean 
useDefaultRemoteLogMetadataManagerClass,
-                                                                    String 
rsmPrefix,
-                                                                    String 
rlmmPrefix,
-                                                                    
Map<String, Object> rsmProps,
-                                                                    
Map<String, Object> rlmmProps) {
-        String remoteLogMetadataManagerClass = 
useDefaultRemoteLogMetadataManagerClass ? 
DEFAULT_REMOTE_LOG_METADATA_MANAGER_CLASS_NAME : 
"dummy.remote.log.metadata.class";
-        return new RemoteLogManagerConfig(true,
-                "dummy.remote.storage.class",
-                "dummy.remote.storage.class.path",
-                remoteLogMetadataManagerClass,
-                "dummy.remote.log.metadata.class.path",
-                "listener.name",
-                1024 * 1024L,
-                1,
-                1,
-                1,
-                60000L,
-                100L,
-                60000L,
-                0.3,
-                10,
-                100,
-                100,
-                rsmPrefix,
-                rsmProps,
-                rlmmPrefix,
-                rlmmProps,
-                Long.MAX_VALUE,
-                11,
-                1,
-                Long.MAX_VALUE,
-                11,
-                1,
-                500);
+    @Test
+    public void testDefaultConfigs() {
+        // Even with empty properties, RemoteLogManagerConfig has default 
values
+        Map<String, Object> emptyProps = new HashMap<>();
+        RemoteLogManagerConfig remoteLogManagerConfigEmptyConfig = new 
RemoteLogManagerConfig(emptyProps);
+        
assertEquals(remoteLogManagerConfigEmptyConfig.remoteLogManagerThreadPoolSize(),
 DEFAULT_REMOTE_LOG_MANAGER_THREAD_POOL_SIZE);
+        
assertEquals(remoteLogManagerConfigEmptyConfig.remoteLogManagerCopyNumQuotaSamples(),
 DEFAULT_REMOTE_LOG_MANAGER_COPY_QUOTA_WINDOW_NUM);
+    }
+
+    @Test
+    public void testValidateEmptyStringConfig() {
+        // Test with a empty string props should throw ConfigException
+        Map<String, Object> emptyStringProps = 
Collections.singletonMap(REMOTE_LOG_METADATA_MANAGER_LISTENER_NAME_PROP, "");
+        assertThrows(ConfigException.class, () ->
+                new RemoteLogManagerConfig(emptyStringProps));
     }
 
-    private Map<String, Object> extractProps(RemoteLogManagerConfig 
remoteLogManagerConfig) {
+    private Map<String, Object> getRLMProps(String rsmPrefix, String 
rlmmPrefix) {
+
         Map<String, Object> props = new HashMap<>();
-        props.put(RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP,
-                  remoteLogManagerConfig.enableRemoteStorageSystem());
+        props.put(REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP, true);

Review Comment:
   Yea, fixed now. thanks.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to