apalan60 commented on code in PR #19681:
URL: https://github.com/apache/kafka/pull/19681#discussion_r2085346384


##########
storage/src/test/java/org/apache/kafka/admin/RemoteTopicCrudTest.java:
##########
@@ -0,0 +1,833 @@
+/*
+ * 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.kafka.admin;
+
+
+import kafka.utils.TestUtils;
+
+import org.apache.kafka.clients.admin.AlterConfigOp;
+import org.apache.kafka.clients.admin.ConfigEntry;
+import org.apache.kafka.common.TopicIdPartition;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.Uuid;
+import org.apache.kafka.common.config.ConfigResource;
+import org.apache.kafka.common.config.TopicConfig;
+import org.apache.kafka.common.errors.InvalidConfigurationException;
+import org.apache.kafka.common.errors.UnknownTopicOrPartitionException;
+import org.apache.kafka.common.test.ClusterInstance;
+import org.apache.kafka.common.test.api.ClusterConfigProperty;
+import org.apache.kafka.common.test.api.ClusterTest;
+import org.apache.kafka.common.test.api.ClusterTestDefaults;
+import org.apache.kafka.common.test.api.ClusterTests;
+import org.apache.kafka.common.test.api.Type;
+import org.apache.kafka.common.utils.MockTime;
+import org.apache.kafka.server.log.remote.storage.NoOpRemoteLogMetadataManager;
+import org.apache.kafka.server.log.remote.storage.NoOpRemoteStorageManager;
+import org.apache.kafka.server.log.remote.storage.RemoteLogManagerConfig;
+import org.apache.kafka.server.log.remote.storage.RemoteLogSegmentId;
+import org.apache.kafka.server.log.remote.storage.RemoteLogSegmentMetadata;
+import org.apache.kafka.server.log.remote.storage.RemoteLogSegmentState;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.function.Executable;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import scala.collection.immutable.Map$;
+import scala.jdk.javaapi.CollectionConverters;
+import scala.jdk.javaapi.OptionConverters;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+
+@ClusterTestDefaults(
+        types = Type.KRAFT,
+        brokers = 2,
+        serverProperties = {
+            @ClusterConfigProperty(key = 
RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP, value = "true"),
+            @ClusterConfigProperty(key = 
RemoteLogManagerConfig.REMOTE_STORAGE_MANAGER_CLASS_NAME_PROP, value = 
"org.apache.kafka.server.log.remote.storage.NoOpRemoteStorageManager"),
+            @ClusterConfigProperty(key = 
RemoteLogManagerConfig.REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP, value = 
"org.apache.kafka.server.log.remote.storage.NoOpRemoteLogMetadataManager"),
+            @ClusterConfigProperty(key = "log.retention.ms", value = "2000"),
+            @ClusterConfigProperty(key = 
RemoteLogManagerConfig.LOG_LOCAL_RETENTION_MS_PROP, value = "1000"),
+            @ClusterConfigProperty(key = "retention.bytes", value = "2048"),
+            @ClusterConfigProperty(key = 
RemoteLogManagerConfig.LOG_LOCAL_RETENTION_BYTES_PROP, value = "1024")
+        }
+)
+
+class RemoteTopicCrudTest {
+
+    private final ClusterInstance cluster;
+    private final int numPartitions = 2;
+    private final int numReplicationFactor = 2;
+
+    private String testTopicName;
+
+    public RemoteTopicCrudTest(ClusterInstance cluster) {
+        this.cluster = cluster;
+    }
+
+    @BeforeEach
+    void setUp(TestInfo info) {
+        var methodName = info.getTestMethod().orElseThrow().getName();
+        testTopicName = methodName + "-" + 
UUID.randomUUID().toString().replace("-", "").substring(0, 3);
+    }
+
+    @ClusterTest
+    void testCreateRemoteTopicWithValidRetentionTime() {
+        var topicConfig = new Properties();
+        topicConfig.put(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, "true");
+        topicConfig.put(TopicConfig.RETENTION_MS_CONFIG, "200");
+        topicConfig.put(TopicConfig.LOCAL_LOG_RETENTION_MS_CONFIG, "100");
+        try (var admin = cluster.admin()) {
+            TestUtils.createTopicWithAdmin(admin, testTopicName,
+                    CollectionConverters.asScala(new 
ArrayList<>(cluster.brokers().values())),
+                    CollectionConverters.asScala(new 
ArrayList<>(cluster.controllers().values())), 
+                    numPartitions, 
+                    numReplicationFactor,
+                    Map$.MODULE$.empty(),
+                    topicConfig);
+        }

Review Comment:
   I’ve removed all calls to the Scala `TestUtils` and switched topic-related 
operations to the `Admin` API.



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