jolshan commented on code in PR #16229: URL: https://github.com/apache/kafka/pull/16229#discussion_r1630110425
########## core/src/test/scala/integration/kafka/admin/AdminFenceProducersIntegrationTest.scala: ########## @@ -0,0 +1,95 @@ +/* + * 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 integration.kafka.admin + +import kafka.api.IntegrationTestHarness +import org.apache.kafka.clients.admin._ +import org.apache.kafka.clients.producer.{KafkaProducer, ProducerConfig, ProducerRecord} +import org.apache.kafka.common.errors.ProducerFencedException +import org.apache.kafka.common.utils.Utils +import org.apache.kafka.coordinator.transaction.{TransactionLogConfigs, TransactionStateManagerConfigs} +import org.apache.kafka.server.config.ServerLogConfigs +import org.junit.jupiter.api.Assertions.assertThrows +import org.junit.jupiter.api.{AfterEach, BeforeEach, TestInfo} +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.ValueSource + +import java.util.{Collections, Properties} +import scala.collection.Seq + +class AdminFenceProducersIntegrationTest extends IntegrationTestHarness { + override def brokerCount = 1 + + private val topicName = "topic" + private val txnId = "tnxId" + private val record = new ProducerRecord[Array[Byte], Array[Byte]](topicName, null, new Array[Byte](1)) + + private var adminClient: Admin = _ + private var producer: KafkaProducer[Array[Byte], Array[Byte]] = _ + + @BeforeEach + override def setUp(testInfo: TestInfo): Unit = { + super.setUp(testInfo) + + val producerProps = new Properties + producerProps.put(ProducerConfig.TRANSACTIONAL_ID_CONFIG, txnId) + producerProps.put(ProducerConfig.TRANSACTION_TIMEOUT_CONFIG, 200) + producer = createProducer(configOverrides = producerProps) + adminClient = createAdminClient() + createTopic(topicName) + } + + def overridingProps(): Properties = { + val props = new Properties() + props.put(ServerLogConfigs.AUTO_CREATE_TOPICS_ENABLE_CONFIG, false.toString) + // Set a smaller value for the number of partitions for + props.put(TransactionLogConfigs.TRANSACTIONS_TOPIC_PARTITIONS_CONFIG, 1.toString) + props.put(TransactionLogConfigs.TRANSACTIONS_TOPIC_REPLICATION_FACTOR_CONFIG, 1.toString) + props.put(TransactionLogConfigs.TRANSACTIONS_TOPIC_MIN_ISR_CONFIG, 1.toString) + props.put(TransactionStateManagerConfigs.TRANSACTIONS_ABORT_TIMED_OUT_TRANSACTION_CLEANUP_INTERVAL_MS_CONFIG, "200") Review Comment: ditto to this one. -- 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]
