Yunyung commented on code in PR #20339: URL: https://github.com/apache/kafka/pull/20339#discussion_r2268103929
########## core/src/test/scala/integration/kafka/api/AdminClientWithPoliciesIntegrationTest.scala: ########## @@ -1,247 +0,0 @@ -/** - * 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 kafka.api - -import java.util -import java.util.Properties -import kafka.integration.KafkaServerTestHarness -import kafka.server.KafkaConfig -import kafka.utils.{Logging, TestUtils} -import org.apache.kafka.clients.admin.AlterConfigOp.OpType -import org.apache.kafka.clients.admin.{Admin, AdminClientConfig, AlterConfigOp, AlterConfigsOptions, ConfigEntry} -import org.apache.kafka.common.config.{ConfigResource, SslConfigs, TopicConfig} -import org.apache.kafka.common.errors.{InvalidConfigurationException, InvalidRequestException, PolicyViolationException} -import org.apache.kafka.common.utils.Utils -import org.apache.kafka.network.SocketServerConfigs -import org.apache.kafka.server.config.{ServerConfigs, ServerLogConfigs} -import org.apache.kafka.server.policy.AlterConfigPolicy -import org.apache.kafka.storage.internals.log.LogConfig -import org.apache.kafka.test.TestUtils.assertFutureThrows -import org.junit.jupiter.api.Assertions.{assertEquals, assertNull, assertTrue} -import org.junit.jupiter.api.{AfterEach, BeforeEach, Test, TestInfo, Timeout} - -import scala.collection.mutable -import scala.jdk.CollectionConverters._ - -/** - * Tests AdminClient calls when the broker is configured with policies like AlterConfigPolicy, CreateTopicPolicy, etc. - */ -@Timeout(120) -class AdminClientWithPoliciesIntegrationTest extends KafkaServerTestHarness with Logging { - - import AdminClientWithPoliciesIntegrationTest._ - - var client: Admin = _ - val brokerCount = 3 - - @BeforeEach - override def setUp(testInfo: TestInfo): Unit = { - super.setUp(testInfo) - TestUtils.waitUntilBrokerMetadataIsPropagated(brokers) - } - - @AfterEach - override def tearDown(): Unit = { - if (client != null) - Utils.closeQuietly(client, "AdminClient") - super.tearDown() - } - - def createConfig: util.Map[String, Object] = - util.Map.of[String, Object](AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers()) - - override def generateConfigs: collection.Seq[KafkaConfig] = { - val configs = TestUtils.createBrokerConfigs(brokerCount) - configs.foreach(overrideNodeConfigs) - configs.map(KafkaConfig.fromProps) - } - - override def kraftControllerConfigs(testInfo: TestInfo): Seq[Properties] = { - val props = new Properties() - overrideNodeConfigs(props) - Seq(props) - } - - private def overrideNodeConfigs(props: Properties): Unit = { - props.put(ServerLogConfigs.ALTER_CONFIG_POLICY_CLASS_NAME_CONFIG, classOf[Policy]) - } - - @Test - def testValidAlterConfigs(): Unit = { - client = Admin.create(createConfig) - // Create topics - val topic1 = "describe-alter-configs-topic-1" - val topicResource1 = new ConfigResource(ConfigResource.Type.TOPIC, topic1) - val topicConfig1 = new Properties - val maxMessageBytes = "500000" - val retentionMs = "60000000" - topicConfig1.setProperty(TopicConfig.MAX_MESSAGE_BYTES_CONFIG, maxMessageBytes) - topicConfig1.setProperty(TopicConfig.RETENTION_MS_CONFIG, retentionMs) - createTopic(topic1, 1, 1, topicConfig1) - - val topic2 = "describe-alter-configs-topic-2" - val topicResource2 = new ConfigResource(ConfigResource.Type.TOPIC, topic2) - createTopic(topic2) - - PlaintextAdminIntegrationTest.checkValidAlterConfigs(client, this, topicResource1, topicResource2, maxMessageBytes, retentionMs) - } - - @Test - def testInvalidAlterConfigs(): Unit = { Review Comment: After checking, this test is already covered in https://github.com/apache/kafka/blob/18045c6ac30921503deffbef1744bb365dc599fb/core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala#L1730-L1734 IMO, there isn’t much value in testing it again. Or, we can add it back when we also migrate PlaintextAdminIntegrationTest to the new infrastructure. -- 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