Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ KafkaConfig createKafkaDefaultConfig() {
int brokerId = 1;
Properties properties = TestUtils.createBrokerConfig(
brokerId,
null,
true,
true,
TestUtils.RandomPort(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class ListOffsetsIntegrationTest extends KafkaServerTestHarness {
}

def generateConfigs: Seq[KafkaConfig] = {
TestUtils.createBrokerConfigs(2, null).zipWithIndex.map{ case (props, index) =>
TestUtils.createBrokerConfigs(2).zipWithIndex.map{ case (props, index) =>
// We use mock timer so the records can get removed if the test env is too busy to complete
// tests before kafka-log-retention. Hence, we disable the retention to avoid failed tests
props.setProperty(ServerLogConfigs.LOG_RETENTION_TIME_MILLIS_CONFIG, "-1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ class RemoteTopicCrudTest extends IntegrationTestHarness {
TestUtils.createTopicWithAdmin(createAdminClient(), testTopicName, brokers, controllerServers, numPartitions, brokerCount,
topicConfig = topicConfig)

val tsDisabledProps = TestUtils.createBrokerConfigs(1, null).head
val tsDisabledProps = TestUtils.createBrokerConfigs(1).head
instanceConfigs = List(KafkaConfig.fromProps(tsDisabledProps))

recreateBrokers(startup = true)
Expand All @@ -490,7 +490,7 @@ class RemoteTopicCrudTest extends IntegrationTestHarness {
TestUtils.createTopicWithAdmin(createAdminClient(), testTopicName, brokers, controllerServers, numPartitions, brokerCount,
topicConfig = topicConfig)

val tsDisabledProps = TestUtils.createBrokerConfigs(1, null).head
val tsDisabledProps = TestUtils.createBrokerConfigs(1).head
instanceConfigs = List(KafkaConfig.fromProps(tsDisabledProps))

recreateBrokers(startup = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AdminClientWithPoliciesIntegrationTest extends KafkaServerTestHarness with
Map[String, Object](AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG -> bootstrapServers()).asJava

override def generateConfigs: collection.Seq[KafkaConfig] = {
val configs = TestUtils.createBrokerConfigs(brokerCount, null)
val configs = TestUtils.createBrokerConfigs(brokerCount)
configs.foreach(overrideNodeConfigs)
configs.map(KafkaConfig.fromProps)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ abstract class BaseProducerSendTest extends KafkaServerTestHarness {
overridingProps.put(ServerLogConfigs.NUM_PARTITIONS_CONFIG, 4.toString)
TestUtils.createBrokerConfigs(
numServers,
null,
interBrokerSecurityProtocol = Some(securityProtocol),
trustStoreFile = trustStoreFile,
saslProperties = serverSaslProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ConsumerBounceTest extends AbstractConsumerTest with Logging {
private def generateKafkaConfigs(maxGroupSize: String = maxGroupSize.toString): Seq[KafkaConfig] = {
val properties = new Properties
testConfigs.foreachEntry((k, v) => properties.setProperty(k, v))
FixedPortTestUtils.createBrokerConfigs(brokerCount, null, enableControlledShutdown = false)
FixedPortTestUtils.createBrokerConfigs(brokerCount, enableControlledShutdown = false)
.map(KafkaConfig.fromProps(_, properties))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import java.util.Properties
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.{AtomicBoolean, AtomicInteger}
import java.{lang, util}
import scala.collection.Seq
import scala.collection.mutable.ArrayBuffer
import scala.jdk.CollectionConverters._

Expand Down Expand Up @@ -178,8 +179,7 @@ class CustomQuotaCallbackTest extends IntegrationTestHarness with SaslSetup {
}

private def createTopic(topic: String, numPartitions: Int, leader: Int): Unit = {
val assignment = (0 until numPartitions).map { i => i -> Seq(leader) }.toMap
TestUtils.createTopic(null, topic, assignment, servers)
// TODO createTopic
}

private def createAdminClient(): Admin = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class EndToEndClusterIdTest extends KafkaServerTestHarness {
this.serverConfig.setProperty(MetricConfigs.METRIC_REPORTER_CLASSES_CONFIG, classOf[MockBrokerMetricsReporter].getName)

override def generateConfigs = {
val cfgs = TestUtils.createBrokerConfigs(serverCount, null, interBrokerSecurityProtocol = Some(securityProtocol),
val cfgs = TestUtils.createBrokerConfigs(serverCount, interBrokerSecurityProtocol = Some(securityProtocol),
trustStoreFile = trustStoreFile, saslProperties = serverSaslProperties)
cfgs.foreach(_ ++= serverConfig)
cfgs.map(KafkaConfig.fromProps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ object FixedPortTestUtils {
}

def createBrokerConfigs(numConfigs: Int,
zkConnect: String,
enableControlledShutdown: Boolean = true,
enableDeleteTopic: Boolean = false): Seq[Properties] = {
val ports = FixedPortTestUtils.choosePorts(numConfigs)
(0 until numConfigs).map { node =>
TestUtils.createBrokerConfig(node, zkConnect, enableControlledShutdown, enableDeleteTopic, ports(node))
TestUtils.createBrokerConfig(node, enableControlledShutdown, enableDeleteTopic, ports(node))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ abstract class IntegrationTestHarness extends KafkaServerTestHarness {
}

override def generateConfigs: Seq[KafkaConfig] = {
val cfgs = TestUtils.createBrokerConfigs(brokerCount, null, interBrokerSecurityProtocol = Some(securityProtocol),
val cfgs = TestUtils.createBrokerConfigs(brokerCount, interBrokerSecurityProtocol = Some(securityProtocol),
trustStoreFile = trustStoreFile, saslProperties = serverSaslProperties, logDirCount = logDirCount)
configureListeners(cfgs)
modifyConfigs(cfgs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ProducerCompressionTest extends QuorumTestHarness {
@BeforeEach
override def setUp(testInfo: TestInfo): Unit = {
super.setUp(testInfo)
val props = TestUtils.createBrokerConfig(brokerId, null)
val props = TestUtils.createBrokerConfig(brokerId)
broker = createBroker(new KafkaConfig(props))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ProducerFailureHandlingTest extends KafkaServerTestHarness {
overridingProps.put(GroupCoordinatorConfig.OFFSETS_TOPIC_PARTITIONS_CONFIG, 1.toString)

def generateConfigs =
TestUtils.createBrokerConfigs(numServers, null, enableControlledShutdown = false).map(KafkaConfig.fromProps(_, overridingProps))
TestUtils.createBrokerConfigs(numServers, enableControlledShutdown = false).map(KafkaConfig.fromProps(_, overridingProps))

private var producer1: KafkaProducer[Array[Byte], Array[Byte]] = _
private var producer2: KafkaProducer[Array[Byte], Array[Byte]] = _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ProducerIdExpirationTest extends KafkaServerTestHarness {
var admin: Admin = _

override def generateConfigs: Seq[KafkaConfig] = {
TestUtils.createBrokerConfigs(3, null).map(KafkaConfig.fromProps(_, serverProps()))
TestUtils.createBrokerConfigs(3).map(KafkaConfig.fromProps(_, serverProps()))
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class RackAwareAutoTopicCreationTest extends KafkaServerTestHarness with RackAwa

def generateConfigs =
(0 until numServers) map { node =>
TestUtils.createBrokerConfig(node, null, enableControlledShutdown = false, rack = Some((node / 2).toString))
TestUtils.createBrokerConfig(node, enableControlledShutdown = false, rack = Some((node / 2).toString))
} map (KafkaConfig.fromProps(_, overridingProps))

private val topic = "topic"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class RebootstrapTest extends AbstractConsumerTest {

// In this test, fixed ports are necessary, because brokers must have the
// same port after the restart.
FixedPortTestUtils.createBrokerConfigs(brokerCount, null, enableControlledShutdown = false)
FixedPortTestUtils.createBrokerConfigs(brokerCount, enableControlledShutdown = false)
.map(KafkaConfig.fromProps(_, overridingProps))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class TransactionsBounceTest extends IntegrationTestHarness {
// Since such quick rotation of servers is incredibly unrealistic, we allow this one test to preallocate ports, leaving
// a small risk of hitting errors due to port conflicts. Hopefully this is infrequent enough to not cause problems.
override def generateConfigs = {
FixedPortTestUtils.createBrokerConfigs(brokerCount, null)
FixedPortTestUtils.createBrokerConfigs(brokerCount)
.map(KafkaConfig.fromProps(_, overridingProps))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TransactionsExpirationTest extends KafkaServerTestHarness {
var admin: Admin = _

override def generateConfigs: Seq[KafkaConfig] = {
TestUtils.createBrokerConfigs(3, null).map(KafkaConfig.fromProps(_, serverProps()))
TestUtils.createBrokerConfigs(3).map(KafkaConfig.fromProps(_, serverProps()))
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TransactionsWithMaxInFlightOneTest extends KafkaServerTestHarness {
val transactionalConsumers = mutable.Buffer[Consumer[Array[Byte], Array[Byte]]]()

override def generateConfigs: Seq[KafkaConfig] = {
TestUtils.createBrokerConfigs(numBrokers, null).map(KafkaConfig.fromProps(_, serverProps()))
TestUtils.createBrokerConfigs(numBrokers).map(KafkaConfig.fromProps(_, serverProps()))
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class DynamicBrokerReconfigurationTest extends QuorumTestHarness with SaslSetup

(0 until numServers).foreach { brokerId =>

val props = TestUtils.createBrokerConfig(brokerId, null)
val props = TestUtils.createBrokerConfig(brokerId)
props.put(SocketServerConfigs.ADVERTISED_LISTENERS_CONFIG, s"$SecureInternal://localhost:0, $SecureExternal://localhost:0")
props ++= securityProps(sslProperties1, TRUSTSTORE_PROPS)
// Ensure that we can support multiple listeners per security protocol and multiple security protocols
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FetchFromFollowerIntegrationTest extends BaseFetchRequestTest {
}

override def generateConfigs: collection.Seq[KafkaConfig] = {
TestUtils.createBrokerConfigs(numNodes, null, enableControlledShutdown = false, enableFetchFromFollower = true)
TestUtils.createBrokerConfigs(numNodes, enableControlledShutdown = false, enableFetchFromFollower = true)
.map(KafkaConfig.fromProps(_, overridingProps))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ abstract class MultipleListenersWithSameSecurityProtocolBaseTest extends QuorumT

(0 until numServers).foreach { brokerId =>

val props = TestUtils.createBrokerConfig(brokerId, null, trustStoreFile = Some(trustStoreFile))
val props = TestUtils.createBrokerConfig(brokerId, trustStoreFile = Some(trustStoreFile))
// Ensure that we can support multiple listeners per security protocol and multiple security protocols
props.put(SocketServerConfigs.LISTENERS_CONFIG, s"$SecureInternal://localhost:0, $Internal://localhost:0, " +
s"$SecureExternal://localhost:0, $External://localhost:0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class LocalLeaderEndPointTest extends Logging {

@BeforeEach
def setUp(): Unit = {
val props = TestUtils.createBrokerConfig(sourceBroker.id, null, port = sourceBroker.port)
val props = TestUtils.createBrokerConfig(sourceBroker.id, port = sourceBroker.port)
val config = KafkaConfig.fromProps(props)
val mockLogMgr = TestUtils.createLogManager(config.logDirs.map(new File(_)))
val alterPartitionManager = mock(classOf[AlterPartitionManager])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class NodeToControllerRequestThreadTest {
@Test
def testRetryTimeoutWhileControllerNotAvailable(): Unit = {
val time = new MockTime()
val config = new KafkaConfig(TestUtils.createBrokerConfig(1, "localhost:2181"))
val config = new KafkaConfig(TestUtils.createBrokerConfig(1))
val metadata = mock(classOf[Metadata])
val mockClient = new MockClient(time, metadata)
val controllerNodeProvider = mock(classOf[ControllerNodeProvider])
Expand Down Expand Up @@ -84,7 +84,7 @@ class NodeToControllerRequestThreadTest {
def testRequestsSent(): Unit = {
// just a simple test that tests whether the request from 1 -> 2 is sent and the response callback is called
val time = new MockTime()
val config = new KafkaConfig(TestUtils.createBrokerConfig(1, "localhost:2181"))
val config = new KafkaConfig(TestUtils.createBrokerConfig(1))
val controllerId = 2

val metadata = mock(classOf[Metadata])
Expand Down Expand Up @@ -125,7 +125,7 @@ class NodeToControllerRequestThreadTest {
def testControllerChanged(): Unit = {
// in this test the current broker is 1, and the controller changes from 2 -> 3 then back: 3 -> 2
val time = new MockTime()
val config = new KafkaConfig(TestUtils.createBrokerConfig(1, "localhost:2181"))
val config = new KafkaConfig(TestUtils.createBrokerConfig(1))
val oldControllerId = 1
val newControllerId = 2

Expand Down Expand Up @@ -173,7 +173,7 @@ class NodeToControllerRequestThreadTest {
@Test
def testNotController(): Unit = {
val time = new MockTime()
val config = new KafkaConfig(TestUtils.createBrokerConfig(1, "localhost:2181"))
val config = new KafkaConfig(TestUtils.createBrokerConfig(1))
val oldControllerId = 1
val newControllerId = 2

Expand Down Expand Up @@ -233,7 +233,7 @@ class NodeToControllerRequestThreadTest {
@Test
def testEnvelopeResponseWithNotControllerError(): Unit = {
val time = new MockTime()
val config = new KafkaConfig(TestUtils.createBrokerConfig(1, "localhost:2181"))
val config = new KafkaConfig(TestUtils.createBrokerConfig(1))
val oldControllerId = 1
val newControllerId = 2

Expand Down Expand Up @@ -307,7 +307,7 @@ class NodeToControllerRequestThreadTest {
@Test
def testRetryTimeout(): Unit = {
val time = new MockTime()
val config = new KafkaConfig(TestUtils.createBrokerConfig(1, "localhost:2181"))
val config = new KafkaConfig(TestUtils.createBrokerConfig(1))
val controllerId = 1

val metadata = mock(classOf[Metadata])
Expand Down Expand Up @@ -356,7 +356,7 @@ class NodeToControllerRequestThreadTest {
@Test
def testUnsupportedVersionHandling(): Unit = {
val time = new MockTime()
val config = new KafkaConfig(TestUtils.createBrokerConfig(1, "localhost:2181"))
val config = new KafkaConfig(TestUtils.createBrokerConfig(1))
val controllerId = 2

val metadata = mock(classOf[Metadata])
Expand Down Expand Up @@ -394,7 +394,7 @@ class NodeToControllerRequestThreadTest {
@Test
def testAuthenticationExceptionHandling(): Unit = {
val time = new MockTime()
val config = new KafkaConfig(TestUtils.createBrokerConfig(1, "localhost:2181"))
val config = new KafkaConfig(TestUtils.createBrokerConfig(1))
val controllerId = 2

val metadata = mock(classOf[Metadata])
Expand Down Expand Up @@ -434,7 +434,7 @@ class NodeToControllerRequestThreadTest {
def testThreadNotStarted(): Unit = {
// Make sure we throw if we enqueue anything while the thread is not running
val time = new MockTime()
val config = new KafkaConfig(TestUtils.createBrokerConfig(1, "localhost:2181"))
val config = new KafkaConfig(TestUtils.createBrokerConfig(1))

val metadata = mock(classOf[Metadata])
val mockClient = new MockClient(time, metadata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class RemoteLeaderEndPointTest {
val time = new MockTime
val logPrefix = "remote-leader-endpoint"
val sourceBroker: BrokerEndPoint = new BrokerEndPoint(0, "localhost", 9092)
val props = TestUtils.createBrokerConfig(sourceBroker.id, TestUtils.MockZkConnect, port = sourceBroker.port)
val props = TestUtils.createBrokerConfig(sourceBroker.id, port = sourceBroker.port)
val fetchSessionHandler = new FetchSessionHandler(new LogContext(logPrefix), sourceBroker.id)
val config = KafkaConfig.fromProps(props)
blockingSend = new MockBlockingSender(offsets = new util.HashMap[TopicPartition, EpochEndOffset](),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import scala.jdk.CollectionConverters._

abstract class AbstractCoordinatorConcurrencyTest[M <: CoordinatorMember] extends Logging {
val nThreads = 5
val serverProps = TestUtils.createBrokerConfig(nodeId = 0, zkConnect = "")
val serverProps = TestUtils.createBrokerConfig(0)
val random = new Random
var replicaManager: TestReplicaManager = _
var zkClient: KafkaZkClient = _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class GroupCoordinatorTest {

@BeforeEach
def setUp(): Unit = {
val props = TestUtils.createBrokerConfig(nodeId = 0, zkConnect = "")
val props = TestUtils.createBrokerConfig(0)
props.setProperty(GroupCoordinatorConfig.GROUP_MIN_SESSION_TIMEOUT_MS_CONFIG, GroupMinSessionTimeout.toString)
props.setProperty(GroupCoordinatorConfig.GROUP_MAX_SESSION_TIMEOUT_MS_CONFIG, GroupMaxSessionTimeout.toString)
props.setProperty(GroupCoordinatorConfig.GROUP_MAX_SIZE_CONFIG, GroupMaxSize.toString)
Expand Down Expand Up @@ -201,7 +201,7 @@ class GroupCoordinatorTest {

@Test
def testOffsetsRetentionMsIntegerOverflow(): Unit = {
val props = TestUtils.createBrokerConfig(nodeId = 0, zkConnect = "")
val props = TestUtils.createBrokerConfig(0)
props.setProperty(GroupCoordinatorConfig.OFFSETS_RETENTION_MINUTES_CONFIG, Integer.MAX_VALUE.toString)
val config = KafkaConfig.fromProps(props)
val offsetConfig = GroupCoordinator.offsetConfig(config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class GroupMetadataManagerTest {
val noExpiration = OptionalLong.empty()

private val offsetConfig = {
val config = KafkaConfig.fromProps(TestUtils.createBrokerConfig(nodeId = 0, zkConnect = ""))
val config = KafkaConfig.fromProps(TestUtils.createBrokerConfig(0))
new OffsetConfig(config.groupCoordinatorConfig.offsetMetadataMaxSize,
config.groupCoordinatorConfig.offsetsLoadBufferSize,
config.groupCoordinatorConfig.offsetsRetentionMs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class TransactionMarkerChannelManagerTest {
private val time = new MockTime

private val channelManager = new TransactionMarkerChannelManager(
KafkaConfig.fromProps(TestUtils.createBrokerConfig(1, "localhost:2181")),
KafkaConfig.fromProps(TestUtils.createBrokerConfig(1)),
metadataCache,
networkClient,
txnStateManager,
Expand All @@ -98,7 +98,7 @@ class TransactionMarkerChannelManagerTest {
val mockMetricsGroupCtor = mockConstruction(classOf[KafkaMetricsGroup])
try {
val transactionMarkerChannelManager = new TransactionMarkerChannelManager(
KafkaConfig.fromProps(TestUtils.createBrokerConfig(1, "localhost:2181")),
KafkaConfig.fromProps(TestUtils.createBrokerConfig(1)),
metadataCache,
networkClient,
txnStateManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MetricsDuringTopicCreationDeletionTest extends KafkaServerTestHarness with

@volatile private var running = true

override def generateConfigs = TestUtils.createBrokerConfigs(nodesNum, null)
override def generateConfigs = TestUtils.createBrokerConfigs(nodesNum)
.map(KafkaConfig.fromProps(_, overridingProps))

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.junit.jupiter.params.provider.ValueSource
class MinIsrConfigTest extends KafkaServerTestHarness {
val overridingProps = new Properties()
overridingProps.put(ServerLogConfigs.MIN_IN_SYNC_REPLICAS_CONFIG, "5")
def generateConfigs: Seq[KafkaConfig] = TestUtils.createBrokerConfigs(1, null).map(KafkaConfig.fromProps(_, overridingProps))
def generateConfigs: Seq[KafkaConfig] = TestUtils.createBrokerConfigs(1).map(KafkaConfig.fromProps(_, overridingProps))

@ParameterizedTest
@ValueSource(strings = Array("kraft"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class UncleanLeaderElectionTest extends QuorumTestHarness {
override def setUp(testInfo: TestInfo): Unit = {
super.setUp(testInfo)

configProps1 = createBrokerConfig(brokerId1, null)
configProps2 = createBrokerConfig(brokerId2, null)
configProps1 = createBrokerConfig(brokerId1)
configProps2 = createBrokerConfig(brokerId2)

for (configProps <- List(configProps1, configProps2)) {
configProps.put("controlled.shutdown.enable", enableControlledShutdown.toString)
Expand Down
Loading