You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ij...@apache.org on 2017/12/27 16:30:11 UTC
[kafka] branch trunk updated: MINOR: Update test classes to use
KafkaZkClient/AdminZkClient methods (#4353)
This is an automated email from the ASF dual-hosted git repository.
ijuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 89b245b MINOR: Update test classes to use KafkaZkClient/AdminZkClient methods (#4353)
89b245b is described below
commit 89b245baa7963e908d5f22d6f53c34f14690af67
Author: Manikumar Reddy O <ma...@gmail.com>
AuthorDate: Wed Dec 27 22:00:02 2017 +0530
MINOR: Update test classes to use KafkaZkClient/AdminZkClient methods (#4353)
---
.../admin/ReassignPartitionsIntegrationTest.scala | 2 +-
.../kafka/api/AdminClientIntegrationTest.scala | 40 +++---
.../AdminClientWithPoliciesIntegrationTest.scala | 14 +-
.../kafka/api/AuthorizerIntegrationTest.scala | 12 +-
.../integration/kafka/api/BaseConsumerTest.scala | 2 +-
.../kafka/api/BaseProducerSendTest.scala | 20 +--
.../integration/kafka/api/BaseQuotaTest.scala | 2 +-
.../integration/kafka/api/ConsumerBounceTest.scala | 6 +-
.../kafka/api/EndToEndAuthorizationTest.scala | 2 +-
.../kafka/api/EndToEndClusterIdTest.scala | 2 +-
.../kafka/api/IntegrationTestHarness.scala | 2 +-
.../kafka/api/LegacyAdminClientTest.scala | 2 +-
.../integration/kafka/api/LogAppendTimeTest.scala | 2 +-
.../scala/integration/kafka/api/MetricsTest.scala | 2 +-
.../kafka/api/PlaintextConsumerTest.scala | 46 +++----
.../kafka/api/PlaintextProducerSendTest.scala | 4 +-
.../integration/kafka/api/ProducerBounceTest.scala | 4 +-
.../kafka/api/ProducerCompressionTest.scala | 2 +-
.../kafka/api/ProducerFailureHandlingTest.scala | 18 +--
.../kafka/api/RackAwareAutoTopicCreationTest.scala | 4 +-
.../SaslClientsWithInvalidCredentialsTest.scala | 7 +-
.../SaslScramSslEndToEndAuthorizationTest.scala | 2 +-
.../kafka/api/TransactionsBounceTest.scala | 6 +-
.../integration/kafka/api/TransactionsTest.scala | 8 +-
...ListenersWithSameSecurityProtocolBaseTest.scala | 4 +-
.../ReplicaFetcherThreadFatalErrorTest.scala | 10 +-
.../other/kafka/ReplicationQuotasTestRig.scala | 11 +-
.../scala/unit/kafka/admin/AddPartitionsTest.scala | 25 ++--
.../test/scala/unit/kafka/admin/AdminTest.scala | 17 ++-
.../unit/kafka/admin/DeleteConsumerGroupTest.scala | 22 +--
.../scala/unit/kafka/admin/DeleteTopicTest.scala | 59 ++++-----
.../kafka/admin/DescribeConsumerGroupTest.scala | 58 ++++----
.../admin/ReassignPartitionsClusterTest.scala | 147 ++++++++++-----------
.../scala/unit/kafka/admin/TopicCommandTest.scala | 26 ++--
.../unit/kafka/consumer/ConsumerIteratorTest.scala | 2 +-
.../consumer/ZookeeperConsumerConnectorTest.scala | 30 ++---
.../controller/ControllerIntegrationTest.scala | 26 ++--
.../kafka/integration/AutoOffsetResetTest.scala | 2 +-
.../scala/unit/kafka/integration/FetcherTest.scala | 2 +-
.../unit/kafka/integration/PrimitiveApiTest.scala | 8 +-
.../unit/kafka/integration/TopicMetadataTest.scala | 10 +-
.../integration/UncleanLeaderElectionTest.scala | 12 +-
.../consumer/ZookeeperConsumerConnectorTest.scala | 2 +-
.../scala/unit/kafka/metrics/MetricsTest.scala | 8 +-
.../scala/unit/kafka/producer/ProducerTest.scala | 15 ++-
.../unit/kafka/producer/SyncProducerTest.scala | 10 +-
.../server/AddPartitionsToTxnRequestTest.scala | 2 +-
.../unit/kafka/server/AdvertiseBrokerTest.scala | 6 +-
.../server/AlterReplicaLogDirsRequestTest.scala | 4 +-
.../kafka/server/CreateTopicsRequestTest.scala | 2 +-
.../server/CreateTopicsRequestWithPolicyTest.scala | 2 +-
.../kafka/server/DeleteTopicsRequestTest.scala | 10 +-
.../kafka/server/DescribeLogDirsRequestTest.scala | 2 +-
.../kafka/server/DynamicConfigChangeTest.scala | 3 +-
.../unit/kafka/server/EdgeCaseRequestTest.scala | 2 +-
.../scala/unit/kafka/server/FetchRequestTest.scala | 2 +-
.../unit/kafka/server/LeaderElectionTest.scala | 8 +-
.../unit/kafka/server/LogDirFailureTest.scala | 7 +-
.../scala/unit/kafka/server/LogOffsetTest.scala | 2 +-
.../scala/unit/kafka/server/LogRecoveryTest.scala | 14 +-
.../unit/kafka/server/MetadataRequestTest.scala | 22 +--
.../scala/unit/kafka/server/OffsetCommitTest.scala | 20 +--
.../unit/kafka/server/ProduceRequestTest.scala | 2 +-
.../scala/unit/kafka/server/ReplicaFetchTest.scala | 2 +-
.../scala/unit/kafka/server/RequestQuotaTest.scala | 2 +-
.../kafka/server/ServerGenerateClusterIdTest.scala | 4 +-
.../unit/kafka/server/ServerShutdownTest.scala | 4 +-
.../unit/kafka/server/ServerStartupTest.scala | 2 +-
...chDrivenReplicationProtocolAcceptanceTest.scala | 6 +-
.../server/epoch/LeaderEpochIntegrationTest.scala | 2 +-
.../unit/kafka/utils/ReplicationUtilsTest.scala | 2 +-
.../test/scala/unit/kafka/utils/TestUtils.scala | 49 ++++---
.../scala/unit/kafka/zk/AdminZkClientTest.scala | 8 +-
73 files changed, 455 insertions(+), 453 deletions(-)
diff --git a/core/src/test/scala/integration/kafka/admin/ReassignPartitionsIntegrationTest.scala b/core/src/test/scala/integration/kafka/admin/ReassignPartitionsIntegrationTest.scala
index 3c0c537..12bf980 100644
--- a/core/src/test/scala/integration/kafka/admin/ReassignPartitionsIntegrationTest.scala
+++ b/core/src/test/scala/integration/kafka/admin/ReassignPartitionsIntegrationTest.scala
@@ -21,7 +21,7 @@ class ReassignPartitionsIntegrationTest extends ZooKeeperTestHarness with RackAw
@Test
def testRackAwareReassign() {
val rackInfo = Map(0 -> "rack1", 1 -> "rack2", 2 -> "rack2", 3 -> "rack1", 4 -> "rack3", 5 -> "rack3")
- TestUtils.createBrokersInZk(toBrokerMetadata(rackInfo), zkUtils)
+ TestUtils.createBrokersInZk(toBrokerMetadata(rackInfo), zkClient)
val numPartitions = 18
val replicationFactor = 3
diff --git a/core/src/test/scala/integration/kafka/api/AdminClientIntegrationTest.scala b/core/src/test/scala/integration/kafka/api/AdminClientIntegrationTest.scala
index 14e26df..daeb82a 100644
--- a/core/src/test/scala/integration/kafka/api/AdminClientIntegrationTest.scala
+++ b/core/src/test/scala/integration/kafka/api/AdminClientIntegrationTest.scala
@@ -28,7 +28,7 @@ import org.apache.kafka.common.utils.{Time, Utils}
import kafka.log.LogConfig
import kafka.server.{Defaults, KafkaConfig, KafkaServer}
import org.apache.kafka.clients.admin._
-import kafka.utils.{Logging, TestUtils, ZkUtils}
+import kafka.utils.{Logging, TestUtils}
import kafka.utils.Implicits._
import org.apache.kafka.clients.admin.NewTopic
import org.apache.kafka.clients.consumer.KafkaConsumer
@@ -48,6 +48,8 @@ import scala.util.Random
import scala.collection.JavaConverters._
import java.lang.{Long => JLong}
+import kafka.zk.KafkaZkClient
+
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
@@ -229,7 +231,7 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging {
val results = client.describeTopics(Seq(nonExistingTopic, existingTopic).asJava).values
assertEquals(existingTopic, results.get(existingTopic).get.name)
intercept[ExecutionException](results.get(nonExistingTopic).get).getCause.isInstanceOf[UnknownTopicOrPartitionException]
- assertEquals(None, zkUtils.getTopicPartitionCount(nonExistingTopic))
+ assertEquals(None, zkClient.getTopicPartitionCount(nonExistingTopic))
}
@Test
@@ -253,7 +255,7 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging {
def testDescribeLogDirs(): Unit = {
client = AdminClient.create(createConfig())
val topic = "topic"
- val leaderByPartition = TestUtils.createTopic(zkUtils, topic, 10, 1, servers, new Properties())
+ val leaderByPartition = TestUtils.createTopic(zkClient, topic, 10, 1, servers, new Properties())
val partitionsByBroker = leaderByPartition.groupBy { case (partitionId, leaderId) => leaderId }.mapValues(_.keys.toSeq)
val brokers = (0 until serverCount).map(Integer.valueOf)
val logDirInfosByBroker = client.describeLogDirs(brokers.asJava).all.get
@@ -279,7 +281,7 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging {
def testDescribeReplicaLogDirs(): Unit = {
client = AdminClient.create(createConfig())
val topic = "topic"
- val leaderByPartition = TestUtils.createTopic(zkUtils, topic, 10, 1, servers, new Properties())
+ val leaderByPartition = TestUtils.createTopic(zkClient, topic, 10, 1, servers, new Properties())
val replicas = leaderByPartition.map { case (partition, brokerId) => new TopicPartitionReplica(topic, partition, brokerId) }.toSeq
val replicaDirInfos = client.describeReplicaLogDirs(replicas.asJavaCollection).all.get
@@ -315,7 +317,7 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging {
assertTrue(exception.getCause.isInstanceOf[ReplicaNotAvailableException])
}
- TestUtils.createTopic(zkUtils, topic, 1, serverCount, servers, new Properties)
+ TestUtils.createTopic(zkClient, topic, 1, serverCount, servers, new Properties)
servers.foreach { server =>
val logDir = server.logManager.getLog(tp).get.dir.getParent
assertEquals(firstReplicaAssignment(new TopicPartitionReplica(topic, 0, server.config.brokerId)), logDir)
@@ -387,11 +389,11 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging {
val topicConfig1 = new Properties
topicConfig1.setProperty(LogConfig.MaxMessageBytesProp, "500000")
topicConfig1.setProperty(LogConfig.RetentionMsProp, "60000000")
- TestUtils.createTopic(zkUtils, topic1, 1, 1, servers, topicConfig1)
+ TestUtils.createTopic(zkClient, topic1, 1, 1, servers, topicConfig1)
val topic2 = "describe-alter-configs-topic-2"
val topicResource2 = new ConfigResource(ConfigResource.Type.TOPIC, topic2)
- TestUtils.createTopic(zkUtils, topic2, 1, 1, servers, new Properties)
+ TestUtils.createTopic(zkClient, topic2, 1, 1, servers, new Properties)
// Describe topics and broker
val brokerResource1 = new ConfigResource(ConfigResource.Type.BROKER, servers(1).config.brokerId.toString)
@@ -445,7 +447,7 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging {
assertEquals(servers(2).config.logCleanerThreads.toString,
configs.get(brokerResource2).get(KafkaConfig.LogCleanerThreadsProp).value)
- checkValidAlterConfigs(zkUtils, servers, client, topicResource1, topicResource2)
+ checkValidAlterConfigs(servers, client, topicResource1, topicResource2)
}
@Test
@@ -454,10 +456,10 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging {
// Create topics
val topic1 = "create-partitions-topic-1"
- TestUtils.createTopic(zkUtils, topic1, 1, 1, servers, new Properties)
+ TestUtils.createTopic(zkClient, topic1, 1, 1, servers, new Properties)
val topic2 = "create-partitions-topic-2"
- TestUtils.createTopic(zkUtils, topic2, 1, 2, servers, new Properties)
+ TestUtils.createTopic(zkClient, topic2, 1, 2, servers, new Properties)
// assert that both the topics have 1 partition
assertEquals(1, client.describeTopics(Set(topic1).asJava).values.get(topic1).get.partitions.size)
@@ -712,7 +714,7 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging {
@Test
def testSeekAfterDeleteRecords(): Unit = {
- TestUtils.createTopic(zkUtils, topic, 2, serverCount, servers)
+ TestUtils.createTopic(zkClient, topic, 2, serverCount, servers)
client = AdminClient.create(createConfig)
@@ -739,7 +741,7 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging {
@Test
@Ignore // Disabled temporarily until flakiness is resolved
def testLogStartOffsetCheckpoint(): Unit = {
- TestUtils.createTopic(zkUtils, topic, 2, serverCount, servers)
+ TestUtils.createTopic(zkClient, topic, 2, serverCount, servers)
client = AdminClient.create(createConfig)
@@ -778,7 +780,7 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging {
@Test
def testLogStartOffsetAfterDeleteRecords(): Unit = {
- TestUtils.createTopic(zkUtils, topic, 2, serverCount, servers)
+ TestUtils.createTopic(zkClient, topic, 2, serverCount, servers)
client = AdminClient.create(createConfig)
@@ -797,7 +799,7 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging {
@Test
def testOffsetsForTimesAfterDeleteRecords(): Unit = {
- TestUtils.createTopic(zkUtils, topic, 2, serverCount, servers)
+ TestUtils.createTopic(zkClient, topic, 2, serverCount, servers)
client = AdminClient.create(createConfig)
@@ -841,7 +843,7 @@ class AdminClientIntegrationTest extends IntegrationTestHarness with Logging {
@Test
def testInvalidAlterConfigs(): Unit = {
client = AdminClient.create(createConfig)
- checkInvalidAlterConfigs(zkUtils, servers, client)
+ checkInvalidAlterConfigs(zkClient, servers, client)
}
val ACL1 = new AclBinding(new Resource(ResourceType.TOPIC, "mytopic3"),
@@ -940,7 +942,7 @@ object AdminClientIntegrationTest {
import org.scalatest.Assertions._
- def checkValidAlterConfigs(zkUtils: ZkUtils, servers: Seq[KafkaServer], client: AdminClient,
+ def checkValidAlterConfigs(servers: Seq[KafkaServer], client: AdminClient,
topicResource1: ConfigResource, topicResource2: ConfigResource): Unit = {
// Alter topics
var topicConfigEntries1 = Seq(
@@ -1003,15 +1005,15 @@ object AdminClientIntegrationTest {
assertEquals("0.9", configs.get(topicResource2).get(LogConfig.MinCleanableDirtyRatioProp).value)
}
- def checkInvalidAlterConfigs(zkUtils: ZkUtils, servers: Seq[KafkaServer], client: AdminClient): Unit = {
+ def checkInvalidAlterConfigs(zkClient: KafkaZkClient, servers: Seq[KafkaServer], client: AdminClient): Unit = {
// Create topics
val topic1 = "invalid-alter-configs-topic-1"
val topicResource1 = new ConfigResource(ConfigResource.Type.TOPIC, topic1)
- TestUtils.createTopic(zkUtils, topic1, 1, 1, servers, new Properties())
+ TestUtils.createTopic(zkClient, topic1, 1, 1, servers, new Properties())
val topic2 = "invalid-alter-configs-topic-2"
val topicResource2 = new ConfigResource(ConfigResource.Type.TOPIC, topic2)
- TestUtils.createTopic(zkUtils, topic2, 1, 1, servers, new Properties)
+ TestUtils.createTopic(zkClient, topic2, 1, 1, servers, new Properties)
val topicConfigEntries1 = Seq(
new ConfigEntry(LogConfig.MinCleanableDirtyRatioProp, "1.1"), // this value is invalid as it's above 1.0
diff --git a/core/src/test/scala/integration/kafka/api/AdminClientWithPoliciesIntegrationTest.scala b/core/src/test/scala/integration/kafka/api/AdminClientWithPoliciesIntegrationTest.scala
index 8e8e825..a381c84 100644
--- a/core/src/test/scala/integration/kafka/api/AdminClientWithPoliciesIntegrationTest.scala
+++ b/core/src/test/scala/integration/kafka/api/AdminClientWithPoliciesIntegrationTest.scala
@@ -76,19 +76,19 @@ class AdminClientWithPoliciesIntegrationTest extends KafkaServerTestHarness with
val topicConfig1 = new Properties
topicConfig1.setProperty(LogConfig.MaxMessageBytesProp, "500000")
topicConfig1.setProperty(LogConfig.RetentionMsProp, "60000000")
- TestUtils.createTopic(zkUtils, topic1, 1, 1, servers, topicConfig1)
+ TestUtils.createTopic(zkClient, topic1, 1, 1, servers, topicConfig1)
val topic2 = "describe-alter-configs-topic-2"
val topicResource2 = new ConfigResource(ConfigResource.Type.TOPIC, topic2)
- TestUtils.createTopic(zkUtils, topic2, 1, 1, servers, new Properties)
+ TestUtils.createTopic(zkClient, topic2, 1, 1, servers, new Properties)
- AdminClientIntegrationTest.checkValidAlterConfigs(zkUtils, servers, client, topicResource1, topicResource2)
+ AdminClientIntegrationTest.checkValidAlterConfigs(servers, client, topicResource1, topicResource2)
}
@Test
def testInvalidAlterConfigs(): Unit = {
client = AdminClient.create(createConfig)
- AdminClientIntegrationTest.checkInvalidAlterConfigs(zkUtils, servers, client)
+ AdminClientIntegrationTest.checkInvalidAlterConfigs(zkClient, servers, client)
}
@Test
@@ -98,15 +98,15 @@ class AdminClientWithPoliciesIntegrationTest extends KafkaServerTestHarness with
// Create topics
val topic1 = "invalid-alter-configs-due-to-policy-topic-1"
val topicResource1 = new ConfigResource(ConfigResource.Type.TOPIC, topic1)
- TestUtils.createTopic(zkUtils, topic1, 1, 1, servers, new Properties())
+ TestUtils.createTopic(zkClient, topic1, 1, 1, servers, new Properties())
val topic2 = "invalid-alter-configs-due-to-policy-topic-2"
val topicResource2 = new ConfigResource(ConfigResource.Type.TOPIC, topic2)
- TestUtils.createTopic(zkUtils, topic2, 1, 1, servers, new Properties)
+ TestUtils.createTopic(zkClient, topic2, 1, 1, servers, new Properties)
val topic3 = "invalid-alter-configs-due-to-policy-topic-3"
val topicResource3 = new ConfigResource(ConfigResource.Type.TOPIC, topic3)
- TestUtils.createTopic(zkUtils, topic3, 1, 1, servers, new Properties)
+ TestUtils.createTopic(zkClient, topic3, 1, 1, servers, new Properties)
val topicConfigEntries1 = Seq(
new ConfigEntry(LogConfig.MinCleanableDirtyRatioProp, "0.9"),
diff --git a/core/src/test/scala/integration/kafka/api/AuthorizerIntegrationTest.scala b/core/src/test/scala/integration/kafka/api/AuthorizerIntegrationTest.scala
index b701f13..4230225 100644
--- a/core/src/test/scala/integration/kafka/api/AuthorizerIntegrationTest.scala
+++ b/core/src/test/scala/integration/kafka/api/AuthorizerIntegrationTest.scala
@@ -241,14 +241,14 @@ class AuthorizerIntegrationTest extends BaseRequestTest {
consumers += TestUtils.createNewConsumer(TestUtils.getBrokerListStrFromServers(servers), groupId = group, securityProtocol = SecurityProtocol.PLAINTEXT)
// create the consumer offset topic
- TestUtils.createTopic(zkUtils, GROUP_METADATA_TOPIC_NAME,
+ TestUtils.createTopic(zkClient, GROUP_METADATA_TOPIC_NAME,
1,
1,
servers,
servers.head.groupCoordinator.offsetsTopicConfigs)
// create the test topic with all the brokers as replicas
- TestUtils.createTopic(zkUtils, topic, 1, 1, this.servers)
- TestUtils.createTopic(zkUtils, deleteTopic, 1, 1, this.servers)
+ TestUtils.createTopic(zkClient, topic, 1, 1, this.servers)
+ TestUtils.createTopic(zkClient, deleteTopic, 1, 1, this.servers)
}
@After
@@ -447,9 +447,9 @@ class AuthorizerIntegrationTest extends BaseRequestTest {
@Test
def testAuthorizationWithTopicNotExisting() {
adminZkClient.deleteTopic(topic)
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, servers)
adminZkClient.deleteTopic(deleteTopic)
- TestUtils.verifyTopicDeletion(zkUtils, deleteTopic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, deleteTopic, 1, servers)
val requestKeyToRequest = mutable.LinkedHashMap[ApiKeys, AbstractRequest](
ApiKeys.METADATA -> createMetadataRequest(allowAutoTopicCreation = false),
@@ -680,7 +680,7 @@ class AuthorizerIntegrationTest extends BaseRequestTest {
// create an unmatched topic
val unmatchedTopic = "unmatched"
- TestUtils.createTopic(zkUtils, unmatchedTopic, 1, 1, this.servers)
+ TestUtils.createTopic(zkClient, unmatchedTopic, 1, 1, this.servers)
addAndVerifyAcls(Set(new Acl(KafkaPrincipal.ANONYMOUS, Allow, Acl.WildCardHost, Write)), new Resource(Topic, unmatchedTopic))
sendRecords(1, new TopicPartition(unmatchedTopic, part))
removeAllAcls()
diff --git a/core/src/test/scala/integration/kafka/api/BaseConsumerTest.scala b/core/src/test/scala/integration/kafka/api/BaseConsumerTest.scala
index e124468..a11dd8c 100644
--- a/core/src/test/scala/integration/kafka/api/BaseConsumerTest.scala
+++ b/core/src/test/scala/integration/kafka/api/BaseConsumerTest.scala
@@ -68,7 +68,7 @@ abstract class BaseConsumerTest extends IntegrationTestHarness {
super.setUp()
// create the test topic with all the brokers as replicas
- TestUtils.createTopic(this.zkUtils, topic, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic, 2, serverCount, this.servers)
}
@Test
diff --git a/core/src/test/scala/integration/kafka/api/BaseProducerSendTest.scala b/core/src/test/scala/integration/kafka/api/BaseProducerSendTest.scala
index 0badda9..579c8bb 100644
--- a/core/src/test/scala/integration/kafka/api/BaseProducerSendTest.scala
+++ b/core/src/test/scala/integration/kafka/api/BaseProducerSendTest.scala
@@ -123,7 +123,7 @@ abstract class BaseProducerSendTest extends KafkaServerTestHarness {
try {
// create topic
- TestUtils.createTopic(zkUtils, topic, 1, 2, servers)
+ TestUtils.createTopic(zkClient, topic, 1, 2, servers)
// send a normal record
val record0 = new ProducerRecord[Array[Byte], Array[Byte]](topic, partition, "key".getBytes(StandardCharsets.UTF_8),
@@ -184,7 +184,7 @@ abstract class BaseProducerSendTest extends KafkaServerTestHarness {
timeoutMs: Long = 20000L) {
val partition = 0
try {
- TestUtils.createTopic(zkUtils, topic, 1, 2, servers)
+ TestUtils.createTopic(zkClient, topic, 1, 2, servers)
val futures = for (i <- 1 to numRecords) yield {
val record = new ProducerRecord(topic, partition, s"key$i".getBytes(StandardCharsets.UTF_8),
@@ -239,7 +239,7 @@ abstract class BaseProducerSendTest extends KafkaServerTestHarness {
topicProps.setProperty(LogConfig.MessageTimestampTypeProp, "LogAppendTime")
else
topicProps.setProperty(LogConfig.MessageTimestampTypeProp, "CreateTime")
- TestUtils.createTopic(zkUtils, topic, 1, 2, servers, topicProps)
+ TestUtils.createTopic(zkClient, topic, 1, 2, servers, topicProps)
val recordAndFutures = for (i <- 1 to numRecords) yield {
val record = new ProducerRecord(topic, partition, baseTimestamp + i, s"key$i".getBytes(StandardCharsets.UTF_8),
@@ -271,7 +271,7 @@ abstract class BaseProducerSendTest extends KafkaServerTestHarness {
try {
// create topic
- TestUtils.createTopic(zkUtils, topic, 1, 2, servers)
+ TestUtils.createTopic(zkClient, topic, 1, 2, servers)
// non-blocking send a list of records
val record0 = new ProducerRecord[Array[Byte], Array[Byte]](topic, null, "key".getBytes(StandardCharsets.UTF_8),
@@ -303,7 +303,7 @@ abstract class BaseProducerSendTest extends KafkaServerTestHarness {
val producer = createProducer(brokerList)
try {
- TestUtils.createTopic(zkUtils, topic, 2, 2, servers)
+ TestUtils.createTopic(zkClient, topic, 2, 2, servers)
val partition = 1
val now = System.currentTimeMillis()
@@ -348,7 +348,7 @@ abstract class BaseProducerSendTest extends KafkaServerTestHarness {
val producer = createProducer(brokerList)
// create topic
- TestUtils.createTopic(zkUtils, topic, 1, 2, servers)
+ TestUtils.createTopic(zkClient, topic, 1, 2, servers)
val partition0 = 0
var futures0 = (1 to numRecords).map { i =>
@@ -371,7 +371,7 @@ abstract class BaseProducerSendTest extends KafkaServerTestHarness {
case _: KafkaException => // this is ok
}
- val existingAssignment = zkUtils.getReplicaAssignmentForTopics(List(topic)).map {
+ val existingAssignment = zkClient.getReplicaAssignmentForTopics(Set(topic)).map {
case (topicPartition, replicas) => topicPartition.partition -> replicas
}
adminZkClient.addPartitions(topic, existingAssignment, adminZkClient.getBrokerMetadatas(), 2)
@@ -410,7 +410,7 @@ abstract class BaseProducerSendTest extends KafkaServerTestHarness {
def testFlush() {
val producer = createProducer(brokerList, lingerMs = Long.MaxValue)
try {
- TestUtils.createTopic(zkUtils, topic, 2, 2, servers)
+ TestUtils.createTopic(zkClient, topic, 2, 2, servers)
val record = new ProducerRecord[Array[Byte], Array[Byte]](topic,
"value".getBytes(StandardCharsets.UTF_8))
for (_ <- 0 until 50) {
@@ -429,7 +429,7 @@ abstract class BaseProducerSendTest extends KafkaServerTestHarness {
*/
@Test
def testCloseWithZeroTimeoutFromCallerThread() {
- TestUtils.createTopic(zkUtils, topic, 2, 2, servers)
+ TestUtils.createTopic(zkClient, topic, 2, 2, servers)
val partition = 0
consumer.assign(List(new TopicPartition(topic, partition)).asJava)
val record0 = new ProducerRecord[Array[Byte], Array[Byte]](topic, partition, null,
@@ -459,7 +459,7 @@ abstract class BaseProducerSendTest extends KafkaServerTestHarness {
*/
@Test
def testCloseWithZeroTimeoutFromSenderThread() {
- TestUtils.createTopic(zkUtils, topic, 1, 2, servers)
+ TestUtils.createTopic(zkClient, topic, 1, 2, servers)
val partition = 0
consumer.assign(List(new TopicPartition(topic, partition)).asJava)
val record = new ProducerRecord[Array[Byte], Array[Byte]](topic, partition, null, "value".getBytes(StandardCharsets.UTF_8))
diff --git a/core/src/test/scala/integration/kafka/api/BaseQuotaTest.scala b/core/src/test/scala/integration/kafka/api/BaseQuotaTest.scala
index d821f52..257308c 100644
--- a/core/src/test/scala/integration/kafka/api/BaseQuotaTest.scala
+++ b/core/src/test/scala/integration/kafka/api/BaseQuotaTest.scala
@@ -72,7 +72,7 @@ abstract class BaseQuotaTest extends IntegrationTestHarness {
super.setUp()
val numPartitions = 1
- val leaders = TestUtils.createTopic(zkUtils, topic1, numPartitions, serverCount, servers)
+ val leaders = TestUtils.createTopic(zkClient, topic1, numPartitions, serverCount, servers)
leaderNode = if (leaders(0) == servers.head.config.brokerId) servers.head else servers(1)
followerNode = if (leaders(0) != servers.head.config.brokerId) servers.head else servers(1)
}
diff --git a/core/src/test/scala/integration/kafka/api/ConsumerBounceTest.scala b/core/src/test/scala/integration/kafka/api/ConsumerBounceTest.scala
index 0b42118..5fca9b4 100644
--- a/core/src/test/scala/integration/kafka/api/ConsumerBounceTest.scala
+++ b/core/src/test/scala/integration/kafka/api/ConsumerBounceTest.scala
@@ -69,7 +69,7 @@ class ConsumerBounceTest extends IntegrationTestHarness with Logging {
super.setUp()
// create the test topic with all the brokers as replicas
- TestUtils.createTopic(this.zkUtils, topic, 1, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic, 1, serverCount, this.servers)
}
@After
@@ -173,7 +173,7 @@ class ConsumerBounceTest extends IntegrationTestHarness with Logging {
val consumer = this.consumers.head
consumer.subscribe(Collections.singleton(newtopic))
executor.schedule(new Runnable {
- def run() = TestUtils.createTopic(zkUtils, newtopic, serverCount, serverCount, servers)
+ def run() = TestUtils.createTopic(zkClient, newtopic, serverCount, serverCount, servers)
}, 2, TimeUnit.SECONDS)
consumer.poll(0)
@@ -288,7 +288,7 @@ class ConsumerBounceTest extends IntegrationTestHarness with Logging {
@Test
def testCloseDuringRebalance() {
val topic = "closetest"
- TestUtils.createTopic(this.zkUtils, topic, 10, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic, 10, serverCount, this.servers)
this.consumerConfig.setProperty(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, "60000")
this.consumerConfig.setProperty(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, "1000")
this.consumerConfig.setProperty(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false")
diff --git a/core/src/test/scala/integration/kafka/api/EndToEndAuthorizationTest.scala b/core/src/test/scala/integration/kafka/api/EndToEndAuthorizationTest.scala
index 720d8b6..d997db5 100644
--- a/core/src/test/scala/integration/kafka/api/EndToEndAuthorizationTest.scala
+++ b/core/src/test/scala/integration/kafka/api/EndToEndAuthorizationTest.scala
@@ -161,7 +161,7 @@ abstract class EndToEndAuthorizationTest extends IntegrationTestHarness with Sas
TestUtils.waitAndVerifyAcls(TopicBrokerReadAcl, s.apis.authorizer.get, new Resource(Topic, "*"))
}
// create the test topic with all the brokers as replicas
- TestUtils.createTopic(zkUtils, topic, 1, 3, this.servers)
+ TestUtils.createTopic(zkClient, topic, 1, 3, this.servers)
}
override def createNewProducer: KafkaProducer[Array[Byte], Array[Byte]] = {
diff --git a/core/src/test/scala/integration/kafka/api/EndToEndClusterIdTest.scala b/core/src/test/scala/integration/kafka/api/EndToEndClusterIdTest.scala
index fce75b0..8022170 100644
--- a/core/src/test/scala/integration/kafka/api/EndToEndClusterIdTest.scala
+++ b/core/src/test/scala/integration/kafka/api/EndToEndClusterIdTest.scala
@@ -115,7 +115,7 @@ class EndToEndClusterIdTest extends KafkaServerTestHarness {
super.setUp()
MockDeserializer.resetStaticVariables
// create the consumer offset topic
- TestUtils.createTopic(this.zkUtils, topic, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic, 2, serverCount, this.servers)
}
@Test
diff --git a/core/src/test/scala/integration/kafka/api/IntegrationTestHarness.scala b/core/src/test/scala/integration/kafka/api/IntegrationTestHarness.scala
index 9c1b479..1b45acb 100644
--- a/core/src/test/scala/integration/kafka/api/IntegrationTestHarness.scala
+++ b/core/src/test/scala/integration/kafka/api/IntegrationTestHarness.scala
@@ -84,7 +84,7 @@ abstract class IntegrationTestHarness extends KafkaServerTestHarness {
consumers += createNewConsumer
}
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
}
def clientSecurityProps(certAlias: String): Properties = {
diff --git a/core/src/test/scala/integration/kafka/api/LegacyAdminClientTest.scala b/core/src/test/scala/integration/kafka/api/LegacyAdminClientTest.scala
index 2839137..774db18 100644
--- a/core/src/test/scala/integration/kafka/api/LegacyAdminClientTest.scala
+++ b/core/src/test/scala/integration/kafka/api/LegacyAdminClientTest.scala
@@ -69,7 +69,7 @@ class LegacyAdminClientTest extends IntegrationTestHarness with Logging {
override def setUp() {
super.setUp()
client = AdminClient.createSimplePlaintext(this.brokerList)
- TestUtils.createTopic(this.zkUtils, topic, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic, 2, serverCount, this.servers)
}
@After
diff --git a/core/src/test/scala/integration/kafka/api/LogAppendTimeTest.scala b/core/src/test/scala/integration/kafka/api/LogAppendTimeTest.scala
index 4a97bea..9c5a9c8 100644
--- a/core/src/test/scala/integration/kafka/api/LogAppendTimeTest.scala
+++ b/core/src/test/scala/integration/kafka/api/LogAppendTimeTest.scala
@@ -48,7 +48,7 @@ class LogAppendTimeTest extends IntegrationTestHarness {
@Before
override def setUp() {
super.setUp()
- TestUtils.createTopic(zkUtils, topic, servers = servers)
+ TestUtils.createTopic(zkClient, topic, servers = servers)
}
@Test
diff --git a/core/src/test/scala/integration/kafka/api/MetricsTest.scala b/core/src/test/scala/integration/kafka/api/MetricsTest.scala
index 167b6a6..6e95973 100644
--- a/core/src/test/scala/integration/kafka/api/MetricsTest.scala
+++ b/core/src/test/scala/integration/kafka/api/MetricsTest.scala
@@ -71,7 +71,7 @@ class MetricsTest extends IntegrationTestHarness with SaslSetup {
val topic = "topicWithOldMessageFormat"
val props = new Properties
props.setProperty(LogConfig.MessageFormatVersionProp, "0.9.0")
- TestUtils.createTopic(this.zkUtils, topic, numPartitions = 1, replicationFactor = 1, this.servers, props)
+ TestUtils.createTopic(zkClient, topic, numPartitions = 1, replicationFactor = 1, this.servers, props)
val tp = new TopicPartition(topic, 0)
// Produce and consume some records
diff --git a/core/src/test/scala/integration/kafka/api/PlaintextConsumerTest.scala b/core/src/test/scala/integration/kafka/api/PlaintextConsumerTest.scala
index aad9b6a..65b2865 100644
--- a/core/src/test/scala/integration/kafka/api/PlaintextConsumerTest.scala
+++ b/core/src/test/scala/integration/kafka/api/PlaintextConsumerTest.scala
@@ -325,17 +325,17 @@ class PlaintextConsumerTest extends BaseConsumerTest {
sendRecords(numRecords)
val topic1 = "tblablac" // matches subscribed pattern
- TestUtils.createTopic(this.zkUtils, topic1, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic1, 2, serverCount, this.servers)
sendRecords(1000, new TopicPartition(topic1, 0))
sendRecords(1000, new TopicPartition(topic1, 1))
val topic2 = "tblablak" // does not match subscribed pattern
- TestUtils.createTopic(this.zkUtils, topic2, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic2, 2, serverCount, this.servers)
sendRecords(1000, new TopicPartition(topic2, 0))
sendRecords(1000, new TopicPartition(topic2, 1))
val topic3 = "tblab1" // does not match subscribed pattern
- TestUtils.createTopic(this.zkUtils, topic3, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic3, 2, serverCount, this.servers)
sendRecords(1000, new TopicPartition(topic3, 0))
sendRecords(1000, new TopicPartition(topic3, 1))
@@ -357,7 +357,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
}, s"Expected partitions ${subscriptions.asJava} but actually got ${this.consumers.head.assignment()}")
val topic4 = "tsomec" // matches subscribed pattern
- TestUtils.createTopic(this.zkUtils, topic4, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic4, 2, serverCount, this.servers)
sendRecords(1000, new TopicPartition(topic4, 0))
sendRecords(1000, new TopicPartition(topic4, 1))
@@ -396,7 +396,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
// the first topic ('topic') matches first subscription pattern only
val fooTopic = "foo" // matches both subscription patterns
- TestUtils.createTopic(this.zkUtils, fooTopic, 1, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, fooTopic, 1, serverCount, this.servers)
sendRecords(1000, new TopicPartition(fooTopic, 0))
assertEquals(0, consumer0.assignment().size)
@@ -416,7 +416,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
}, s"Expected partitions ${subscriptions.asJava} but actually got ${consumer0.assignment()}")
val barTopic = "bar" // matches the next subscription pattern
- TestUtils.createTopic(this.zkUtils, barTopic, 1, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, barTopic, 1, serverCount, this.servers)
sendRecords(1000, new TopicPartition(barTopic, 0))
val pattern2 = Pattern.compile("...") // only 'foo' and 'bar' match this
@@ -453,7 +453,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
sendRecords(numRecords)
val topic1 = "tblablac" // matches the subscription pattern
- TestUtils.createTopic(this.zkUtils, topic1, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic1, 2, serverCount, this.servers)
sendRecords(1000, new TopicPartition(topic1, 0))
sendRecords(1000, new TopicPartition(topic1, 1))
@@ -525,7 +525,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
this.consumers.head.assignment == subscriptions.asJava
}, s"Expected partitions ${subscriptions.asJava} but actually got ${this.consumers.head.assignment}")
- TestUtils.createTopic(this.zkUtils, otherTopic, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, otherTopic, 2, serverCount, this.servers)
this.consumers.head.subscribe(List(topic, otherTopic).asJava)
TestUtils.waitUntilTrue(() => {
this.consumers.head.poll(50)
@@ -536,7 +536,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
@Test
def testShrinkingTopicSubscriptions() {
val otherTopic = "other"
- TestUtils.createTopic(this.zkUtils, otherTopic, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, otherTopic, 2, serverCount, this.servers)
val subscriptions = Set(new TopicPartition(topic, 0), new TopicPartition(topic, 1), new TopicPartition(otherTopic, 0), new TopicPartition(otherTopic, 1))
val shrunkenSubscriptions = Set(new TopicPartition(topic, 0), new TopicPartition(topic, 1))
this.consumers.head.subscribe(List(topic, otherTopic).asJava)
@@ -555,7 +555,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
@Test
def testPartitionsFor() {
val numParts = 2
- TestUtils.createTopic(this.zkUtils, "part-test", numParts, 1, this.servers)
+ TestUtils.createTopic(zkClient, "part-test", numParts, 1, this.servers)
val parts = this.consumers.head.partitionsFor("part-test")
assertNotNull(parts)
assertEquals(2, parts.size)
@@ -788,7 +788,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
val partitionCount = 30
val topics = Seq(topic1, topic2, topic3)
topics.foreach { topicName =>
- TestUtils.createTopic(zkUtils, topicName, partitionCount, serverCount, servers)
+ TestUtils.createTopic(zkClient, topicName, partitionCount, serverCount, servers)
}
val partitions = topics.flatMap { topic =>
@@ -1049,7 +1049,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
@Test
def testAutoCommitIntercept() {
val topic2 = "topic2"
- TestUtils.createTopic(this.zkUtils, topic2, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic2, 2, serverCount, this.servers)
// produce records
val numRecords = 100
@@ -1145,7 +1145,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
val topicName = "testConsumeMessagesWithLogAppendTime"
val topicProps = new Properties()
topicProps.setProperty(LogConfig.MessageTimestampTypeProp, "LogAppendTime")
- TestUtils.createTopic(zkUtils, topicName, 2, 2, servers, topicProps)
+ TestUtils.createTopic(zkClient, topicName, 2, 2, servers, topicProps)
val startTime = System.currentTimeMillis()
val numRecords = 50
@@ -1171,9 +1171,9 @@ class PlaintextConsumerTest extends BaseConsumerTest {
val topic1 = "part-test-topic-1"
val topic2 = "part-test-topic-2"
val topic3 = "part-test-topic-3"
- TestUtils.createTopic(this.zkUtils, topic1, numParts, 1, this.servers)
- TestUtils.createTopic(this.zkUtils, topic2, numParts, 1, this.servers)
- TestUtils.createTopic(this.zkUtils, topic3, numParts, 1, this.servers)
+ TestUtils.createTopic(zkClient, topic1, numParts, 1, this.servers)
+ TestUtils.createTopic(zkClient, topic2, numParts, 1, this.servers)
+ TestUtils.createTopic(zkClient, topic3, numParts, 1, this.servers)
val topics = this.consumers.head.listTopics()
assertNotNull(topics)
@@ -1192,10 +1192,10 @@ class PlaintextConsumerTest extends BaseConsumerTest {
val topic3 = "part-test-topic-3"
val props = new Properties()
props.setProperty(LogConfig.MessageFormatVersionProp, "0.9.0")
- TestUtils.createTopic(this.zkUtils, topic1, numParts, 1, this.servers)
+ TestUtils.createTopic(zkClient, topic1, numParts, 1, this.servers)
// Topic2 is in old message format.
- TestUtils.createTopic(this.zkUtils, topic2, numParts, 1, this.servers, props)
- TestUtils.createTopic(this.zkUtils, topic3, numParts, 1, this.servers)
+ TestUtils.createTopic(zkClient, topic2, numParts, 1, this.servers, props)
+ TestUtils.createTopic(zkClient, topic3, numParts, 1, this.servers)
val consumer = this.consumers.head
@@ -1242,7 +1242,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
createTopicAndSendRecords(topicName = topic0, numPartitions = 2, recordsPerPartition = 100)
val props = new Properties()
props.setProperty(LogConfig.MessageFormatVersionProp, "0.9.0")
- TestUtils.createTopic(this.zkUtils, topic1, numPartitions = 1, replicationFactor = 1, this.servers, props)
+ TestUtils.createTopic(zkClient, topic1, numPartitions = 1, replicationFactor = 1, this.servers, props)
sendRecords(100, new TopicPartition(topic1, 0))
val t0p0 = new TopicPartition(topic0, 0)
@@ -1332,7 +1332,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
@Test
def testAutoCommitOnRebalance() {
val topic2 = "topic2"
- TestUtils.createTopic(this.zkUtils, topic2, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic2, 2, serverCount, this.servers)
this.consumerConfig.setProperty(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true")
val consumer0 = new KafkaConsumer(this.consumerConfig, new ByteArrayDeserializer(), new ByteArrayDeserializer())
@@ -1380,7 +1380,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
def testPerPartitionLagMetricsCleanUpWithSubscribe() {
val numMessages = 1000
val topic2 = "topic2"
- TestUtils.createTopic(this.zkUtils, topic2, 2, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic2, 2, serverCount, this.servers)
// send some messages.
sendRecords(numMessages, tp)
// Test subscribe
@@ -1551,7 +1551,7 @@ class PlaintextConsumerTest extends BaseConsumerTest {
* records to each partition
*/
def createTopicAndSendRecords(topicName: String, numPartitions: Int, recordsPerPartition: Int): Set[TopicPartition] = {
- TestUtils.createTopic(this.zkUtils, topicName, numPartitions, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topicName, numPartitions, serverCount, this.servers)
var parts = Set[TopicPartition]()
for (partition <- 0 until numPartitions) {
val tp = new TopicPartition(topicName, partition)
diff --git a/core/src/test/scala/integration/kafka/api/PlaintextProducerSendTest.scala b/core/src/test/scala/integration/kafka/api/PlaintextProducerSendTest.scala
index 10063a9..6425c1e 100644
--- a/core/src/test/scala/integration/kafka/api/PlaintextProducerSendTest.scala
+++ b/core/src/test/scala/integration/kafka/api/PlaintextProducerSendTest.scala
@@ -78,7 +78,7 @@ class PlaintextProducerSendTest extends BaseProducerSendTest {
assertEquals("Should have offset 0", 0L, producer.send(record).get.offset)
// double check that the topic is created with leader elected
- TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0)
+ TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0)
} finally {
producer.close()
@@ -89,7 +89,7 @@ class PlaintextProducerSendTest extends BaseProducerSendTest {
def testSendWithInvalidCreateTime() {
val topicProps = new Properties()
topicProps.setProperty(LogConfig.MessageTimestampDifferenceMaxMsProp, "1000")
- TestUtils.createTopic(zkUtils, topic, 1, 2, servers, topicProps)
+ TestUtils.createTopic(zkClient, topic, 1, 2, servers, topicProps)
val producer = createProducer(brokerList = brokerList)
try {
diff --git a/core/src/test/scala/integration/kafka/api/ProducerBounceTest.scala b/core/src/test/scala/integration/kafka/api/ProducerBounceTest.scala
index ab13b0a..92ccf49 100644
--- a/core/src/test/scala/integration/kafka/api/ProducerBounceTest.scala
+++ b/core/src/test/scala/integration/kafka/api/ProducerBounceTest.scala
@@ -68,7 +68,7 @@ class ProducerBounceTest extends KafkaServerTestHarness {
val numPartitions = 3
val topicConfig = new Properties()
topicConfig.put(KafkaConfig.MinInSyncReplicasProp, 2.toString)
- TestUtils.createTopic(zkUtils, topic1, numPartitions, numServers, servers, topicConfig)
+ TestUtils.createTopic(zkClient, topic1, numPartitions, numServers, servers, topicConfig)
val scheduler = new ProducerScheduler()
scheduler.start
@@ -89,7 +89,7 @@ class ProducerBounceTest extends KafkaServerTestHarness {
assertFalse(scheduler.failed)
// Make sure the leader still exists after bouncing brokers
- (0 until numPartitions).foreach(partition => TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic1, partition))
+ (0 until numPartitions).foreach(partition => TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic1, partition))
}
scheduler.shutdown
diff --git a/core/src/test/scala/integration/kafka/api/ProducerCompressionTest.scala b/core/src/test/scala/integration/kafka/api/ProducerCompressionTest.scala
index 8cbdd93..3fe86d4 100755
--- a/core/src/test/scala/integration/kafka/api/ProducerCompressionTest.scala
+++ b/core/src/test/scala/integration/kafka/api/ProducerCompressionTest.scala
@@ -74,7 +74,7 @@ class ProducerCompressionTest(compression: String) extends ZooKeeperTestHarness
try {
// create topic
- TestUtils.createTopic(zkUtils, topic, 1, 1, List(server))
+ TestUtils.createTopic(zkClient, topic, 1, 1, List(server))
val partition = 0
// prepare the messages
diff --git a/core/src/test/scala/integration/kafka/api/ProducerFailureHandlingTest.scala b/core/src/test/scala/integration/kafka/api/ProducerFailureHandlingTest.scala
index e1b1c9d..b9fb657 100644
--- a/core/src/test/scala/integration/kafka/api/ProducerFailureHandlingTest.scala
+++ b/core/src/test/scala/integration/kafka/api/ProducerFailureHandlingTest.scala
@@ -88,7 +88,7 @@ class ProducerFailureHandlingTest extends KafkaServerTestHarness {
@Test
def testTooLargeRecordWithAckZero() {
// create topic
- TestUtils.createTopic(zkUtils, topic1, 1, numServers, servers)
+ TestUtils.createTopic(zkClient, topic1, 1, numServers, servers)
// send a too-large record
val record = new ProducerRecord(topic1, null, "key".getBytes, new Array[Byte](serverMessageMaxBytes + 1))
@@ -105,7 +105,7 @@ class ProducerFailureHandlingTest extends KafkaServerTestHarness {
@Test
def testTooLargeRecordWithAckOne() {
// create topic
- TestUtils.createTopic(zkUtils, topic1, 1, numServers, servers)
+ TestUtils.createTopic(zkClient, topic1, 1, numServers, servers)
// send a too-large record
val record = new ProducerRecord(topic1, null, "key".getBytes, new Array[Byte](serverMessageMaxBytes + 1))
@@ -122,7 +122,7 @@ class ProducerFailureHandlingTest extends KafkaServerTestHarness {
// create topic
val topic10 = "topic10"
- TestUtils.createTopic(zkUtils, topic10, servers.size, numServers, servers, topicConfig)
+ TestUtils.createTopic(zkClient, topic10, servers.size, numServers, servers, topicConfig)
// send a record that is too large for replication, but within the broker max message limit
val value = new Array[Byte](maxMessageSize - DefaultRecordBatch.RECORD_BATCH_OVERHEAD - DefaultRecord.MAX_RECORD_OVERHEAD)
@@ -169,7 +169,7 @@ class ProducerFailureHandlingTest extends KafkaServerTestHarness {
@Test
def testWrongBrokerList() {
// create topic
- TestUtils.createTopic(zkUtils, topic1, 1, numServers, servers)
+ TestUtils.createTopic(zkClient, topic1, 1, numServers, servers)
// producer with incorrect broker list
producer4 = TestUtils.createNewProducer("localhost:8686,localhost:4242", acks = 1, maxBlockMs = 10000L, bufferSize = producerBufferSize)
@@ -188,7 +188,7 @@ class ProducerFailureHandlingTest extends KafkaServerTestHarness {
@Test
def testInvalidPartition() {
// create topic with a single partition
- TestUtils.createTopic(zkUtils, topic1, 1, numServers, servers)
+ TestUtils.createTopic(zkClient, topic1, 1, numServers, servers)
// create a record with incorrect partition id (higher than the number of partitions), send should fail
val higherRecord = new ProducerRecord(topic1, 1, "key".getBytes, "value".getBytes)
@@ -203,7 +203,7 @@ class ProducerFailureHandlingTest extends KafkaServerTestHarness {
@Test
def testSendAfterClosed() {
// create topic
- TestUtils.createTopic(zkUtils, topic1, 1, numServers, servers)
+ TestUtils.createTopic(zkClient, topic1, 1, numServers, servers)
val record = new ProducerRecord[Array[Byte],Array[Byte]](topic1, null, "key".getBytes, "value".getBytes)
@@ -228,7 +228,7 @@ class ProducerFailureHandlingTest extends KafkaServerTestHarness {
@Test
def testCannotSendToInternalTopic() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
val thrown = intercept[ExecutionException] {
producer2.send(new ProducerRecord(Topic.GROUP_METADATA_TOPIC_NAME, "test".getBytes, "test".getBytes)).get
}
@@ -241,7 +241,7 @@ class ProducerFailureHandlingTest extends KafkaServerTestHarness {
val topicProps = new Properties()
topicProps.put("min.insync.replicas",(numServers+1).toString)
- TestUtils.createTopic(zkUtils, topicName, 1, numServers, servers, topicProps)
+ TestUtils.createTopic(zkClient, topicName, 1, numServers, servers, topicProps)
val record = new ProducerRecord(topicName, null, "key".getBytes, "value".getBytes)
try {
@@ -261,7 +261,7 @@ class ProducerFailureHandlingTest extends KafkaServerTestHarness {
val topicProps = new Properties()
topicProps.put("min.insync.replicas", numServers.toString)
- TestUtils.createTopic(zkUtils, topicName, 1, numServers, servers,topicProps)
+ TestUtils.createTopic(zkClient, topicName, 1, numServers, servers,topicProps)
val record = new ProducerRecord(topicName, null, "key".getBytes, "value".getBytes)
// this should work with all brokers up and running
diff --git a/core/src/test/scala/integration/kafka/api/RackAwareAutoTopicCreationTest.scala b/core/src/test/scala/integration/kafka/api/RackAwareAutoTopicCreationTest.scala
index 0ae9d17..197214e 100644
--- a/core/src/test/scala/integration/kafka/api/RackAwareAutoTopicCreationTest.scala
+++ b/core/src/test/scala/integration/kafka/api/RackAwareAutoTopicCreationTest.scala
@@ -51,8 +51,8 @@ class RackAwareAutoTopicCreationTest extends KafkaServerTestHarness with RackAwa
assertEquals("Should have offset 0", 0L, producer.send(record).get.offset)
// double check that the topic is created with leader elected
- TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0)
- val assignment = zkUtils.getReplicaAssignmentForTopics(Seq(topic)).map { case (topicPartition, replicas) =>
+ TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0)
+ val assignment = zkClient.getReplicaAssignmentForTopics(Set(topic)).map { case (topicPartition, replicas) =>
topicPartition.partition -> replicas
}
val brokerMetadatas = adminZkClient.getBrokerMetadatas(RackAwareMode.Enforced)
diff --git a/core/src/test/scala/integration/kafka/api/SaslClientsWithInvalidCredentialsTest.scala b/core/src/test/scala/integration/kafka/api/SaslClientsWithInvalidCredentialsTest.scala
index b309b80..ea4b05c 100644
--- a/core/src/test/scala/integration/kafka/api/SaslClientsWithInvalidCredentialsTest.scala
+++ b/core/src/test/scala/integration/kafka/api/SaslClientsWithInvalidCredentialsTest.scala
@@ -27,7 +27,8 @@ import org.junit.{After, Before, Test}
import org.junit.Assert._
import kafka.admin.ConsumerGroupCommand.{ConsumerGroupCommandOptions, KafkaConsumerGroupService}
import kafka.server.KafkaConfig
-import kafka.utils.{JaasTestUtils, TestUtils, ZkUtils}
+import kafka.utils.{JaasTestUtils, TestUtils}
+import kafka.zk.ConfigEntityChangeNotificationZNode
import org.apache.kafka.common.security.auth.SecurityProtocol
class SaslClientsWithInvalidCredentialsTest extends IntegrationTestHarness with SaslSetup {
@@ -51,7 +52,7 @@ class SaslClientsWithInvalidCredentialsTest extends IntegrationTestHarness with
override def configureSecurityBeforeServersStart() {
super.configureSecurityBeforeServersStart()
- zkUtils.makeSurePersistentPathExists(ZkUtils.ConfigChangesPath)
+ zkClient.makeSurePersistentPathExists(ConfigEntityChangeNotificationZNode.path)
// Create broker credentials before starting brokers
createScramCredentials(zkConnect, JaasTestUtils.KafkaScramAdmin, JaasTestUtils.KafkaScramAdminPassword)
}
@@ -61,7 +62,7 @@ class SaslClientsWithInvalidCredentialsTest extends IntegrationTestHarness with
startSasl(jaasSections(kafkaServerSaslMechanisms, Some(kafkaClientSaslMechanism), Both,
JaasTestUtils.KafkaServerContextName))
super.setUp()
- TestUtils.createTopic(this.zkUtils, topic, numPartitions, serverCount, this.servers)
+ TestUtils.createTopic(zkClient, topic, numPartitions, serverCount, this.servers)
}
@After
diff --git a/core/src/test/scala/integration/kafka/api/SaslScramSslEndToEndAuthorizationTest.scala b/core/src/test/scala/integration/kafka/api/SaslScramSslEndToEndAuthorizationTest.scala
index 2f50706..a4f3e0b 100644
--- a/core/src/test/scala/integration/kafka/api/SaslScramSslEndToEndAuthorizationTest.scala
+++ b/core/src/test/scala/integration/kafka/api/SaslScramSslEndToEndAuthorizationTest.scala
@@ -32,7 +32,7 @@ class SaslScramSslEndToEndAuthorizationTest extends SaslEndToEndAuthorizationTes
override def configureSecurityBeforeServersStart() {
super.configureSecurityBeforeServersStart()
- zkUtils.makeSurePersistentPathExists(ZkUtils.ConfigChangesPath)
+ zkClient.makeSurePersistentPathExists(ZkUtils.ConfigChangesPath)
// Create broker credentials before starting brokers
createScramCredentials(zkConnect, kafkaPrincipal, kafkaPassword)
}
diff --git a/core/src/test/scala/integration/kafka/api/TransactionsBounceTest.scala b/core/src/test/scala/integration/kafka/api/TransactionsBounceTest.scala
index 1712ef8..da6ca1f 100644
--- a/core/src/test/scala/integration/kafka/api/TransactionsBounceTest.scala
+++ b/core/src/test/scala/integration/kafka/api/TransactionsBounceTest.scala
@@ -169,8 +169,8 @@ class TransactionsBounceTest extends KafkaServerTestHarness {
private def createTopics() = {
val topicConfig = new Properties()
topicConfig.put(KafkaConfig.MinInSyncReplicasProp, 2.toString)
- TestUtils.createTopic(zkUtils, inputTopic, numPartitions, 3, servers, topicConfig)
- TestUtils.createTopic(zkUtils, outputTopic, numPartitions, 3, servers, topicConfig)
+ TestUtils.createTopic(zkClient, inputTopic, numPartitions, 3, servers, topicConfig)
+ TestUtils.createTopic(zkClient, outputTopic, numPartitions, 3, servers, topicConfig)
}
private class BounceScheduler extends ShutdownableThread("daemon-broker-bouncer", false) {
@@ -186,7 +186,7 @@ class TransactionsBounceTest extends KafkaServerTestHarness {
Thread.sleep(500)
}
- (0 until numPartitions).foreach(partition => TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, outputTopic, partition))
+ (0 until numPartitions).foreach(partition => TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, outputTopic, partition))
}
override def shutdown(){
diff --git a/core/src/test/scala/integration/kafka/api/TransactionsTest.scala b/core/src/test/scala/integration/kafka/api/TransactionsTest.scala
index bb6b520..d50dd33 100644
--- a/core/src/test/scala/integration/kafka/api/TransactionsTest.scala
+++ b/core/src/test/scala/integration/kafka/api/TransactionsTest.scala
@@ -60,8 +60,8 @@ class TransactionsTest extends KafkaServerTestHarness {
val numPartitions = 4
val topicConfig = new Properties()
topicConfig.put(KafkaConfig.MinInSyncReplicasProp, 2.toString)
- TestUtils.createTopic(zkUtils, topic1, numPartitions, numServers, servers, topicConfig)
- TestUtils.createTopic(zkUtils, topic2, numPartitions, numServers, servers, topicConfig)
+ TestUtils.createTopic(zkClient, topic1, numPartitions, numServers, servers, topicConfig)
+ TestUtils.createTopic(zkClient, topic2, numPartitions, numServers, servers, topicConfig)
for (_ <- 0 until transactionalProducerCount)
createTransactionalProducer("transactional-producer")
@@ -503,8 +503,8 @@ class TransactionsTest extends KafkaServerTestHarness {
val topicConfig = new Properties()
topicConfig.put(KafkaConfig.MinInSyncReplicasProp, 2.toString)
- TestUtils.createTopic(zkUtils, topicWith10Partitions, 10, numServers, servers, topicConfig)
- TestUtils.createTopic(zkUtils, topicWith10PartitionsAndOneReplica, 10, 1, servers, new Properties())
+ TestUtils.createTopic(zkClient, topicWith10Partitions, 10, numServers, servers, topicConfig)
+ TestUtils.createTopic(zkClient, topicWith10PartitionsAndOneReplica, 10, 1, servers, new Properties())
firstProducer.initTransactions()
diff --git a/core/src/test/scala/integration/kafka/server/MultipleListenersWithSameSecurityProtocolBaseTest.scala b/core/src/test/scala/integration/kafka/server/MultipleListenersWithSameSecurityProtocolBaseTest.scala
index 40ec293..da8437e 100644
--- a/core/src/test/scala/integration/kafka/server/MultipleListenersWithSameSecurityProtocolBaseTest.scala
+++ b/core/src/test/scala/integration/kafka/server/MultipleListenersWithSameSecurityProtocolBaseTest.scala
@@ -104,13 +104,13 @@ abstract class MultipleListenersWithSameSecurityProtocolBaseTest extends ZooKeep
Internal, config.interBrokerListenerName.value)
}
- TestUtils.createTopic(zkUtils, Topic.GROUP_METADATA_TOPIC_NAME, OffsetConfig.DefaultOffsetsTopicNumPartitions,
+ TestUtils.createTopic(zkClient, Topic.GROUP_METADATA_TOPIC_NAME, OffsetConfig.DefaultOffsetsTopicNumPartitions,
replicationFactor = 2, servers, servers.head.groupCoordinator.offsetsTopicConfigs)
servers.head.config.listeners.foreach { endPoint =>
val listenerName = endPoint.listenerName
- TestUtils.createTopic(zkUtils, listenerName.value, 2, 2, servers)
+ TestUtils.createTopic(zkClient, listenerName.value, 2, 2, servers)
val trustStoreFile =
if (TestUtils.usesSslTransportLayer(endPoint.securityProtocol)) Some(this.trustStoreFile)
diff --git a/core/src/test/scala/integration/kafka/server/ReplicaFetcherThreadFatalErrorTest.scala b/core/src/test/scala/integration/kafka/server/ReplicaFetcherThreadFatalErrorTest.scala
index 46badf0..5e81dc5 100644
--- a/core/src/test/scala/integration/kafka/server/ReplicaFetcherThreadFatalErrorTest.scala
+++ b/core/src/test/scala/integration/kafka/server/ReplicaFetcherThreadFatalErrorTest.scala
@@ -21,7 +21,7 @@ import java.util.concurrent.atomic.AtomicBoolean
import kafka.cluster.BrokerEndPoint
import kafka.server.ReplicaFetcherThread.{FetchRequest, PartitionData}
-import kafka.utils.{Exit, TestUtils, ZkUtils}
+import kafka.utils.{Exit, TestUtils}
import kafka.utils.TestUtils.createBrokerConfigs
import kafka.zk.ZooKeeperTestHarness
import org.apache.kafka.common.TopicPartition
@@ -58,9 +58,9 @@ class ReplicaFetcherThreadFatalErrorTest extends ZooKeeperTestHarness {
// Unlike `TestUtils.createTopic`, this doesn't wait for metadata propagation as the broker shuts down before
// the metadata is propagated.
- def createTopic(zkUtils: ZkUtils, topic: String): Unit = {
+ def createTopic(topic: String): Unit = {
adminZkClient.createTopic(topic, partitions = 1, replicationFactor = 2)
- TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0)
+ TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0)
}
val props = createBrokerConfigs(2, zkConnect)
@@ -72,7 +72,7 @@ class ReplicaFetcherThreadFatalErrorTest extends ZooKeeperTestHarness {
super.addPartitions(partitionAndOffsets.mapValues(_ => -1))
}
}))
- createTopic(zkUtils, "topic")
+ createTopic("topic")
TestUtils.waitUntilTrue(() => shutdownCompleted, "Shutdown of follower did not complete")
}
@@ -96,7 +96,7 @@ class ReplicaFetcherThreadFatalErrorTest extends ZooKeeperTestHarness {
}
}
}))
- TestUtils.createTopic(zkUtils, "topic", numPartitions = 1, replicationFactor = 2, servers = brokers)
+ TestUtils.createTopic(zkClient, "topic", numPartitions = 1, replicationFactor = 2, servers = brokers)
TestUtils.waitUntilTrue(() => shutdownCompleted, "Shutdown of follower did not complete")
}
diff --git a/core/src/test/scala/other/kafka/ReplicationQuotasTestRig.scala b/core/src/test/scala/other/kafka/ReplicationQuotasTestRig.scala
index d411b2f..6fdad30 100644
--- a/core/src/test/scala/other/kafka/ReplicationQuotasTestRig.scala
+++ b/core/src/test/scala/other/kafka/ReplicationQuotasTestRig.scala
@@ -25,9 +25,8 @@ import kafka.admin.ReassignPartitionsCommand.Throttle
import org.apache.kafka.common.TopicPartition
import kafka.server.{KafkaConfig, KafkaServer, QuotaType}
import kafka.utils.TestUtils._
-import kafka.utils.ZkUtils._
import kafka.utils.{Exit, Logging, TestUtils, ZkUtils}
-import kafka.zk.ZooKeeperTestHarness
+import kafka.zk.{ReassignPartitionsZNode, ZooKeeperTestHarness}
import org.apache.kafka.clients.producer.ProducerRecord
import org.jfree.chart.plot.PlotOrientation
import org.jfree.chart.{ChartFactory, ChartFrame, JFreeChart}
@@ -124,7 +123,7 @@ object ReplicationQuotasTestRig {
val replicas = (0 to config.partitions).map(partition => partition -> Seq(nextReplicaRoundRobin())).toMap
startBrokers(brokers)
- createTopic(zkUtils, topicName, replicas, servers)
+ createTopic(zkClient, topicName, replicas, servers)
println("Writing Data")
val producer = TestUtils.createNewProducer(TestUtils.getBrokerListStrFromServers(servers), retries = 5, acks = 0)
@@ -167,7 +166,7 @@ object ReplicationQuotasTestRig {
}
def logOutput(config: ExperimentDef, replicas: Map[Int, Seq[Int]], newAssignment: Map[TopicPartition, Seq[Int]]): Unit = {
- val actual = zkUtils.getPartitionAssignmentForTopics(Seq(topicName))(topicName)
+ val actual = zkClient.getPartitionAssignmentForTopics(Set(topicName))(topicName)
//Long stats
println("The replicas are " + replicas.toSeq.sortBy(_._1).map("\n" + _))
@@ -188,8 +187,8 @@ object ReplicationQuotasTestRig {
def waitForReassignmentToComplete() {
waitUntilTrue(() => {
printRateMetrics()
- !zkUtils.pathExists(ReassignPartitionsPath)
- }, s"Znode ${ZkUtils.ReassignPartitionsPath} wasn't deleted", 60 * 60 * 1000, pause = 1000L)
+ !zkClient.reassignPartitionsInProgress()
+ }, s"Znode ${ReassignPartitionsZNode.path} wasn't deleted", 60 * 60 * 1000, pause = 1000L)
}
def renderChart(data: mutable.Map[Int, Array[Double]], name: String, journal: Journal, displayChartsOnScreen: Boolean): Unit = {
diff --git a/core/src/test/scala/unit/kafka/admin/AddPartitionsTest.scala b/core/src/test/scala/unit/kafka/admin/AddPartitionsTest.scala
index d79ba32..b68379b 100755
--- a/core/src/test/scala/unit/kafka/admin/AddPartitionsTest.scala
+++ b/core/src/test/scala/unit/kafka/admin/AddPartitionsTest.scala
@@ -25,6 +25,7 @@ import kafka.utils.TestUtils
import kafka.cluster.Broker
import kafka.client.ClientUtils
import kafka.server.{KafkaConfig, KafkaServer}
+import org.apache.kafka.common.TopicPartition
import org.apache.kafka.common.errors.InvalidReplicaAssignmentException
import org.apache.kafka.common.network.ListenerName
import org.apache.kafka.common.security.auth.SecurityProtocol
@@ -58,10 +59,10 @@ class AddPartitionsTest extends ZooKeeperTestHarness {
brokers = servers.map(s => TestUtils.createBroker(s.config.brokerId, s.config.hostName, TestUtils.boundPort(s)))
// create topics first
- createTopic(zkUtils, topic1, partitionReplicaAssignment = topic1Assignment, servers = servers)
- createTopic(zkUtils, topic2, partitionReplicaAssignment = topic2Assignment, servers = servers)
- createTopic(zkUtils, topic3, partitionReplicaAssignment = topic3Assignment, servers = servers)
- createTopic(zkUtils, topic4, partitionReplicaAssignment = topic4Assignment, servers = servers)
+ createTopic(zkClient, topic1, partitionReplicaAssignment = topic1Assignment, servers = servers)
+ createTopic(zkClient, topic2, partitionReplicaAssignment = topic2Assignment, servers = servers)
+ createTopic(zkClient, topic3, partitionReplicaAssignment = topic3Assignment, servers = servers)
+ createTopic(zkClient, topic4, partitionReplicaAssignment = topic4Assignment, servers = servers)
}
@After
@@ -97,10 +98,10 @@ class AddPartitionsTest extends ZooKeeperTestHarness {
def testIncrementPartitions(): Unit = {
adminZkClient.addPartitions(topic1, topic1Assignment, adminZkClient.getBrokerMetadatas(), 3)
// wait until leader is elected
- val leader1 = waitUntilLeaderIsElectedOrChanged(zkUtils, topic1, 1)
- val leader2 = waitUntilLeaderIsElectedOrChanged(zkUtils, topic1, 2)
- val leader1FromZk = zkUtils.getLeaderForPartition(topic1, 1).get
- val leader2FromZk = zkUtils.getLeaderForPartition(topic1, 2).get
+ val leader1 = waitUntilLeaderIsElectedOrChanged(zkClient, topic1, 1)
+ val leader2 = waitUntilLeaderIsElectedOrChanged(zkClient, topic1, 2)
+ val leader1FromZk = zkClient.getLeaderForPartition(new TopicPartition(topic1, 1)).get
+ val leader2FromZk = zkClient.getLeaderForPartition(new TopicPartition(topic1, 2)).get
assertEquals(leader1, leader1FromZk)
assertEquals(leader2, leader2FromZk)
@@ -126,10 +127,10 @@ class AddPartitionsTest extends ZooKeeperTestHarness {
adminZkClient.addPartitions(topic2, topic2Assignment, adminZkClient.getBrokerMetadatas(), 3,
Some(Map(0 -> Seq(1, 2), 1 -> Seq(0, 1), 2 -> Seq(2, 3))))
// wait until leader is elected
- val leader1 = waitUntilLeaderIsElectedOrChanged(zkUtils, topic2, 1)
- val leader2 = waitUntilLeaderIsElectedOrChanged(zkUtils, topic2, 2)
- val leader1FromZk = zkUtils.getLeaderForPartition(topic2, 1).get
- val leader2FromZk = zkUtils.getLeaderForPartition(topic2, 2).get
+ val leader1 = waitUntilLeaderIsElectedOrChanged(zkClient, topic2, 1)
+ val leader2 = waitUntilLeaderIsElectedOrChanged(zkClient, topic2, 2)
+ val leader1FromZk = zkClient.getLeaderForPartition(new TopicPartition(topic2, 1)).get
+ val leader2FromZk = zkClient.getLeaderForPartition(new TopicPartition(topic2, 2)).get
assertEquals(leader1, leader1FromZk)
assertEquals(leader2, leader2FromZk)
diff --git a/core/src/test/scala/unit/kafka/admin/AdminTest.scala b/core/src/test/scala/unit/kafka/admin/AdminTest.scala
index fb594d0..1f07ce4 100755
--- a/core/src/test/scala/unit/kafka/admin/AdminTest.scala
+++ b/core/src/test/scala/unit/kafka/admin/AdminTest.scala
@@ -35,7 +35,6 @@ import java.util
import java.util.concurrent.LinkedBlockingQueue
import kafka.utils.TestUtils._
-import kafka.admin.AdminUtils._
import scala.collection.{Map, Set, immutable}
import kafka.utils.CoreUtils._
@@ -88,7 +87,7 @@ class AdminTest extends ZooKeeperTestHarness with Logging with RackAwareTest {
@Test
def testManualReplicaAssignment() {
val brokers = List(0, 1, 2, 3, 4)
- TestUtils.createBrokersInZk(zkUtils, brokers)
+ TestUtils.createBrokersInZk(zkClient, brokers)
// duplicate brokers
intercept[InvalidReplicaAssignmentException] {
@@ -139,7 +138,7 @@ class AdminTest extends ZooKeeperTestHarness with Logging with RackAwareTest {
11 -> 1
)
val topic = "test"
- TestUtils.createBrokersInZk(zkUtils, List(0, 1, 2, 3, 4))
+ TestUtils.createBrokersInZk(zkClient, List(0, 1, 2, 3, 4))
// create the topic
AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK(zkUtils, topic, expectedReplicaAssignment)
// create leaders for all partitions
@@ -159,7 +158,7 @@ class AdminTest extends ZooKeeperTestHarness with Logging with RackAwareTest {
def testTopicCreationWithCollision() {
val topic = "test.topic"
val collidingTopic = "test_topic"
- TestUtils.createBrokersInZk(zkUtils, List(0, 1, 2, 3, 4))
+ TestUtils.createBrokersInZk(zkClient, List(0, 1, 2, 3, 4))
// create the topic
AdminUtils.createTopic(zkUtils, topic, 3, 1)
@@ -310,7 +309,7 @@ class AdminTest extends ZooKeeperTestHarness with Logging with RackAwareTest {
servers = TestUtils.createBrokerConfigs(2, zkConnect, false).map(b => TestUtils.createServer(KafkaConfig.fromProps(b)))
// wait until reassignment completes
- TestUtils.waitUntilTrue(() => !checkIfReassignPartitionPathExists(zkUtils),
+ TestUtils.waitUntilTrue(() => !zkClient.reassignPartitionsInProgress(),
"Partition reassignment should complete")
val assignedReplicas = zkClient.getReplicasForPartition(new TopicPartition(topic, partitionToBeReassigned))
assertEquals("Partition should have been reassigned to 0, 1", newReplicas, assignedReplicas)
@@ -347,11 +346,11 @@ class AdminTest extends ZooKeeperTestHarness with Logging with RackAwareTest {
adminZkClient.createOrUpdateTopicPartitionAssignmentPathInZK(topic, expectedReplicaAssignment)
servers = serverConfigs.reverseMap(s => TestUtils.createServer(s))
// broker 2 should be the leader since it was started first
- val currentLeader = TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partition, oldLeaderOpt = None)
+ val currentLeader = TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic, partition, oldLeaderOpt = None)
// trigger preferred replica election
val preferredReplicaElection = new PreferredReplicaLeaderElectionCommand(zkClient, Set(new TopicPartition(topic, partition)))
preferredReplicaElection.moveLeaderToPreferredReplica()
- val newLeader = TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partition, oldLeaderOpt = Some(currentLeader))
+ val newLeader = TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic, partition, oldLeaderOpt = Some(currentLeader))
assertEquals("Preferred replica election failed", preferredReplica, newLeader)
}
@@ -364,7 +363,7 @@ class AdminTest extends ZooKeeperTestHarness with Logging with RackAwareTest {
val serverConfigs = TestUtils.createBrokerConfigs(3, zkConnect, false).map(KafkaConfig.fromProps)
servers = serverConfigs.reverseMap(s => TestUtils.createServer(s))
// create the topic
- TestUtils.createTopic(zkUtils, topic, partitionReplicaAssignment = expectedReplicaAssignment, servers = servers)
+ TestUtils.createTopic(zkClient, topic, partitionReplicaAssignment = expectedReplicaAssignment, servers = servers)
val controllerId = zkUtils.getController()
val controller = servers.find(p => p.config.brokerId == controllerId).get.kafkaController
@@ -551,7 +550,7 @@ class AdminTest extends ZooKeeperTestHarness with Logging with RackAwareTest {
val brokerList = 0 to 5
val rackInfo = Map(0 -> "rack1", 1 -> "rack2", 2 -> "rack2", 3 -> "rack1", 5 -> "rack3")
val brokerMetadatas = toBrokerMetadata(rackInfo, brokersWithoutRack = brokerList.filterNot(rackInfo.keySet))
- TestUtils.createBrokersInZk(brokerMetadatas, zkUtils)
+ TestUtils.createBrokersInZk(brokerMetadatas, zkClient)
val processedMetadatas1 = AdminUtils.getBrokerMetadatas(zkUtils, RackAwareMode.Disabled)
assertEquals(brokerList, processedMetadatas1.map(_.id))
diff --git a/core/src/test/scala/unit/kafka/admin/DeleteConsumerGroupTest.scala b/core/src/test/scala/unit/kafka/admin/DeleteConsumerGroupTest.scala
index ba11471..78bbe09 100644
--- a/core/src/test/scala/unit/kafka/admin/DeleteConsumerGroupTest.scala
+++ b/core/src/test/scala/unit/kafka/admin/DeleteConsumerGroupTest.scala
@@ -36,7 +36,7 @@ class DeleteConsumerGroupTest extends KafkaServerTestHarness {
val groupToDelete = "groupToDelete"
val otherGroup = "otherGroup"
- TestUtils.createTopic(zkUtils, topic, 1, 3, servers)
+ TestUtils.createTopic(zkClient, topic, 1, 3, servers)
fillInConsumerGroupInfo(topic, groupToDelete, "consumer", 0, 10, false)
fillInConsumerGroupInfo(topic, otherGroup, "consumer", 0, 10, false)
@@ -54,7 +54,7 @@ class DeleteConsumerGroupTest extends KafkaServerTestHarness {
val groupToDelete = "groupToDelete"
val otherGroup = "otherGroup"
- TestUtils.createTopic(zkUtils, topic, 1, 3, servers)
+ TestUtils.createTopic(zkClient, topic, 1, 3, servers)
fillInConsumerGroupInfo(topic, groupToDelete, "consumer", 0, 10, true)
fillInConsumerGroupInfo(topic, otherGroup, "consumer", 0, 10, false)
@@ -71,7 +71,7 @@ class DeleteConsumerGroupTest extends KafkaServerTestHarness {
val topic = "test"
val groupToDelete = "groupToDelete"
val otherGroup = "otherGroup"
- TestUtils.createTopic(zkUtils, topic, 1, 3, servers)
+ TestUtils.createTopic(zkClient, topic, 1, 3, servers)
fillInConsumerGroupInfo(topic, groupToDelete, "consumer", 0, 10, false)
fillInConsumerGroupInfo(topic, otherGroup, "consumer", 0, 10, false)
@@ -89,8 +89,8 @@ class DeleteConsumerGroupTest extends KafkaServerTestHarness {
val otherTopic = "otherTopic"
val groupToDelete = "groupToDelete"
val otherGroup = "otherGroup"
- TestUtils.createTopic(zkUtils, topicToDelete, 1, 3, servers)
- TestUtils.createTopic(zkUtils, otherTopic, 1, 3, servers)
+ TestUtils.createTopic(zkClient, topicToDelete, 1, 3, servers)
+ TestUtils.createTopic(zkClient, otherTopic, 1, 3, servers)
fillInConsumerGroupInfo(topicToDelete, groupToDelete, "consumer", 0, 10, false)
fillInConsumerGroupInfo(otherTopic, groupToDelete, "consumer", 0, 10, false)
@@ -111,8 +111,8 @@ class DeleteConsumerGroupTest extends KafkaServerTestHarness {
val topicToDelete = "topicToDelete"
val otherTopic = "otherTopic"
val group = "group"
- TestUtils.createTopic(zkUtils, topicToDelete, 1, 3, servers)
- TestUtils.createTopic(zkUtils, otherTopic, 1, 3, servers)
+ TestUtils.createTopic(zkClient, topicToDelete, 1, 3, servers)
+ TestUtils.createTopic(zkClient, otherTopic, 1, 3, servers)
fillInConsumerGroupInfo(topicToDelete, group, "consumer", 0, 10, true)
fillInConsumerGroupInfo(otherTopic, group, "consumer", 0, 10, true)
@@ -131,8 +131,8 @@ class DeleteConsumerGroupTest extends KafkaServerTestHarness {
val otherTopic = "otherTopic"
val groups = Seq("group1", "group2")
- TestUtils.createTopic(zkUtils, topicToDelete, 1, 3, servers)
- TestUtils.createTopic(zkUtils, otherTopic, 1, 3, servers)
+ TestUtils.createTopic(zkClient, topicToDelete, 1, 3, servers)
+ TestUtils.createTopic(zkClient, otherTopic, 1, 3, servers)
val groupTopicDirsForTopicToDelete = groups.map(group => new ZKGroupTopicDirs(group, topicToDelete))
val groupTopicDirsForOtherTopic = groups.map(group => new ZKGroupTopicDirs(group, otherTopic))
groupTopicDirsForTopicToDelete.foreach(dir => fillInConsumerGroupInfo(topicToDelete, dir.group, "consumer", 0, 10, false))
@@ -151,12 +151,12 @@ class DeleteConsumerGroupTest extends KafkaServerTestHarness {
val topic = "topic"
val group = "group"
- TestUtils.createTopic(zkUtils, topic, 1, 3, servers)
+ TestUtils.createTopic(zkClient, topic, 1, 3, servers)
val dir = new ZKGroupTopicDirs(group, topic)
fillInConsumerGroupInfo(topic, dir.group, "consumer", 0, 10, false)
AdminUtils.deleteTopic(zkUtils, topic)
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, servers)
AdminUtils.deleteAllConsumerGroupInfoForTopicInZK(zkUtils, topic)
TestUtils.waitUntilTrue(() => !groupDirExists(dir),
diff --git a/core/src/test/scala/unit/kafka/admin/DeleteTopicTest.scala b/core/src/test/scala/unit/kafka/admin/DeleteTopicTest.scala
index 0d62afc..593b9cc 100644
--- a/core/src/test/scala/unit/kafka/admin/DeleteTopicTest.scala
+++ b/core/src/test/scala/unit/kafka/admin/DeleteTopicTest.scala
@@ -19,13 +19,12 @@ package kafka.admin
import kafka.log.Log
import kafka.zk.ZooKeeperTestHarness
import kafka.utils.TestUtils
-import kafka.utils.ZkUtils._
import kafka.server.{KafkaConfig, KafkaServer}
import org.junit.Assert._
import org.junit.{After, Test}
import java.util.Properties
-import kafka.common.TopicAlreadyMarkedForDeletionException
+import kafka.common.{KafkaException, TopicAlreadyMarkedForDeletionException}
import org.apache.kafka.common.TopicPartition
import org.apache.kafka.common.errors.UnknownTopicOrPartitionException
@@ -47,7 +46,7 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
servers = createTestTopicAndCluster(topic)
// start topic deletion
adminZkClient.deleteTopic(topic)
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, servers)
}
@Test
@@ -56,7 +55,7 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
val topic = topicPartition.topic
servers = createTestTopicAndCluster(topic)
// shut down one follower replica
- val leaderIdOpt = zkUtils.getLeaderForPartition(topic, 0)
+ val leaderIdOpt = zkClient.getLeaderForPartition(new TopicPartition(topic, 0))
assertTrue("Leader should exist for partition [test,0]", leaderIdOpt.isDefined)
val follower = servers.filter(s => s.config.brokerId != leaderIdOpt.get).last
follower.shutdown()
@@ -67,11 +66,11 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
servers.filter(s => s.config.brokerId != follower.config.brokerId)
.forall(_.getLogManager().getLog(topicPartition).isEmpty), "Replicas 0,1 have not deleted log.")
// ensure topic deletion is halted
- TestUtils.waitUntilTrue(() => zkUtils.isTopicMarkedForDeletion(topic),
+ TestUtils.waitUntilTrue(() => zkClient.isTopicMarkedForDeletion(topic),
"Admin path /admin/delete_topic/test path deleted even when a follower replica is down")
// restart follower replica
follower.startup()
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, servers)
}
@Test
@@ -79,9 +78,9 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
val topicPartition = new TopicPartition("test", 0)
val topic = topicPartition.topic
servers = createTestTopicAndCluster(topic)
- val controllerId = zkUtils.getController()
+ val controllerId = zkClient.getControllerId.getOrElse(fail("Controller doesn't exist"))
val controller = servers.filter(s => s.config.brokerId == controllerId).head
- val leaderIdOpt = zkUtils.getLeaderForPartition(topic, 0)
+ val leaderIdOpt = zkClient.getLeaderForPartition(new TopicPartition(topic, 0))
val follower = servers.filter(s => s.config.brokerId != leaderIdOpt.get && s.config.brokerId != controllerId).last
follower.shutdown()
@@ -91,13 +90,13 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
controller.shutdown()
// ensure topic deletion is halted
- TestUtils.waitUntilTrue(() => zkUtils.isTopicMarkedForDeletion(topic),
+ TestUtils.waitUntilTrue(() => zkClient.isTopicMarkedForDeletion(topic),
"Admin path /admin/delete_topic/test path deleted even when a replica is down")
controller.startup()
follower.startup()
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, servers)
}
@Test
@@ -116,7 +115,7 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
// wait until replica log is created on every broker
TestUtils.waitUntilTrue(() => servers.forall(_.getLogManager().getLog(topicPartition).isDefined),
"Replicas for topic test not created.")
- val leaderIdOpt = zkUtils.getLeaderForPartition(topic, 0)
+ val leaderIdOpt = zkClient.getLeaderForPartition(new TopicPartition(topic, 0))
assertTrue("Leader should exist for partition [test,0]", leaderIdOpt.isDefined)
val follower = servers.filter(s => s.config.brokerId != leaderIdOpt.get).last
follower.shutdown()
@@ -125,7 +124,7 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
// start partition reassignment at the same time right after delete topic. In this case, reassignment will fail since
// the topic is being deleted
// reassign partition 0
- val oldAssignedReplicas = zkUtils.getReplicasForPartition(topic, 0)
+ val oldAssignedReplicas = zkClient.getReplicasForPartition(new TopicPartition(topic, 0))
val newReplicas = Seq(1, 2, 3)
val reassignPartitionsCommand = new ReassignPartitionsCommand(zkClient, None,
Map(topicPartition -> newReplicas), adminZkClient = adminZkClient)
@@ -136,21 +135,21 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
ReassignPartitionsCommand.checkIfPartitionReassignmentSucceeded(zkClient, topicPartition,
Map(topicPartition -> newReplicas), partitionsBeingReassigned) == ReassignmentFailed
}, "Partition reassignment shouldn't complete.")
- val controllerId = zkUtils.getController()
+ val controllerId = zkClient.getControllerId.getOrElse(fail("Controller doesn't exist"))
val controller = servers.filter(s => s.config.brokerId == controllerId).head
assertFalse("Partition reassignment should fail",
controller.kafkaController.controllerContext.partitionsBeingReassigned.contains(topicPartition))
- val assignedReplicas = zkUtils.getReplicasForPartition(topic, 0)
+ val assignedReplicas = zkClient.getReplicasForPartition(new TopicPartition(topic, 0))
assertEquals("Partition should not be reassigned to 0, 1, 2", oldAssignedReplicas, assignedReplicas)
follower.startup()
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, servers)
}
@Test
def testDeleteTopicDuringAddPartition() {
val topic = "test"
servers = createTestTopicAndCluster(topic)
- val leaderIdOpt = zkUtils.getLeaderForPartition(topic, 0)
+ val leaderIdOpt = zkClient.getLeaderForPartition(new TopicPartition(topic, 0))
assertTrue("Leader should exist for partition [test,0]", leaderIdOpt.isDefined)
val follower = servers.filter(_.config.brokerId != leaderIdOpt.get).last
val newPartition = new TopicPartition(topic, 1)
@@ -158,7 +157,7 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
val brokers = adminZkClient.getBrokerMetadatas()
follower.shutdown()
// wait until the broker has been removed from ZK to reduce non-determinism
- TestUtils.waitUntilTrue(() => zkUtils.getBrokerInfo(follower.config.brokerId).isEmpty,
+ TestUtils.waitUntilTrue(() => zkClient.getBroker(follower.config.brokerId).isEmpty,
s"Follower ${follower.config.brokerId} was not removed from ZK")
// add partitions to topic
adminZkClient.addPartitions(topic, expectedReplicaAssignment, brokers, 2,
@@ -167,7 +166,7 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
adminZkClient.deleteTopic(topic)
follower.startup()
// test if topic deletion is resumed
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, servers)
// verify that new partition doesn't exist on any broker either
TestUtils.waitUntilTrue(() =>
servers.forall(_.getLogManager().getLog(newPartition).isEmpty),
@@ -176,7 +175,7 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
@Test
def testAddPartitionDuringDeleteTopic() {
- zkUtils.setupCommonPaths()
+ zkClient.createTopLevelPaths()
val topic = "test"
servers = createTestTopicAndCluster(topic)
val brokers = adminZkClient.getBrokerMetadatas()
@@ -186,7 +185,7 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
val newPartition = new TopicPartition(topic, 1)
adminZkClient.addPartitions(topic, expectedReplicaAssignment, brokers, 2,
Some(Map(1 -> Seq(0, 1, 2), 2 -> Seq(0, 1, 2))))
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, servers)
// verify that new partition doesn't exist on any broker either
assertTrue("Replica logs not deleted after delete topic is complete",
servers.forall(_.getLogManager().getLog(newPartition).isEmpty))
@@ -200,11 +199,11 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
servers = createTestTopicAndCluster(topic)
// start topic deletion
adminZkClient.deleteTopic(topic)
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, servers)
// re-create topic on same replicas
adminZkClient.createOrUpdateTopicPartitionAssignmentPathInZK(topic, expectedReplicaAssignment)
// wait until leader is elected
- TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0, 1000)
+ TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0, 1000)
// check if all replica logs are created
TestUtils.waitUntilTrue(() => servers.forall(_.getLogManager().getLog(topicPartition).isDefined),
"Replicas for topic test not created.")
@@ -223,14 +222,14 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
case _: UnknownTopicOrPartitionException => // expected exception
}
// verify delete topic path for test2 is removed from ZooKeeper
- TestUtils.verifyTopicDeletion(zkUtils, "test2", 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, "test2", 1, servers)
// verify that topic test is untouched
TestUtils.waitUntilTrue(() => servers.forall(_.getLogManager().getLog(topicPartition).isDefined),
"Replicas for topic test not created")
// test the topic path exists
- assertTrue("Topic test mistakenly deleted", zkUtils.pathExists(getTopicPath(topic)))
+ assertTrue("Topic test mistakenly deleted", zkClient.topicExists(topic))
// topic test should have a leader
- TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0, 1000)
+ TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0, 1000)
}
@Test
@@ -260,7 +259,7 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
// delete topic
adminZkClient.deleteTopic("test")
- TestUtils.verifyTopicDeletion(zkUtils, "test", 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, "test", 1, servers)
}
@Test
@@ -280,7 +279,7 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
case _: TopicAlreadyMarkedForDeletionException => // expected exception
}
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, servers)
}
private def createTestTopicAndCluster(topic: String, deleteTopicEnabled: Boolean = true): Seq[KafkaServer] = {
@@ -318,14 +317,14 @@ class DeleteTopicTest extends ZooKeeperTestHarness {
servers = createTestTopicAndCluster(topic, deleteTopicEnabled = false)
// mark the topic for deletion
adminZkClient.deleteTopic("test")
- TestUtils.waitUntilTrue(() => !zkUtils.isTopicMarkedForDeletion(topic),
+ TestUtils.waitUntilTrue(() => !zkClient.isTopicMarkedForDeletion(topic),
"Admin path /admin/delete_topic/%s path not deleted even if deleteTopic is disabled".format(topic))
// verify that topic test is untouched
assertTrue(servers.forall(_.getLogManager().getLog(topicPartition).isDefined))
// test the topic path exists
- assertTrue("Topic path disappeared", zkUtils.pathExists(getTopicPath(topic)))
+ assertTrue("Topic path disappeared", zkClient.topicExists(topic))
// topic test should have a leader
- val leaderIdOpt = zkUtils.getLeaderForPartition(topic, 0)
+ val leaderIdOpt = zkClient.getLeaderForPartition(new TopicPartition(topic, 0))
assertTrue("Leader should exist for topic test", leaderIdOpt.isDefined)
}
}
diff --git a/core/src/test/scala/unit/kafka/admin/DescribeConsumerGroupTest.scala b/core/src/test/scala/unit/kafka/admin/DescribeConsumerGroupTest.scala
index 11f2865..6325060 100644
--- a/core/src/test/scala/unit/kafka/admin/DescribeConsumerGroupTest.scala
+++ b/core/src/test/scala/unit/kafka/admin/DescribeConsumerGroupTest.scala
@@ -77,7 +77,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
@deprecated("This test has been deprecated and will be removed in a future release.", "0.11.0.0")
def testDescribeNonExistingGroupWithOldConsumer() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
createOldConsumer()
val service = getConsumerGroupService(Array("--zookeeper", zkConnect, "--describe", "--group", "missing.group"))
TestUtils.waitUntilTrue(() => service.collectGroupOffsets()._2.isEmpty, "Expected no rows in describe group results.")
@@ -86,7 +86,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
@deprecated("This test has been deprecated and will be removed in a future release.", "0.11.0.0")
def testDescribeExistingGroupWithOldConsumer() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
createOldConsumer()
val service = getConsumerGroupService(Array("--zookeeper", zkConnect, "--describe", "--group", group))
@@ -101,7 +101,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
@deprecated("This test has been deprecated and will be removed in a future release.", "0.11.0.0")
def testDescribeExistingGroupWithNoMembersWithOldConsumer() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
createOldConsumer()
val service = getConsumerGroupService(Array("--zookeeper", zkConnect, "--describe", "--group", group))
@@ -124,7 +124,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
@deprecated("This test has been deprecated and will be removed in a future release.", "0.11.0.0")
def testDescribeConsumersWithNoAssignedPartitionsWithOldConsumer() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
createOldConsumer()
createOldConsumer()
val service = getConsumerGroupService(Array("--zookeeper", zkConnect, "--describe", "--group", group))
@@ -140,7 +140,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeNonExistingGroup() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
val missingGroup = "missing.group"
for (describeType <- describeTypes) {
@@ -156,7 +156,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test(expected = classOf[joptsimple.OptionException])
def testDescribeWithMultipleSubActions() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
val cgcArgs = Array("--bootstrap-server", brokerList, "--describe", "--group", group, "--members", "--state")
getConsumerGroupService(cgcArgs)
fail("Expected an error due to presence of mutually exclusive options")
@@ -164,7 +164,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeOffsetsOfNonExistingGroup() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run one consumer in the group consuming from a single-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 1, group, topic))
@@ -179,7 +179,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeMembersOfNonExistingGroup() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run one consumer in the group consuming from a single-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 1, group, topic))
@@ -198,7 +198,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeStateOfNonExistingGroup() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run one consumer in the group consuming from a single-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 1, group, topic))
@@ -215,7 +215,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeExistingGroup() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
for (describeType <- describeTypes) {
val group = this.group + describeType.mkString("")
@@ -233,7 +233,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeOffsetsOfExistingGroup() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run one consumer in the group consuming from a single-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 1, group, topic))
@@ -253,7 +253,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeMembersOfExistingGroup() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run one consumer in the group consuming from a single-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 1, group, topic))
@@ -287,7 +287,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeStateOfExistingGroup() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run one consumer in the group consuming from a single-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 1, group, topic))
@@ -306,7 +306,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeStateOfExistingGroupWithRoundRobinAssignor() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run one consumer in the group consuming from a single-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 1, group, topic, "org.apache.kafka.clients.consumer.RoundRobinAssignor"))
@@ -325,7 +325,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeExistingGroupWithNoMembers() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
for (describeType <- describeTypes) {
val group = this.group + describeType.mkString("")
@@ -350,7 +350,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeOffsetsOfExistingGroupWithNoMembers() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run one consumer in the group consuming from a single-partition topic
val executor = addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 1, group, topic))
@@ -383,7 +383,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeMembersOfExistingGroupWithNoMembers() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run one consumer in the group consuming from a single-partition topic
val executor = addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 1, group, topic))
@@ -407,7 +407,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeStateOfExistingGroupWithNoMembers() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run one consumer in the group consuming from a single-partition topic
val executor = addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 1, group, topic))
@@ -434,7 +434,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeWithConsumersWithoutAssignedPartitions() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
for (describeType <- describeTypes) {
val group = this.group + describeType.mkString("")
@@ -453,7 +453,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeOffsetsWithConsumersWithoutAssignedPartitions() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run two consumers in the group consuming from a single-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 2, group, topic))
@@ -472,7 +472,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeMembersWithConsumersWithoutAssignedPartitions() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run two consumers in the group consuming from a single-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 2, group, topic))
@@ -497,7 +497,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeStateWithConsumersWithoutAssignedPartitions() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
// run two consumers in the group consuming from a single-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 2, group, topic))
@@ -513,7 +513,7 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeWithMultiPartitionTopicAndMultipleConsumers() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
val topic2 = "foo2"
adminZkClient.createTopic(topic2, 2, 1)
@@ -534,9 +534,9 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeOffsetsWithMultiPartitionTopicAndMultipleConsumers() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
val topic2 = "foo2"
- AdminUtils.createTopic(zkUtils, topic2, 2, 1)
+ adminZkClient.createTopic(topic2, 2, 1)
// run two consumers in the group consuming from a two-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 2, group, topic2))
@@ -556,9 +556,9 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeMembersWithMultiPartitionTopicAndMultipleConsumers() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
val topic2 = "foo2"
- AdminUtils.createTopic(zkUtils, topic2, 2, 1)
+ adminZkClient.createTopic(topic2, 2, 1)
// run two consumers in the group consuming from a two-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 2, group, topic2))
@@ -582,9 +582,9 @@ class DescribeConsumerGroupTest extends KafkaServerTestHarness {
@Test
def testDescribeStateWithMultiPartitionTopicAndMultipleConsumers() {
- TestUtils.createOffsetsTopic(zkUtils, servers)
+ TestUtils.createOffsetsTopic(zkClient, servers)
val topic2 = "foo2"
- AdminUtils.createTopic(zkUtils, topic2, 2, 1)
+ adminZkClient.createTopic(topic2, 2, 1)
// run two consumers in the group consuming from a two-partition topic
addConsumerGroupExecutor(new ConsumerGroupExecutor(brokerList, 2, group, topic2))
diff --git a/core/src/test/scala/unit/kafka/admin/ReassignPartitionsClusterTest.scala b/core/src/test/scala/unit/kafka/admin/ReassignPartitionsClusterTest.scala
index 4968b57..2a24a37 100644
--- a/core/src/test/scala/unit/kafka/admin/ReassignPartitionsClusterTest.scala
+++ b/core/src/test/scala/unit/kafka/admin/ReassignPartitionsClusterTest.scala
@@ -19,9 +19,8 @@ import kafka.admin.ReassignPartitionsCommand._
import kafka.common.AdminCommandFailedException
import kafka.server.{KafkaConfig, KafkaServer}
import kafka.utils.TestUtils._
-import kafka.utils.ZkUtils._
-import kafka.utils.{Logging, TestUtils, ZkUtils}
-import kafka.zk.ZooKeeperTestHarness
+import kafka.utils.{Logging, TestUtils}
+import kafka.zk.{ReassignPartitionsZNode, ZooKeeperTestHarness}
import org.junit.Assert.{assertEquals, assertTrue}
import org.junit.{After, Before, Test}
import kafka.admin.ReplicationQuotaUtils._
@@ -85,7 +84,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
val partition = 0
// Get a random log directory on broker 101
val expectedLogDir = getRandomLogDirAssignment(101)
- createTopic(zkUtils, topicName, Map(partition -> Seq(100)), servers = servers)
+ createTopic(zkClient, topicName, Map(partition -> Seq(100)), servers = servers)
//When we move the replica on 100 to broker 101
val topicJson: String = s"""{"version":1,"partitions":[{"topic":"$topicName","partition":0,"replicas":[101],"log_dirs":["$expectedLogDir"]}]}"""
@@ -93,7 +92,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
waitForReassignmentToComplete()
//Then the replica should be on 101
- assertEquals(Seq(101), zkUtils.getPartitionAssignmentForTopics(Seq(topicName)).get(topicName).get(partition))
+ assertEquals(Seq(101), zkClient.getPartitionAssignmentForTopics(Set(topicName)).get(topicName).get(partition))
// The replica should be in the expected log directory on broker 101
val replica = new TopicPartitionReplica(topicName, 0, 101)
assertEquals(expectedLogDir, adminClient.describeReplicaLogDirs(Collections.singleton(replica)).all().get.get(replica).getCurrentReplicaLogDir)
@@ -105,7 +104,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
startBrokers(Seq(100, 101))
adminClient = createAdminClient(servers)
val expectedLogDir = getRandomLogDirAssignment(100)
- createTopic(zkUtils, topicName, Map(0 -> Seq(100)), servers = servers)
+ createTopic(zkClient, topicName, Map(0 -> Seq(100)), servers = servers)
// When we execute an assignment that moves an existing replica to another log directory on the same broker
val topicJson: String = s"""{"version":1,"partitions":[{"topic":"$topicName","partition":0,"replicas":[100],"log_dirs":["$expectedLogDir"]}]}"""
@@ -121,7 +120,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
val brokers = Array(100, 101, 102)
startBrokers(brokers)
adminClient = createAdminClient(servers)
- createTopic(zkUtils, topicName, Map(
+ createTopic(zkClient, topicName, Map(
0 -> Seq(100, 101),
1 -> Seq(100, 101),
2 -> Seq(100, 101)
@@ -147,7 +146,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
waitForReassignmentToComplete()
// Then the replicas should span all three brokers
- val actual = zkUtils.getPartitionAssignmentForTopics(Seq(topicName))(topicName)
+ val actual = zkClient.getPartitionAssignmentForTopics(Set(topicName))(topicName)
assertEquals(Seq(100, 101, 102), actual.values.flatten.toSeq.distinct.sorted)
// The replica should be in the expected log directory on broker 102 and 100
waitUntilTrue(() => {
@@ -163,7 +162,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
//Given partitions on 3 of 3 brokers
val brokers = Array(100, 101, 102)
startBrokers(brokers)
- createTopic(zkUtils, topicName, Map(
+ createTopic(zkClient, topicName, Map(
0 -> Seq(100, 101),
1 -> Seq(101, 102),
2 -> Seq(102, 100)
@@ -176,7 +175,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
waitForReassignmentToComplete()
//Then replicas should only span the first two brokers
- val actual = zkUtils.getPartitionAssignmentForTopics(Seq(topicName))(topicName)
+ val actual = zkClient.getPartitionAssignmentForTopics(Set(topicName))(topicName)
assertEquals(Seq(100, 101), actual.values.flatten.toSeq.distinct.sorted)
}
@@ -186,12 +185,12 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
val brokers = Array(100, 101, 102)
startBrokers(brokers)
adminClient = createAdminClient(servers)
- createTopic(zkUtils, "topic1", Map(
+ createTopic(zkClient, "topic1", Map(
0 -> Seq(100, 101),
1 -> Seq(101, 102),
2 -> Seq(102, 100)
), servers = servers)
- createTopic(zkUtils, "topic2", Map(
+ createTopic(zkClient, "topic2", Map(
0 -> Seq(100, 101),
1 -> Seq(101, 102),
2 -> Seq(102, 100)
@@ -217,7 +216,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
waitForReassignmentToComplete()
//Then the proposed changes should have been made
- val actual = zkUtils.getPartitionAssignmentForTopics(Seq("topic1", "topic2"))
+ val actual = zkClient.getPartitionAssignmentForTopics(Set("topic1", "topic2"))
assertEquals(Seq(100, 102), actual("topic1")(0))//changed
assertEquals(Seq(101, 102), actual("topic1")(1))
assertEquals(Seq(100, 102), actual("topic1")(2))//changed
@@ -237,7 +236,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
//Given partitions on 3 of 3 brokers
val brokers = Array(100, 101, 102)
startBrokers(brokers)
- createTopic(zkUtils, topicName, Map(
+ createTopic(zkClient, topicName, Map(
0 -> Seq(100, 101)
), servers = servers)
@@ -264,7 +263,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
val took = System.currentTimeMillis() - start - delayMs
//Check move occurred
- val actual = zkUtils.getPartitionAssignmentForTopics(Seq(topicName))(topicName)
+ val actual = zkClient.getPartitionAssignmentForTopics(Set(topicName))(topicName)
assertEquals(Seq(101, 102), actual.values.flatten.toSeq.distinct.sorted)
//Then command should have taken longer than the throttle rate
@@ -280,13 +279,13 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
//Given 6 brokers, two topics
val brokers = Array(100, 101, 102, 103, 104, 105)
startBrokers(brokers)
- createTopic(zkUtils, "topic1", Map(
+ createTopic(zkClient, "topic1", Map(
0 -> Seq(100, 101),
1 -> Seq(100, 101),
2 -> Seq(103, 104) //will leave in place
), servers = servers)
- createTopic(zkUtils, "topic2", Map(
+ createTopic(zkClient, "topic2", Map(
0 -> Seq(104, 105),
1 -> Seq(104, 105),
2 -> Seq(103, 104)//will leave in place
@@ -325,7 +324,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
//Given partitions on 3 of 3 brokers
val brokers = Array(100, 101, 102)
startBrokers(brokers)
- createTopic(zkUtils, topicName, Map(
+ createTopic(zkClient, topicName, Map(
0 -> Seq(100, 101)
), servers = servers)
@@ -367,7 +366,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
checkThrottleConfigRemovedFromZK(adminZkClient, topicName, servers)
//Check move occurred
- val actual = zkUtils.getPartitionAssignmentForTopics(Seq(topicName))(topicName)
+ val actual = zkClient.getPartitionAssignmentForTopics(Set(topicName))(topicName)
assertEquals(Seq(101, 102), actual.values.flatten.toSeq.distinct.sorted)
}
@@ -375,7 +374,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
def shouldFailIfProposedDoesNotMatchExisting() {
//Given a single replica on server 100
startBrokers(Seq(100, 101))
- createTopic(zkUtils, topicName, Map(0 -> Seq(100)), servers = servers)
+ createTopic(zkClient, topicName, Map(0 -> Seq(100)), servers = servers)
//When we execute an assignment that includes an invalid partition (1:101 in this case)
val topicJson = s"""{"version":1,"partitions":[{"topic":"$topicName","partition":1,"replicas":[101]}]}"""
@@ -386,7 +385,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
def shouldFailIfProposedHasEmptyReplicaList() {
//Given a single replica on server 100
startBrokers(Seq(100, 101))
- createTopic(zkUtils, topicName, Map(0 -> Seq(100)), servers = servers)
+ createTopic(zkClient, topicName, Map(0 -> Seq(100)), servers = servers)
//When we execute an assignment that specifies an empty replica list (0: empty list in this case)
val topicJson = s"""{"version":1,"partitions":[{"topic":"$topicName","partition":0,"replicas":[]}]}"""
@@ -397,7 +396,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
def shouldFailIfProposedHasInvalidBrokerID() {
//Given a single replica on server 100
startBrokers(Seq(100, 101))
- createTopic(zkUtils, topicName, Map(0 -> Seq(100)), servers = servers)
+ createTopic(zkClient, topicName, Map(0 -> Seq(100)), servers = servers)
//When we execute an assignment that specifies an invalid brokerID (102: invalid broker ID in this case)
val topicJson = s"""{"version":1,"partitions":[{"topic":"$topicName","partition":0,"replicas":[101, 102]}]}"""
@@ -409,7 +408,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
// Given a single replica on server 100
startBrokers(Seq(100, 101))
adminClient = createAdminClient(servers)
- createTopic(zkUtils, topicName, Map(0 -> Seq(100)), servers = servers)
+ createTopic(zkClient, topicName, Map(0 -> Seq(100)), servers = servers)
// When we execute an assignment that specifies an invalid log directory
val topicJson: String = s"""{"version":1,"partitions":[{"topic":"$topicName","partition":0,"replicas":[101],"log_dirs":["invalidDir"]}]}"""
@@ -422,7 +421,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
startBrokers(Seq(100, 101))
adminClient = createAdminClient(servers)
val logDir = getRandomLogDirAssignment(100)
- createTopic(zkUtils, topicName, Map(0 -> Seq(100)), servers = servers)
+ createTopic(zkClient, topicName, Map(0 -> Seq(100)), servers = servers)
// When we execute an assignment whose length of replicas doesn't match that of replicas
val topicJson: String = s"""{"version":1,"partitions":[{"topic":"$topicName","partition":0,"replicas":[101],"log_dirs":["$logDir", "$logDir"]}]}"""
@@ -436,10 +435,10 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
startBrokers(Seq(0, 1, 2, 3))
//With up several small topics
- createTopic(zkUtils, "orders", Map(0 -> List(0, 1, 2), 1 -> List(0, 1, 2)), servers)
- createTopic(zkUtils, "payments", Map(0 -> List(0, 1), 1 -> List(0, 1)), servers)
- createTopic(zkUtils, "deliveries", Map(0 -> List(0)), servers)
- createTopic(zkUtils, "customers", Map(0 -> List(0), 1 -> List(1), 2 -> List(2), 3 -> List(3)), servers)
+ createTopic(zkClient, "orders", Map(0 -> List(0, 1, 2), 1 -> List(0, 1, 2)), servers)
+ createTopic(zkClient, "payments", Map(0 -> List(0, 1), 1 -> List(0, 1)), servers)
+ createTopic(zkClient, "deliveries", Map(0 -> List(0)), servers)
+ createTopic(zkClient, "customers", Map(0 -> List(0), 1 -> List(1), 2 -> List(2), 3 -> List(3)), servers)
//Define a move for some of them
val move = Map(
@@ -455,17 +454,17 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
waitForReassignmentToComplete()
//Check moved replicas did move
- assertEquals(Seq(0, 2, 3), zkUtils.getReplicasForPartition("orders", 0))
- assertEquals(Seq(0, 1, 2), zkUtils.getReplicasForPartition("orders", 1))
- assertEquals(Seq(1, 2), zkUtils.getReplicasForPartition("payments", 1))
- assertEquals(Seq(1, 2), zkUtils.getReplicasForPartition("deliveries", 0))
+ assertEquals(Seq(0, 2, 3), zkClient.getReplicasForPartition(new TopicPartition("orders", 0)))
+ assertEquals(Seq(0, 1, 2), zkClient.getReplicasForPartition(new TopicPartition("orders", 1)))
+ assertEquals(Seq(1, 2), zkClient.getReplicasForPartition(new TopicPartition("payments", 1)))
+ assertEquals(Seq(1, 2), zkClient.getReplicasForPartition(new TopicPartition("deliveries", 0)))
//Check untouched replicas are still there
- assertEquals(Seq(0, 1), zkUtils.getReplicasForPartition("payments", 0))
- assertEquals(Seq(0), zkUtils.getReplicasForPartition("customers", 0))
- assertEquals(Seq(1), zkUtils.getReplicasForPartition("customers", 1))
- assertEquals(Seq(2), zkUtils.getReplicasForPartition("customers", 2))
- assertEquals(Seq(3), zkUtils.getReplicasForPartition("customers", 3))
+ assertEquals(Seq(0, 1), zkClient.getReplicasForPartition(new TopicPartition("payments", 0)))
+ assertEquals(Seq(0), zkClient.getReplicasForPartition(new TopicPartition("customers", 0)))
+ assertEquals(Seq(1), zkClient.getReplicasForPartition(new TopicPartition("customers", 1)))
+ assertEquals(Seq(2), zkClient.getReplicasForPartition(new TopicPartition("customers", 2)))
+ assertEquals(Seq(3), zkClient.getReplicasForPartition(new TopicPartition("customers", 3)))
}
/**
@@ -478,10 +477,10 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
def shouldPerformMultipleReassignmentOperationsOverVariousTopics() {
startBrokers(Seq(0, 1, 2, 3))
- createTopic(zkUtils, "orders", Map(0 -> List(0, 1, 2), 1 -> List(0, 1, 2)), servers)
- createTopic(zkUtils, "payments", Map(0 -> List(0, 1), 1 -> List(0, 1)), servers)
- createTopic(zkUtils, "deliveries", Map(0 -> List(0)), servers)
- createTopic(zkUtils, "customers", Map(0 -> List(0), 1 -> List(1), 2 -> List(2), 3 -> List(3)), servers)
+ createTopic(zkClient, "orders", Map(0 -> List(0, 1, 2), 1 -> List(0, 1, 2)), servers)
+ createTopic(zkClient, "payments", Map(0 -> List(0, 1), 1 -> List(0, 1)), servers)
+ createTopic(zkClient, "deliveries", Map(0 -> List(0)), servers)
+ createTopic(zkClient, "customers", Map(0 -> List(0), 1 -> List(1), 2 -> List(2), 3 -> List(3)), servers)
val firstMove = Map(
new TopicPartition("orders", 0) -> Seq(0, 2, 3), //moves
@@ -495,17 +494,17 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
waitForReassignmentToComplete(pause = 1L)
// Check moved replicas did move
- assertEquals(Seq(0, 2, 3), zkUtils.getReplicasForPartition("orders", 0))
- assertEquals(Seq(0, 1, 2), zkUtils.getReplicasForPartition("orders", 1))
- assertEquals(Seq(1, 2), zkUtils.getReplicasForPartition("payments", 1))
- assertEquals(Seq(1, 2), zkUtils.getReplicasForPartition("deliveries", 0))
+ assertEquals(Seq(0, 2, 3), zkClient.getReplicasForPartition(new TopicPartition("orders", 0)))
+ assertEquals(Seq(0, 1, 2), zkClient.getReplicasForPartition(new TopicPartition("orders", 1)))
+ assertEquals(Seq(1, 2), zkClient.getReplicasForPartition(new TopicPartition("payments", 1)))
+ assertEquals(Seq(1, 2), zkClient.getReplicasForPartition(new TopicPartition("deliveries", 0)))
// Check untouched replicas are still there
- assertEquals(Seq(0, 1), zkUtils.getReplicasForPartition("payments", 0))
- assertEquals(Seq(0), zkUtils.getReplicasForPartition("customers", 0))
- assertEquals(Seq(1), zkUtils.getReplicasForPartition("customers", 1))
- assertEquals(Seq(2), zkUtils.getReplicasForPartition("customers", 2))
- assertEquals(Seq(3), zkUtils.getReplicasForPartition("customers", 3))
+ assertEquals(Seq(0, 1), zkClient.getReplicasForPartition(new TopicPartition("payments", 0)))
+ assertEquals(Seq(0), zkClient.getReplicasForPartition(new TopicPartition("customers", 0)))
+ assertEquals(Seq(1), zkClient.getReplicasForPartition(new TopicPartition("customers", 1)))
+ assertEquals(Seq(2), zkClient.getReplicasForPartition(new TopicPartition("customers", 2)))
+ assertEquals(Seq(3), zkClient.getReplicasForPartition(new TopicPartition("customers", 3)))
// Define a move for some of them
val secondMove = Map(
@@ -520,17 +519,17 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
waitForReassignmentToComplete(pause = 1L)
// Check moved replicas did move
- assertEquals(Seq(0, 2, 3), zkUtils.getReplicasForPartition("orders", 0))
- assertEquals(Seq(3, 1, 2), zkUtils.getReplicasForPartition("orders", 1))
- assertEquals(Seq(2, 1), zkUtils.getReplicasForPartition("payments", 1))
- assertEquals(Seq(1, 2, 3), zkUtils.getReplicasForPartition("deliveries", 0))
+ assertEquals(Seq(0, 2, 3), zkClient.getReplicasForPartition(new TopicPartition("orders", 0)))
+ assertEquals(Seq(3, 1, 2), zkClient.getReplicasForPartition(new TopicPartition("orders", 1)))
+ assertEquals(Seq(2, 1), zkClient.getReplicasForPartition(new TopicPartition("payments", 1)))
+ assertEquals(Seq(1, 2, 3), zkClient.getReplicasForPartition(new TopicPartition("deliveries", 0)))
//Check untouched replicas are still there
- assertEquals(Seq(0, 1), zkUtils.getReplicasForPartition("payments", 0))
- assertEquals(Seq(0), zkUtils.getReplicasForPartition("customers", 0))
- assertEquals(Seq(1), zkUtils.getReplicasForPartition("customers", 1))
- assertEquals(Seq(2), zkUtils.getReplicasForPartition("customers", 2))
- assertEquals(Seq(3), zkUtils.getReplicasForPartition("customers", 3))
+ assertEquals(Seq(0, 1), zkClient.getReplicasForPartition(new TopicPartition("payments", 0)))
+ assertEquals(Seq(0), zkClient.getReplicasForPartition(new TopicPartition("customers", 0)))
+ assertEquals(Seq(1), zkClient.getReplicasForPartition(new TopicPartition("customers", 1)))
+ assertEquals(Seq(2), zkClient.getReplicasForPartition(new TopicPartition("customers", 2)))
+ assertEquals(Seq(3), zkClient.getReplicasForPartition(new TopicPartition("customers", 3)))
// We set the znode and then continuously attempt to set it again to exercise the case where the znode is set
// immediately after deletion (i.e. before we set the watcher again)
@@ -554,17 +553,17 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
waitForReassignmentToComplete(pause = 1L)
// Check moved replicas for thirdMove and fourthMove
- assertEquals(Seq(1, 2, 3), zkUtils.getReplicasForPartition("orders", 0))
- assertEquals(Seq(2, 3), zkUtils.getReplicasForPartition("payments", 1))
+ assertEquals(Seq(1, 2, 3), zkClient.getReplicasForPartition(new TopicPartition("orders", 0)))
+ assertEquals(Seq(2, 3), zkClient.getReplicasForPartition(new TopicPartition("payments", 1)))
//Check untouched replicas are still there
- assertEquals(Seq(3, 1, 2), zkUtils.getReplicasForPartition("orders", 1))
- assertEquals(Seq(1, 2, 3), zkUtils.getReplicasForPartition("deliveries", 0))
- assertEquals(Seq(0, 1), zkUtils.getReplicasForPartition("payments", 0))
- assertEquals(Seq(0), zkUtils.getReplicasForPartition("customers", 0))
- assertEquals(Seq(1), zkUtils.getReplicasForPartition("customers", 1))
- assertEquals(Seq(2), zkUtils.getReplicasForPartition("customers", 2))
- assertEquals(Seq(3), zkUtils.getReplicasForPartition("customers", 3))
+ assertEquals(Seq(3, 1, 2), zkClient.getReplicasForPartition(new TopicPartition("orders", 1)))
+ assertEquals(Seq(1, 2, 3), zkClient.getReplicasForPartition(new TopicPartition("deliveries", 0)))
+ assertEquals(Seq(0, 1), zkClient.getReplicasForPartition(new TopicPartition("payments", 0)))
+ assertEquals(Seq(0), zkClient.getReplicasForPartition(new TopicPartition("customers", 0)))
+ assertEquals(Seq(1), zkClient.getReplicasForPartition(new TopicPartition("customers", 1)))
+ assertEquals(Seq(2), zkClient.getReplicasForPartition(new TopicPartition("customers", 2)))
+ assertEquals(Seq(3), zkClient.getReplicasForPartition(new TopicPartition("customers", 3)))
}
/**
@@ -574,7 +573,7 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
@Test
def shouldTriggerReassignmentOnControllerStartup(): Unit = {
startBrokers(Seq(0, 1, 2))
- createTopic(zkUtils, "orders", Map(0 -> List(0, 1), 1 -> List(1, 2)), servers)
+ createTopic(zkClient, "orders", Map(0 -> List(0, 1), 1 -> List(1, 2)), servers)
servers.foreach(_.shutdown())
val firstMove = Map(
@@ -589,14 +588,14 @@ class ReassignPartitionsClusterTest extends ZooKeeperTestHarness with Logging {
servers.foreach(_.startup())
waitForReassignmentToComplete()
- assertEquals(Seq(2, 1), zkUtils.getReplicasForPartition("orders", 0))
- assertEquals(Seq(1, 2), zkUtils.getReplicasForPartition("orders", 1))
- assertEquals(Seq.empty, zkUtils.getReplicasForPartition("customers", 0))
+ assertEquals(Seq(2, 1), zkClient.getReplicasForPartition(new TopicPartition("orders", 0)))
+ assertEquals(Seq(1, 2), zkClient.getReplicasForPartition(new TopicPartition("orders", 1)))
+ assertEquals(Seq.empty, zkClient.getReplicasForPartition(new TopicPartition("customers", 0)))
}
def waitForReassignmentToComplete(pause: Long = 100L) {
- waitUntilTrue(() => !zkUtils.pathExists(ReassignPartitionsPath),
- s"Znode ${ZkUtils.ReassignPartitionsPath} wasn't deleted", pause = pause)
+ waitUntilTrue(() => !zkClient.reassignPartitionsInProgress,
+ s"Znode ${ReassignPartitionsZNode.path} wasn't deleted", pause = pause)
}
def json(topic: String*): String = {
diff --git a/core/src/test/scala/unit/kafka/admin/TopicCommandTest.scala b/core/src/test/scala/unit/kafka/admin/TopicCommandTest.scala
index 180f257..291082c 100644
--- a/core/src/test/scala/unit/kafka/admin/TopicCommandTest.scala
+++ b/core/src/test/scala/unit/kafka/admin/TopicCommandTest.scala
@@ -20,10 +20,9 @@ import org.junit.Assert._
import org.junit.Test
import kafka.utils.Logging
import kafka.utils.TestUtils
-import kafka.zk.ZooKeeperTestHarness
+import kafka.zk.{ConfigEntityChangeNotificationZNode, ZooKeeperTestHarness}
import kafka.server.ConfigType
import kafka.admin.TopicCommand.TopicCommandOptions
-import kafka.utils.ZkUtils.ConfigChangesPath
import kafka.utils.ZkUtils.getDeleteTopicPath
import org.apache.kafka.common.errors.TopicExistsException
import org.apache.kafka.common.internals.Topic
@@ -38,7 +37,7 @@ class TopicCommandTest extends ZooKeeperTestHarness with Logging with RackAwareT
val cleanupVal = "compact"
// create brokers
val brokers = List(0, 1, 2)
- TestUtils.createBrokersInZk(zkUtils, brokers)
+ TestUtils.createBrokersInZk(zkClient, brokers)
// create the topic
val createOpts = new TopicCommandOptions(Array("--partitions", numPartitionsOriginal.toString,
"--replication-factor", "1",
@@ -50,7 +49,7 @@ class TopicCommandTest extends ZooKeeperTestHarness with Logging with RackAwareT
assertTrue("Properties after creation have incorrect value", props.getProperty(cleanupKey).equals(cleanupVal))
// pre-create the topic config changes path to avoid a NoNodeException
- zkUtils.createPersistentPath(ConfigChangesPath)
+ zkClient.makeSurePersistentPathExists(ConfigEntityChangeNotificationZNode.path)
// modify the topic to add new partitions
val numPartitionsModified = 3
@@ -63,13 +62,14 @@ class TopicCommandTest extends ZooKeeperTestHarness with Logging with RackAwareT
@Test
def testTopicDeletion() {
+
val normalTopic = "test"
val numPartitionsOriginal = 1
// create brokers
val brokers = List(0, 1, 2)
- TestUtils.createBrokersInZk(zkUtils, brokers)
+ TestUtils.createBrokersInZk(zkClient, brokers)
// create the NormalTopic
val createOpts = new TopicCommandOptions(Array("--partitions", numPartitionsOriginal.toString,
@@ -104,7 +104,7 @@ class TopicCommandTest extends ZooKeeperTestHarness with Logging with RackAwareT
def testDeleteIfExists() {
// create brokers
val brokers = List(0, 1, 2)
- TestUtils.createBrokersInZk(zkUtils, brokers)
+ TestUtils.createBrokersInZk(zkClient, brokers)
// delete a topic that does not exist without --if-exists
val deleteOpts = new TopicCommandOptions(Array("--topic", "test"))
@@ -121,7 +121,7 @@ class TopicCommandTest extends ZooKeeperTestHarness with Logging with RackAwareT
def testAlterIfExists() {
// create brokers
val brokers = List(0, 1, 2)
- TestUtils.createBrokersInZk(zkUtils, brokers)
+ TestUtils.createBrokersInZk(zkClient, brokers)
// alter a topic that does not exist without --if-exists
val alterOpts = new TopicCommandOptions(Array("--topic", "test", "--partitions", "1"))
@@ -138,7 +138,7 @@ class TopicCommandTest extends ZooKeeperTestHarness with Logging with RackAwareT
def testCreateIfNotExists() {
// create brokers
val brokers = List(0, 1, 2)
- TestUtils.createBrokersInZk(zkUtils, brokers)
+ TestUtils.createBrokersInZk(zkClient, brokers)
val topic = "test"
val numPartitions = 1
@@ -162,7 +162,7 @@ class TopicCommandTest extends ZooKeeperTestHarness with Logging with RackAwareT
@Test
def testCreateAlterTopicWithRackAware() {
val rackInfo = Map(0 -> "rack1", 1 -> "rack2", 2 -> "rack2", 3 -> "rack1", 4 -> "rack3", 5 -> "rack3")
- TestUtils.createBrokersInZk(toBrokerMetadata(rackInfo), zkUtils)
+ TestUtils.createBrokersInZk(toBrokerMetadata(rackInfo), zkClient)
val numPartitions = 18
val replicationFactor = 3
@@ -172,7 +172,7 @@ class TopicCommandTest extends ZooKeeperTestHarness with Logging with RackAwareT
"--topic", "foo"))
TopicCommand.createTopic(zkClient, createOpts)
- var assignment = zkUtils.getReplicaAssignmentForTopics(Seq("foo")).map { case (tp, replicas) =>
+ var assignment = zkClient.getReplicaAssignmentForTopics(Set("foo")).map { case (tp, replicas) =>
tp.partition -> replicas
}
checkReplicaDistribution(assignment, rackInfo, rackInfo.size, numPartitions, replicationFactor)
@@ -183,7 +183,7 @@ class TopicCommandTest extends ZooKeeperTestHarness with Logging with RackAwareT
"--partitions", alteredNumPartitions.toString,
"--topic", "foo"))
TopicCommand.alterTopic(zkClient, alterOpts)
- assignment = zkUtils.getReplicaAssignmentForTopics(Seq("foo")).map { case (tp, replicas) =>
+ assignment = zkClient.getReplicaAssignmentForTopics(Set("foo")).map { case (tp, replicas) =>
tp.partition -> replicas
}
checkReplicaDistribution(assignment, rackInfo, rackInfo.size, alteredNumPartitions, replicationFactor)
@@ -195,13 +195,13 @@ class TopicCommandTest extends ZooKeeperTestHarness with Logging with RackAwareT
val topic = "testtopic"
val markedForDeletionDescribe = "MarkedForDeletion"
val markedForDeletionList = "marked for deletion"
- TestUtils.createBrokersInZk(zkUtils, brokers)
+ TestUtils.createBrokersInZk(zkClient, brokers)
val createOpts = new TopicCommandOptions(Array("--partitions", "1", "--replication-factor", "1", "--topic", topic))
TopicCommand.createTopic(zkClient, createOpts)
// delete the broker first, so when we attempt to delete the topic it gets into "marked for deletion"
- TestUtils.deleteBrokersInZk(zkUtils, brokers)
+ TestUtils.deleteBrokersInZk(zkClient, brokers)
TopicCommand.deleteTopic(zkClient, new TopicCommandOptions(Array("--topic", topic)))
// Test describe topics
diff --git a/core/src/test/scala/unit/kafka/consumer/ConsumerIteratorTest.scala b/core/src/test/scala/unit/kafka/consumer/ConsumerIteratorTest.scala
index 5571e03..f46d8cf 100755
--- a/core/src/test/scala/unit/kafka/consumer/ConsumerIteratorTest.scala
+++ b/core/src/test/scala/unit/kafka/consumer/ConsumerIteratorTest.scala
@@ -60,7 +60,7 @@ class ConsumerIteratorTest extends KafkaServerTestHarness {
new AtomicLong(0),
new AtomicInteger(0),
""))
- createTopic(zkUtils, topic, partitionReplicaAssignment = Map(0 -> Seq(configs.head.brokerId)), servers = servers)
+ createTopic(zkClient, topic, partitionReplicaAssignment = Map(0 -> Seq(configs.head.brokerId)), servers = servers)
}
@Test
diff --git a/core/src/test/scala/unit/kafka/consumer/ZookeeperConsumerConnectorTest.scala b/core/src/test/scala/unit/kafka/consumer/ZookeeperConsumerConnectorTest.scala
index c36400b..729ab1a 100644
--- a/core/src/test/scala/unit/kafka/consumer/ZookeeperConsumerConnectorTest.scala
+++ b/core/src/test/scala/unit/kafka/consumer/ZookeeperConsumerConnectorTest.scala
@@ -96,8 +96,8 @@ class ZookeeperConsumerConnectorTest extends KafkaServerTestHarness with Logging
sendMessages(servers, topic, nMessages, 1)
// wait to make sure the topic and partition have a leader for the successful case
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0)
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 1)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 1)
TestUtils.waitUntilMetadataIsPropagated(servers, topic, 0)
TestUtils.waitUntilMetadataIsPropagated(servers, topic, 1)
@@ -129,8 +129,8 @@ class ZookeeperConsumerConnectorTest extends KafkaServerTestHarness with Logging
val sentMessages2 = sendMessages(servers, topic, nMessages, 0) ++
sendMessages(servers, topic, nMessages, 1)
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0)
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 1)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 1)
val receivedMessages2 = getMessages(topicMessageStreams1, nMessages) ++ getMessages(topicMessageStreams2, nMessages)
assertEquals(sentMessages2.sorted, receivedMessages2.sorted)
@@ -150,8 +150,8 @@ class ZookeeperConsumerConnectorTest extends KafkaServerTestHarness with Logging
val sentMessages3 = sendMessages(servers, topic, nMessages, 0) ++
sendMessages(servers, topic, nMessages, 1)
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0)
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 1)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 1)
val receivedMessages3 = getMessages(topicMessageStreams1, nMessages) ++ getMessages(topicMessageStreams2, nMessages)
assertEquals(sentMessages3.sorted, receivedMessages3.sorted)
@@ -184,8 +184,8 @@ class ZookeeperConsumerConnectorTest extends KafkaServerTestHarness with Logging
val sentMessages1 = sendMessages(servers, topic, nMessages, 0, GZIPCompressionCodec) ++
sendMessages(servers, topic, nMessages, 1, GZIPCompressionCodec)
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0)
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 1)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 1)
TestUtils.waitUntilMetadataIsPropagated(servers, topic, 0)
TestUtils.waitUntilMetadataIsPropagated(servers, topic, 1)
@@ -217,8 +217,8 @@ class ZookeeperConsumerConnectorTest extends KafkaServerTestHarness with Logging
val sentMessages2 = sendMessages(servers, topic, nMessages, 0, GZIPCompressionCodec) ++
sendMessages(servers, topic, nMessages, 1, GZIPCompressionCodec)
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0)
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 1)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 1)
val receivedMessages2 = getMessages(topicMessageStreams1, nMessages) ++ getMessages(topicMessageStreams2, nMessages)
assertEquals(sentMessages2.sorted, receivedMessages2.sorted)
@@ -238,8 +238,8 @@ class ZookeeperConsumerConnectorTest extends KafkaServerTestHarness with Logging
val sentMessages3 = sendMessages(servers, topic, nMessages, 0, GZIPCompressionCodec) ++
sendMessages(servers, topic, nMessages, 1, GZIPCompressionCodec)
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0)
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 1)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 1)
val receivedMessages3 = getMessages(topicMessageStreams1, nMessages) ++ getMessages(topicMessageStreams2, nMessages)
assertEquals(sentMessages3.sorted, receivedMessages3.sorted)
@@ -293,8 +293,8 @@ class ZookeeperConsumerConnectorTest extends KafkaServerTestHarness with Logging
val consumerConfig = new ConsumerConfig(TestUtils.createConsumerProperties(zkConnect, group, consumer1))
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0)
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 1)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0)
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, 1)
val zkConsumerConnector =
new ZookeeperConsumerConnector(consumerConfig, true)
@@ -324,7 +324,7 @@ class ZookeeperConsumerConnectorTest extends KafkaServerTestHarness with Logging
val zkUtils = ZkUtils(zkConnect, 6000, 30000, false)
// create topic topic1 with 1 partition on broker 0
- createTopic(zkUtils, topic, numPartitions = 1, replicationFactor = 1, servers = servers)
+ createTopic(zkClient, topic, numPartitions = 1, replicationFactor = 1, servers = servers)
// send some messages to each broker
val sentMessages1 = sendMessages(servers, topic, nMessages)
diff --git a/core/src/test/scala/unit/kafka/controller/ControllerIntegrationTest.scala b/core/src/test/scala/unit/kafka/controller/ControllerIntegrationTest.scala
index d917fe1..32435c6 100644
--- a/core/src/test/scala/unit/kafka/controller/ControllerIntegrationTest.scala
+++ b/core/src/test/scala/unit/kafka/controller/ControllerIntegrationTest.scala
@@ -79,7 +79,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
servers = makeServers(1)
val tp = TopicAndPartition("t", 0)
val assignment = Map(tp.partition -> Seq(0))
- TestUtils.createTopic(zkUtils, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
+ TestUtils.createTopic(zkClient, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
waitForPartitionState(tp, KafkaController.InitialControllerEpoch, 0, LeaderAndIsr.initialLeaderEpoch,
"failed to get expected partition state upon topic creation")
}
@@ -93,7 +93,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
servers(otherBrokerId).awaitShutdown()
val tp = TopicAndPartition("t", 0)
val assignment = Map(tp.partition -> Seq(otherBrokerId, controllerId))
- TestUtils.createTopic(zkUtils, tp.topic, partitionReplicaAssignment = assignment, servers = servers.take(1))
+ TestUtils.createTopic(zkClient, tp.topic, partitionReplicaAssignment = assignment, servers = servers.take(1))
waitForPartitionState(tp, KafkaController.InitialControllerEpoch, controllerId, LeaderAndIsr.initialLeaderEpoch,
"failed to get expected partition state upon topic creation")
}
@@ -105,7 +105,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
val tp1 = TopicAndPartition("t", 1)
val assignment = Map(tp0.partition -> Seq(0))
val expandedAssignment = Map(tp0.partition -> Seq(0), tp1.partition -> Seq(0))
- TestUtils.createTopic(zkUtils, tp0.topic, partitionReplicaAssignment = assignment, servers = servers)
+ TestUtils.createTopic(zkClient, tp0.topic, partitionReplicaAssignment = assignment, servers = servers)
zkUtils.updatePersistentPath(ZkUtils.getTopicPath(tp0.topic), zkUtils.replicaAssignmentZkData(expandedAssignment.map(kv => kv._1.toString -> kv._2)))
waitForPartitionState(tp1, KafkaController.InitialControllerEpoch, 0, LeaderAndIsr.initialLeaderEpoch,
"failed to get expected partition state upon topic partition expansion")
@@ -121,7 +121,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
val tp1 = TopicAndPartition("t", 1)
val assignment = Map(tp0.partition -> Seq(otherBrokerId, controllerId))
val expandedAssignment = Map(tp0.partition -> Seq(otherBrokerId, controllerId), tp1.partition -> Seq(otherBrokerId, controllerId))
- TestUtils.createTopic(zkUtils, tp0.topic, partitionReplicaAssignment = assignment, servers = servers)
+ TestUtils.createTopic(zkClient, tp0.topic, partitionReplicaAssignment = assignment, servers = servers)
servers(otherBrokerId).shutdown()
servers(otherBrokerId).awaitShutdown()
zkUtils.updatePersistentPath(ZkUtils.getTopicPath(tp0.topic), zkUtils.replicaAssignmentZkData(expandedAssignment.map(kv => kv._1.toString -> kv._2)))
@@ -142,7 +142,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
val tp = TopicAndPartition("t", 0)
val assignment = Map(tp.partition -> Seq(controllerId))
val reassignment = Map(tp -> Seq(otherBrokerId))
- TestUtils.createTopic(zkUtils, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
+ TestUtils.createTopic(zkClient, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
zkUtils.createPersistentPath(ZkUtils.ReassignPartitionsPath, ZkUtils.formatAsReassignmentJson(reassignment))
waitForPartitionState(tp, KafkaController.InitialControllerEpoch, otherBrokerId, LeaderAndIsr.initialLeaderEpoch + 3,
"failed to get expected partition state after partition reassignment")
@@ -163,7 +163,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
val tp = TopicAndPartition("t", 0)
val assignment = Map(tp.partition -> Seq(controllerId))
val reassignment = Map(tp -> Seq(otherBrokerId))
- TestUtils.createTopic(zkUtils, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
+ TestUtils.createTopic(zkClient, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
servers(otherBrokerId).shutdown()
servers(otherBrokerId).awaitShutdown()
zkUtils.createPersistentPath(ZkUtils.ReassignPartitionsPath, ZkUtils.formatAsReassignmentJson(reassignment))
@@ -181,7 +181,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
val tp = TopicAndPartition("t", 0)
val assignment = Map(tp.partition -> Seq(controllerId))
val reassignment = Map(tp -> Seq(otherBrokerId))
- TestUtils.createTopic(zkUtils, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
+ TestUtils.createTopic(zkClient, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
servers(otherBrokerId).shutdown()
servers(otherBrokerId).awaitShutdown()
zkUtils.createPersistentPath(ZkUtils.ReassignPartitionsPath, ZkUtils.formatAsReassignmentJson(reassignment))
@@ -203,7 +203,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
val otherBroker = servers.find(_.config.brokerId != controllerId).get
val tp = TopicAndPartition("t", 0)
val assignment = Map(tp.partition -> Seq(otherBroker.config.brokerId, controllerId))
- TestUtils.createTopic(zkUtils, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
+ TestUtils.createTopic(zkClient, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
preferredReplicaLeaderElection(controllerId, otherBroker, tp, assignment(tp.partition).toSet, LeaderAndIsr.initialLeaderEpoch)
}
@@ -214,7 +214,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
val otherBroker = servers.find(_.config.brokerId != controllerId).get
val tp = TopicAndPartition("t", 0)
val assignment = Map(tp.partition -> Seq(otherBroker.config.brokerId, controllerId))
- TestUtils.createTopic(zkUtils, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
+ TestUtils.createTopic(zkClient, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
preferredReplicaLeaderElection(controllerId, otherBroker, tp, assignment(tp.partition).toSet, LeaderAndIsr.initialLeaderEpoch)
preferredReplicaLeaderElection(controllerId, otherBroker, tp, assignment(tp.partition).toSet, LeaderAndIsr.initialLeaderEpoch + 2)
}
@@ -226,7 +226,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
val otherBrokerId = servers.map(_.config.brokerId).filter(_ != controllerId).head
val tp = TopicAndPartition("t", 0)
val assignment = Map(tp.partition -> Seq(otherBrokerId, controllerId))
- TestUtils.createTopic(zkUtils, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
+ TestUtils.createTopic(zkClient, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
servers(otherBrokerId).shutdown()
servers(otherBrokerId).awaitShutdown()
zkUtils.createPersistentPath(ZkUtils.PreferredReplicaLeaderElectionPath, ZkUtils.preferredReplicaLeaderElectionZkData(Set(tp)))
@@ -243,7 +243,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
val otherBrokerId = servers.map(_.config.brokerId).filter(_ != controllerId).head
val tp = TopicAndPartition("t", 0)
val assignment = Map(tp.partition -> Seq(1, 0))
- TestUtils.createTopic(zkUtils, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
+ TestUtils.createTopic(zkClient, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
servers(otherBrokerId).shutdown()
servers(otherBrokerId).awaitShutdown()
waitForPartitionState(tp, KafkaController.InitialControllerEpoch, controllerId, LeaderAndIsr.initialLeaderEpoch + 1,
@@ -260,7 +260,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
val otherBrokerId = servers.map(_.config.brokerId).filter(_ != controllerId).head
val tp = TopicAndPartition("t", 0)
val assignment = Map(tp.partition -> Seq(otherBrokerId))
- TestUtils.createTopic(zkUtils, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
+ TestUtils.createTopic(zkClient, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
waitForPartitionState(tp, KafkaController.InitialControllerEpoch, otherBrokerId, LeaderAndIsr.initialLeaderEpoch,
"failed to get expected partition state upon topic creation")
servers(otherBrokerId).shutdown()
@@ -280,7 +280,7 @@ class ControllerIntegrationTest extends ZooKeeperTestHarness {
val otherBrokerId = servers.map(_.config.brokerId).filter(_ != controllerId).head
val tp = TopicAndPartition("t", 0)
val assignment = Map(tp.partition -> Seq(otherBrokerId))
- TestUtils.createTopic(zkUtils, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
+ TestUtils.createTopic(zkClient, tp.topic, partitionReplicaAssignment = assignment, servers = servers)
waitForPartitionState(tp, KafkaController.InitialControllerEpoch, otherBrokerId, LeaderAndIsr.initialLeaderEpoch,
"failed to get expected partition state upon topic creation")
servers(1).shutdown()
diff --git a/core/src/test/scala/unit/kafka/integration/AutoOffsetResetTest.scala b/core/src/test/scala/unit/kafka/integration/AutoOffsetResetTest.scala
index cfc325d..bec5282 100644
--- a/core/src/test/scala/unit/kafka/integration/AutoOffsetResetTest.scala
+++ b/core/src/test/scala/unit/kafka/integration/AutoOffsetResetTest.scala
@@ -77,7 +77,7 @@ class AutoOffsetResetTest extends KafkaServerTestHarness with Logging {
* Returns the count of messages received.
*/
def resetAndConsume(numMessages: Int, resetTo: String, offset: Long): Int = {
- TestUtils.createTopic(zkUtils, topic, 1, 1, servers)
+ TestUtils.createTopic(zkClient, topic, 1, 1, servers)
val producer: Producer[String, Array[Byte]] = TestUtils.createProducer(
TestUtils.getBrokerListStrFromServers(servers),
diff --git a/core/src/test/scala/unit/kafka/integration/FetcherTest.scala b/core/src/test/scala/unit/kafka/integration/FetcherTest.scala
index f23225c..6ecec3c 100644
--- a/core/src/test/scala/unit/kafka/integration/FetcherTest.scala
+++ b/core/src/test/scala/unit/kafka/integration/FetcherTest.scala
@@ -43,7 +43,7 @@ class FetcherTest extends KafkaServerTestHarness {
@Before
override def setUp() {
super.setUp
- TestUtils.createTopic(zkUtils, topic, partitionReplicaAssignment = Map(0 -> Seq(configs.head.brokerId)), servers = servers)
+ TestUtils.createTopic(zkClient, topic, partitionReplicaAssignment = Map(0 -> Seq(configs.head.brokerId)), servers = servers)
val cluster = new Cluster(servers.map { s =>
new Broker(s.config.brokerId, "localhost", boundPort(s), listenerName, securityProtocol)
diff --git a/core/src/test/scala/unit/kafka/integration/PrimitiveApiTest.scala b/core/src/test/scala/unit/kafka/integration/PrimitiveApiTest.scala
index 9c4d08f..d6c59d2 100755
--- a/core/src/test/scala/unit/kafka/integration/PrimitiveApiTest.scala
+++ b/core/src/test/scala/unit/kafka/integration/PrimitiveApiTest.scala
@@ -117,7 +117,7 @@ class PrimitiveApiTest extends ProducerConsumerTestHarness {
private def produceAndMultiFetch(producer: Producer[String, String]) {
for(topic <- List("test1", "test2", "test3", "test4"))
- TestUtils.createTopic(zkUtils, topic, servers = servers)
+ TestUtils.createTopic(zkClient, topic, servers = servers)
// send some messages
val topics = List(("test4", 0), ("test1", 0), ("test2", 0), ("test3", 0));
@@ -186,7 +186,7 @@ class PrimitiveApiTest extends ProducerConsumerTestHarness {
private def multiProduce(producer: Producer[String, String]) {
val topics = Map("test4" -> 0, "test1" -> 0, "test2" -> 0, "test3" -> 0)
- topics.keys.map(topic => TestUtils.createTopic(zkUtils, topic, servers = servers))
+ topics.keys.map(topic => TestUtils.createTopic(zkClient, topic, servers = servers))
val messages = new mutable.HashMap[String, Seq[String]]
val builder = new FetchRequestBuilder()
@@ -214,7 +214,7 @@ class PrimitiveApiTest extends ProducerConsumerTestHarness {
@Test
def testConsumerEmptyTopic() {
val newTopic = "new-topic"
- TestUtils.createTopic(zkUtils, newTopic, numPartitions = 1, replicationFactor = 1, servers = servers)
+ TestUtils.createTopic(zkClient, newTopic, numPartitions = 1, replicationFactor = 1, servers = servers)
val fetchResponse = consumer.fetch(new FetchRequestBuilder().addFetch(newTopic, 0, 0, 10000).build())
assertFalse(fetchResponse.messageSet(newTopic, 0).iterator.hasNext)
@@ -223,7 +223,7 @@ class PrimitiveApiTest extends ProducerConsumerTestHarness {
@Test
def testPipelinedProduceRequests() {
val topics = Map("test4" -> 0, "test1" -> 0, "test2" -> 0, "test3" -> 0)
- topics.keys.map(topic => TestUtils.createTopic(zkUtils, topic, servers = servers))
+ topics.keys.map(topic => TestUtils.createTopic(zkClient, topic, servers = servers))
val props = new Properties()
props.put("request.required.acks", "0")
val pipelinedProducer: Producer[String, String] =
diff --git a/core/src/test/scala/unit/kafka/integration/TopicMetadataTest.scala b/core/src/test/scala/unit/kafka/integration/TopicMetadataTest.scala
index e93dcf6..87ffdf1 100644
--- a/core/src/test/scala/unit/kafka/integration/TopicMetadataTest.scala
+++ b/core/src/test/scala/unit/kafka/integration/TopicMetadataTest.scala
@@ -59,7 +59,7 @@ class TopicMetadataTest extends ZooKeeperTestHarness {
def testBasicTopicMetadata(): Unit = {
// create topic
val topic = "test"
- createTopic(zkUtils, topic, numPartitions = 1, replicationFactor = 1, servers = Seq(server1))
+ createTopic(zkClient, topic, numPartitions = 1, replicationFactor = 1, servers = Seq(server1))
val topicsMetadata = ClientUtils.fetchTopicMetadata(Set(topic), brokerEndPoints, "TopicMetadataTest-testBasicTopicMetadata",
2000, 0).topicsMetadata
@@ -78,8 +78,8 @@ class TopicMetadataTest extends ZooKeeperTestHarness {
// create topic
val topic1 = "testGetAllTopicMetadata1"
val topic2 = "testGetAllTopicMetadata2"
- createTopic(zkUtils, topic1, numPartitions = 1, replicationFactor = 1, servers = Seq(server1))
- createTopic(zkUtils, topic2, numPartitions = 1, replicationFactor = 1, servers = Seq(server1))
+ createTopic(zkClient, topic1, numPartitions = 1, replicationFactor = 1, servers = Seq(server1))
+ createTopic(zkClient, topic2, numPartitions = 1, replicationFactor = 1, servers = Seq(server1))
// issue metadata request with empty list of topics
val topicsMetadata = ClientUtils.fetchTopicMetadata(Set.empty, brokerEndPoints, "TopicMetadataTest-testGetAllTopicMetadata",
@@ -110,7 +110,7 @@ class TopicMetadataTest extends ZooKeeperTestHarness {
assertEquals(0, topicsMetadata.head.partitionsMetadata.size)
// wait for leader to be elected
- TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0)
+ TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0)
TestUtils.waitUntilMetadataIsPropagated(Seq(server1), topic, 0)
// retry the metadata for the auto created topic
@@ -162,7 +162,7 @@ class TopicMetadataTest extends ZooKeeperTestHarness {
assertEquals("Expecting InvalidTopicCode for topic2 metadata", Errors.INVALID_TOPIC_EXCEPTION, topicsMetadata(1).error)
// wait for leader to be elected
- TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic1, 0)
+ TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic1, 0)
TestUtils.waitUntilMetadataIsPropagated(Seq(server1), topic1, 0)
// retry the metadata for the first auto created topic
diff --git a/core/src/test/scala/unit/kafka/integration/UncleanLeaderElectionTest.scala b/core/src/test/scala/unit/kafka/integration/UncleanLeaderElectionTest.scala
index 7732e38..5269f92 100755
--- a/core/src/test/scala/unit/kafka/integration/UncleanLeaderElectionTest.scala
+++ b/core/src/test/scala/unit/kafka/integration/UncleanLeaderElectionTest.scala
@@ -173,7 +173,7 @@ class UncleanLeaderElectionTest extends ZooKeeperTestHarness {
def verifyUncleanLeaderElectionEnabled(): Unit = {
// wait until leader is elected
- val leaderId = waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId)
+ val leaderId = waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId)
debug("Leader for " + topic + " is elected to be: %s".format(leaderId))
assertTrue("Leader id is set to expected value for topic: " + topic, leaderId == brokerId1 || leaderId == brokerId2)
@@ -196,7 +196,7 @@ class UncleanLeaderElectionTest extends ZooKeeperTestHarness {
servers.filter(server => server.config.brokerId == followerId).map(server => server.startup())
// wait until new leader is (uncleanly) elected
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId, newLeaderOpt = Some(followerId))
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId, newLeaderOpt = Some(followerId))
produceMessage(servers, topic, "third")
@@ -206,7 +206,7 @@ class UncleanLeaderElectionTest extends ZooKeeperTestHarness {
def verifyUncleanLeaderElectionDisabled(): Unit = {
// wait until leader is elected
- val leaderId = waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId)
+ val leaderId = waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId)
debug("Leader for " + topic + " is elected to be: %s".format(leaderId))
assertTrue("Leader id is set to expected value for topic: " + topic, leaderId == brokerId1 || leaderId == brokerId2)
@@ -229,7 +229,7 @@ class UncleanLeaderElectionTest extends ZooKeeperTestHarness {
servers.filter(server => server.config.brokerId == followerId).map(server => server.startup())
// verify that unclean election to non-ISR follower does not occur
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId, newLeaderOpt = Some(-1))
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId, newLeaderOpt = Some(-1))
// message production and consumption should both fail while leader is down
try {
@@ -243,14 +243,14 @@ class UncleanLeaderElectionTest extends ZooKeeperTestHarness {
// restart leader temporarily to send a successfully replicated message
servers.filter(server => server.config.brokerId == leaderId).map(server => server.startup())
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId, newLeaderOpt = Some(leaderId))
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId, newLeaderOpt = Some(leaderId))
produceMessage(servers, topic, "third")
waitUntilMetadataIsPropagated(servers, topic, partitionId)
servers.filter(server => server.config.brokerId == leaderId).map(server => shutdownServer(server))
// verify clean leader transition to ISR follower
- waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId, newLeaderOpt = Some(followerId))
+ waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId, newLeaderOpt = Some(followerId))
// verify messages can be consumed from ISR follower that was just promoted to leader
assertEquals(List("first", "second", "third"), consumeAllMessages(topic))
diff --git a/core/src/test/scala/unit/kafka/javaapi/consumer/ZookeeperConsumerConnectorTest.scala b/core/src/test/scala/unit/kafka/javaapi/consumer/ZookeeperConsumerConnectorTest.scala
index ede4ff7..215776f 100644
--- a/core/src/test/scala/unit/kafka/javaapi/consumer/ZookeeperConsumerConnectorTest.scala
+++ b/core/src/test/scala/unit/kafka/javaapi/consumer/ZookeeperConsumerConnectorTest.scala
@@ -57,7 +57,7 @@ class ZookeeperConsumerConnectorTest extends KafkaServerTestHarness with Logging
requestHandlerLogger.setLevel(Level.FATAL)
// create the topic
- TestUtils.createTopic(zkUtils, topic, numParts, 1, servers)
+ TestUtils.createTopic(zkClient, topic, numParts, 1, servers)
// send some messages to each broker
val sentMessages1 = sendMessages(servers, nMessages, "batch1")
diff --git a/core/src/test/scala/unit/kafka/metrics/MetricsTest.scala b/core/src/test/scala/unit/kafka/metrics/MetricsTest.scala
index c250d85..b8794f3 100644
--- a/core/src/test/scala/unit/kafka/metrics/MetricsTest.scala
+++ b/core/src/test/scala/unit/kafka/metrics/MetricsTest.scala
@@ -54,7 +54,7 @@ class MetricsTest extends KafkaServerTestHarness with Logging {
def testMetricsLeak() {
val topic = "test-metrics-leak"
// create topic topic1 with 1 partition on broker 0
- createTopic(zkUtils, topic, numPartitions = 1, replicationFactor = 1, servers = servers)
+ createTopic(zkClient, topic, numPartitions = 1, replicationFactor = 1, servers = servers)
// force creation not client's specific metrics.
createAndShutdownStep(topic, "group0", "consumer0", "producer0")
@@ -74,7 +74,7 @@ class MetricsTest extends KafkaServerTestHarness with Logging {
val topic = "test-topic-metric"
adminZkClient.createTopic(topic, 1, 1)
adminZkClient.deleteTopic(topic)
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, servers)
assertEquals("Topic metrics exists after deleteTopic", Set.empty, topicMetricGroups(topic))
}
@@ -88,7 +88,7 @@ class MetricsTest extends KafkaServerTestHarness with Logging {
assertTrue("Topic metrics don't exist", topicMetricGroups(topic).nonEmpty)
servers.foreach(s => assertNotNull(s.brokerTopicStats.topicStats(topic)))
adminZkClient.deleteTopic(topic)
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, servers)
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, servers)
assertEquals("Topic metrics exists after deleteTopic", Set.empty, topicMetricGroups(topic))
}
@@ -130,7 +130,7 @@ class MetricsTest extends KafkaServerTestHarness with Logging {
val topicConfig = new Properties
topicConfig.setProperty(LogConfig.MinInSyncReplicasProp, "2")
- createTopic(zkUtils, topic, 1, numNodes, servers, topicConfig)
+ createTopic(zkClient, topic, 1, numNodes, servers, topicConfig)
// Produce a few messages to create the metrics
TestUtils.produceMessages(servers, topic, nMessages)
diff --git a/core/src/test/scala/unit/kafka/producer/ProducerTest.scala b/core/src/test/scala/unit/kafka/producer/ProducerTest.scala
index 86a0e86..dc2a5ed 100755
--- a/core/src/test/scala/unit/kafka/producer/ProducerTest.scala
+++ b/core/src/test/scala/unit/kafka/producer/ProducerTest.scala
@@ -29,6 +29,7 @@ import kafka.serializer.StringEncoder
import kafka.server.{KafkaConfig, KafkaRequestHandler, KafkaServer}
import kafka.utils._
import kafka.zk.ZooKeeperTestHarness
+import org.apache.kafka.common.TopicPartition
import org.apache.kafka.common.record.TimestampType
import org.apache.kafka.common.utils.Time
import org.apache.log4j.{Level, Logger}
@@ -96,7 +97,7 @@ class ProducerTest extends ZooKeeperTestHarness with Logging{
@Test
def testUpdateBrokerPartitionInfo() {
val topic = "new-topic"
- TestUtils.createTopic(zkUtils, topic, numPartitions = 1, replicationFactor = 2, servers = servers)
+ TestUtils.createTopic(zkClient, topic, numPartitions = 1, replicationFactor = 2, servers = servers)
val props = new Properties()
// no need to retry since the send will always fail
@@ -148,7 +149,7 @@ class ProducerTest extends ZooKeeperTestHarness with Logging{
val topic = "new-topic"
// create topic with 1 partition and await leadership
- TestUtils.createTopic(zkUtils, topic, numPartitions = 1, replicationFactor = 2, servers = servers)
+ TestUtils.createTopic(zkClient, topic, numPartitions = 1, replicationFactor = 2, servers = servers)
val producer1 = TestUtils.createProducer[String, String](
brokerList = TestUtils.getBrokerListStrFromServers(Seq(server1, server2)),
@@ -162,7 +163,7 @@ class ProducerTest extends ZooKeeperTestHarness with Logging{
producer1.send(new KeyedMessage[String, String](topic, "test", "test2"))
val endTime = System.currentTimeMillis()
// get the leader
- val leaderOpt = zkUtils.getLeaderForPartition(topic, 0)
+ val leaderOpt = zkClient.getLeaderForPartition(new TopicPartition(topic, 0))
assertTrue("Leader for topic new-topic partition 0 should exist", leaderOpt.isDefined)
val leader = leaderOpt.get
@@ -220,7 +221,7 @@ class ProducerTest extends ZooKeeperTestHarness with Logging{
val topic = "new-topic"
// create topic
- TestUtils.createTopic(zkUtils, topic, partitionReplicaAssignment = Map(0->Seq(0), 1->Seq(0), 2->Seq(0), 3->Seq(0)),
+ TestUtils.createTopic(zkClient, topic, partitionReplicaAssignment = Map(0->Seq(0), 1->Seq(0), 2->Seq(0), 3->Seq(0)),
servers = servers)
val producer = TestUtils.createProducer[String, String](
@@ -253,7 +254,7 @@ class ProducerTest extends ZooKeeperTestHarness with Logging{
// restart server 1
server1.startup()
- TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic, 0)
+ TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic, 0)
TestUtils.waitUntilMetadataIsPropagated(servers, topic, 0)
TestUtils.waitUntilLeaderIsKnown(servers, topic, 0)
@@ -279,7 +280,7 @@ class ProducerTest extends ZooKeeperTestHarness with Logging{
def testAsyncSendCanCorrectlyFailWithTimeout() {
val topic = "new-topic"
// create topics in ZK
- TestUtils.createTopic(zkUtils, topic, partitionReplicaAssignment = Map(0->Seq(0, 1)), servers = servers)
+ TestUtils.createTopic(zkClient, topic, partitionReplicaAssignment = Map(0->Seq(0, 1)), servers = servers)
val timeoutMs = 500
val props = new Properties()
@@ -338,7 +339,7 @@ class ProducerTest extends ZooKeeperTestHarness with Logging{
partitioner = classOf[StaticPartitioner].getName)
try {
- TestUtils.createTopic(zkUtils, "new-topic", 2, 1, servers)
+ TestUtils.createTopic(zkClient, "new-topic", 2, 1, servers)
producer.send(new KeyedMessage("new-topic", "key", null))
} finally {
producer.close()
diff --git a/core/src/test/scala/unit/kafka/producer/SyncProducerTest.scala b/core/src/test/scala/unit/kafka/producer/SyncProducerTest.scala
index 4a0d46e..9279d90 100644
--- a/core/src/test/scala/unit/kafka/producer/SyncProducerTest.scala
+++ b/core/src/test/scala/unit/kafka/producer/SyncProducerTest.scala
@@ -96,7 +96,7 @@ class SyncProducerTest extends KafkaServerTestHarness {
val props = TestUtils.getSyncProducerConfig(boundPort(server))
val producer = new SyncProducer(new SyncProducerConfig(props))
- TestUtils.createTopic(zkUtils, "test", numPartitions = 1, replicationFactor = 1, servers = servers)
+ TestUtils.createTopic(zkClient, "test", numPartitions = 1, replicationFactor = 1, servers = servers)
val message1 = new Message(new Array[Byte](configs.head.messageMaxBytes + 1))
val messageSet1 = new ByteBufferMessageSet(compressionCodec = NoCompressionCodec, messages = message1)
@@ -125,7 +125,7 @@ class SyncProducerTest extends KafkaServerTestHarness {
val producer = new SyncProducer(new SyncProducerConfig(props))
adminZkClient.createTopic("test", 1, 1)
- TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, "test", 0)
+ TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, "test", 0)
// This message will be dropped silently since message size too large.
producer.send(produceRequest("test", 0,
@@ -167,9 +167,9 @@ class SyncProducerTest extends KafkaServerTestHarness {
// #2 - test that we get correct offsets when partition is owned by broker
adminZkClient.createTopic("topic1", 1, 1)
- TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, "topic1", 0)
+ TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, "topic1", 0)
adminZkClient.createTopic("topic3", 1, 1)
- TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, "topic3", 0)
+ TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, "topic3", 0)
val response2 = producer.send(request)
assertNotNull(response2)
@@ -243,7 +243,7 @@ class SyncProducerTest extends KafkaServerTestHarness {
val topicProps = new Properties()
topicProps.put("min.insync.replicas","2")
adminZkClient.createTopic(topicName, 1, 1,topicProps)
- TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topicName, 0)
+ TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topicName, 0)
val response = producer.send(produceRequest(topicName, 0,
new ByteBufferMessageSet(compressionCodec = NoCompressionCodec, messages = new Message(messageBytes)),-1))
diff --git a/core/src/test/scala/unit/kafka/server/AddPartitionsToTxnRequestTest.scala b/core/src/test/scala/unit/kafka/server/AddPartitionsToTxnRequestTest.scala
index 62dd4c4..9a3187b 100644
--- a/core/src/test/scala/unit/kafka/server/AddPartitionsToTxnRequestTest.scala
+++ b/core/src/test/scala/unit/kafka/server/AddPartitionsToTxnRequestTest.scala
@@ -38,7 +38,7 @@ class AddPartitionsToTxnRequestTest extends BaseRequestTest {
@Before
override def setUp(): Unit = {
super.setUp()
- TestUtils.createTopic(zkUtils, topic1, numPartitions, servers.size, servers, new Properties())
+ TestUtils.createTopic(zkClient, topic1, numPartitions, servers.size, servers, new Properties())
}
@Test
diff --git a/core/src/test/scala/unit/kafka/server/AdvertiseBrokerTest.scala b/core/src/test/scala/unit/kafka/server/AdvertiseBrokerTest.scala
index 1c3efee..75038bf 100755
--- a/core/src/test/scala/unit/kafka/server/AdvertiseBrokerTest.scala
+++ b/core/src/test/scala/unit/kafka/server/AdvertiseBrokerTest.scala
@@ -45,7 +45,7 @@ class AdvertiseBrokerTest extends ZooKeeperTestHarness {
props.put("advertised.port", advertisedPort.toString)
servers += TestUtils.createServer(KafkaConfig.fromProps(props))
- val brokerInfo = zkUtils.getBrokerInfo(brokerId).get
+ val brokerInfo = zkClient.getBroker(brokerId).get
assertEquals(1, brokerInfo.endPoints.size)
val endpoint = brokerInfo.endPoints.head
assertEquals(advertisedHostName, endpoint.host)
@@ -59,7 +59,7 @@ class AdvertiseBrokerTest extends ZooKeeperTestHarness {
props.put("advertised.listeners", "PLAINTEXT://routable-listener:3334")
servers += TestUtils.createServer(KafkaConfig.fromProps(props))
- val brokerInfo = zkUtils.getBrokerInfo(brokerId).get
+ val brokerInfo = zkClient.getBroker(brokerId).get
assertEquals(1, brokerInfo.endPoints.size)
val endpoint = brokerInfo.endPoints.head
assertEquals("routable-listener", endpoint.host)
@@ -76,7 +76,7 @@ class AdvertiseBrokerTest extends ZooKeeperTestHarness {
props.put("inter.broker.listener.name", "INTERNAL")
servers += TestUtils.createServer(KafkaConfig.fromProps(props))
- val brokerInfo = zkUtils.getBrokerInfo(brokerId).get
+ val brokerInfo = zkClient.getBroker(brokerId).get
assertEquals(1, brokerInfo.endPoints.size)
val endpoint = brokerInfo.endPoints.head
assertEquals("external-listener", endpoint.host)
diff --git a/core/src/test/scala/unit/kafka/server/AlterReplicaLogDirsRequestTest.scala b/core/src/test/scala/unit/kafka/server/AlterReplicaLogDirsRequestTest.scala
index f2dc4a5..fabe3d8 100644
--- a/core/src/test/scala/unit/kafka/server/AlterReplicaLogDirsRequestTest.scala
+++ b/core/src/test/scala/unit/kafka/server/AlterReplicaLogDirsRequestTest.scala
@@ -54,7 +54,7 @@ class AlterReplicaLogDirsRequestTest extends BaseRequestTest {
assertTrue(servers.head.logManager.getLog(tp).isEmpty)
}
- TestUtils.createTopic(zkUtils, topic, partitionNum, 1, servers)
+ TestUtils.createTopic(zkClient, topic, partitionNum, 1, servers)
(0 until partitionNum).foreach { partition =>
assertEquals(logDir1, servers.head.logManager.getLog(new TopicPartition(topic, partition)).get.dir.getParent)
}
@@ -88,7 +88,7 @@ class AlterReplicaLogDirsRequestTest extends BaseRequestTest {
assertEquals(Errors.LOG_DIR_NOT_FOUND, alterReplicaDirResponse1.responses().get(new TopicPartition(topic, 0)))
assertEquals(Errors.REPLICA_NOT_AVAILABLE, alterReplicaDirResponse1.responses().get(new TopicPartition(topic, 1)))
- TestUtils.createTopic(zkUtils, topic, 3, 1, servers)
+ TestUtils.createTopic(zkClient, topic, 3, 1, servers)
// Test AlterReplicaDirRequest after topic creation
val partitionDirs2 = mutable.Map.empty[TopicPartition, String]
diff --git a/core/src/test/scala/unit/kafka/server/CreateTopicsRequestTest.scala b/core/src/test/scala/unit/kafka/server/CreateTopicsRequestTest.scala
index 4ab9520..a6381a6 100644
--- a/core/src/test/scala/unit/kafka/server/CreateTopicsRequestTest.scala
+++ b/core/src/test/scala/unit/kafka/server/CreateTopicsRequestTest.scala
@@ -59,7 +59,7 @@ class CreateTopicsRequestTest extends AbstractCreateTopicsRequestTest {
def testErrorCreateTopicsRequests() {
val timeout = 10000
val existingTopic = "existing-topic"
- TestUtils.createTopic(zkUtils, existingTopic, 1, 1, servers)
+ TestUtils.createTopic(zkClient, existingTopic, 1, 1, servers)
// Basic
validateErrorCreateTopicsRequests(new CreateTopicsRequest.Builder(Map(existingTopic -> new CreateTopicsRequest.TopicDetails(1, 1.toShort)).asJava, timeout).build(),
diff --git a/core/src/test/scala/unit/kafka/server/CreateTopicsRequestWithPolicyTest.scala b/core/src/test/scala/unit/kafka/server/CreateTopicsRequestWithPolicyTest.scala
index 36e03af..3598626 100644
--- a/core/src/test/scala/unit/kafka/server/CreateTopicsRequestWithPolicyTest.scala
+++ b/core/src/test/scala/unit/kafka/server/CreateTopicsRequestWithPolicyTest.scala
@@ -62,7 +62,7 @@ class CreateTopicsRequestWithPolicyTest extends AbstractCreateTopicsRequestTest
def testErrorCreateTopicsRequests() {
val timeout = 10000
val existingTopic = "existing-topic"
- TestUtils.createTopic(zkUtils, existingTopic, 1, 1, servers)
+ TestUtils.createTopic(zkClient, existingTopic, 1, 1, servers)
// Policy violations
validateErrorCreateTopicsRequests(new CreateTopicsRequest.Builder(
diff --git a/core/src/test/scala/unit/kafka/server/DeleteTopicsRequestTest.scala b/core/src/test/scala/unit/kafka/server/DeleteTopicsRequestTest.scala
index 881bf8e..237e918 100644
--- a/core/src/test/scala/unit/kafka/server/DeleteTopicsRequestTest.scala
+++ b/core/src/test/scala/unit/kafka/server/DeleteTopicsRequestTest.scala
@@ -32,11 +32,11 @@ class DeleteTopicsRequestTest extends BaseRequestTest {
def testValidDeleteTopicRequests() {
val timeout = 10000
// Single topic
- TestUtils.createTopic(zkUtils, "topic-1", 1, 1, servers)
+ TestUtils.createTopic(zkClient, "topic-1", 1, 1, servers)
validateValidDeleteTopicRequests(new DeleteTopicsRequest.Builder(Set("topic-1").asJava, timeout).build())
// Multi topic
- TestUtils.createTopic(zkUtils, "topic-3", 5, 2, servers)
- TestUtils.createTopic(zkUtils, "topic-4", 1, 2, servers)
+ TestUtils.createTopic(zkClient, "topic-3", 5, 2, servers)
+ TestUtils.createTopic(zkClient, "topic-4", 1, 2, servers)
validateValidDeleteTopicRequests(new DeleteTopicsRequest.Builder(Set("topic-3", "topic-4").asJava, timeout).build())
}
@@ -61,7 +61,7 @@ class DeleteTopicsRequestTest extends BaseRequestTest {
Map("invalid-topic" -> Errors.UNKNOWN_TOPIC_OR_PARTITION))
// Partial
- TestUtils.createTopic(zkUtils, "partial-topic-1", 1, 1, servers)
+ TestUtils.createTopic(zkClient, "partial-topic-1", 1, 1, servers)
validateErrorDeleteTopicRequests(new DeleteTopicsRequest.Builder(Set(
"partial-topic-1",
"partial-invalid-topic").asJava, timeout).build(),
@@ -72,7 +72,7 @@ class DeleteTopicsRequestTest extends BaseRequestTest {
)
// Timeout
- TestUtils.createTopic(zkUtils, timeoutTopic, 5, 2, servers)
+ TestUtils.createTopic(zkClient, timeoutTopic, 5, 2, servers)
// Must be a 0ms timeout to avoid transient test failures. Even a timeout of 1ms has succeeded in the past.
validateErrorDeleteTopicRequests(new DeleteTopicsRequest.Builder(Set(timeoutTopic).asJava, 0).build(),
Map(timeoutTopic -> Errors.REQUEST_TIMED_OUT))
diff --git a/core/src/test/scala/unit/kafka/server/DescribeLogDirsRequestTest.scala b/core/src/test/scala/unit/kafka/server/DescribeLogDirsRequestTest.scala
index 7f9e63a..9074ad8 100644
--- a/core/src/test/scala/unit/kafka/server/DescribeLogDirsRequestTest.scala
+++ b/core/src/test/scala/unit/kafka/server/DescribeLogDirsRequestTest.scala
@@ -40,7 +40,7 @@ class DescribeLogDirsRequestTest extends BaseRequestTest {
val onlineDir = new File(servers.head.config.logDirs.head).getAbsolutePath
val offlineDir = new File(servers.head.config.logDirs.tail.head).getAbsolutePath
servers.head.replicaManager.handleLogDirFailure(offlineDir)
- TestUtils.createTopic(zkUtils, topic, partitionNum, 1, servers)
+ TestUtils.createTopic(zkClient, topic, partitionNum, 1, servers)
TestUtils.produceMessages(servers, topic, 10)
val request = new DescribeLogDirsRequest.Builder(null).build()
diff --git a/core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala b/core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala
index d596d0f..7ad44cb 100644
--- a/core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala
+++ b/core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala
@@ -28,6 +28,7 @@ import org.junit.Test
import kafka.integration.KafkaServerTestHarness
import kafka.utils._
import kafka.admin.AdminOperationException
+import kafka.zk.ConfigEntityChangeNotificationZNode
import org.apache.kafka.common.TopicPartition
import scala.collection.Map
@@ -149,7 +150,7 @@ class DynamicConfigChangeTest extends KafkaServerTestHarness {
adminZkClient.changeUserOrUserClientIdConfig("ANONYMOUS/clients/overriddenUserClientId", userClientIdProps)
// Remove config change znodes to force quota initialization only through loading of user/client quotas
- zkUtils.getChildren(ZkUtils.ConfigChangesPath).foreach { p => zkUtils.deletePath(ZkUtils.ConfigChangesPath + "/" + p) }
+ zkClient.getChildren(ConfigEntityChangeNotificationZNode.path).foreach { p => zkClient.deletePath(ConfigEntityChangeNotificationZNode.path + "/" + p) }
server.startup()
val quotaManagers = server.apis.quotas
diff --git a/core/src/test/scala/unit/kafka/server/EdgeCaseRequestTest.scala b/core/src/test/scala/unit/kafka/server/EdgeCaseRequestTest.scala
index 7b3011f..1d8912b 100755
--- a/core/src/test/scala/unit/kafka/server/EdgeCaseRequestTest.scala
+++ b/core/src/test/scala/unit/kafka/server/EdgeCaseRequestTest.scala
@@ -113,7 +113,7 @@ class EdgeCaseRequestTest extends KafkaServerTestHarness {
val topic = "topic"
val topicPartition = new TopicPartition(topic, 0)
val correlationId = -1
- TestUtils.createTopic(zkUtils, topic, numPartitions = 1, replicationFactor = 1, servers = servers)
+ TestUtils.createTopic(zkClient, topic, numPartitions = 1, replicationFactor = 1, servers = servers)
val version = ApiKeys.PRODUCE.latestVersion: Short
val serializedBytes = {
diff --git a/core/src/test/scala/unit/kafka/server/FetchRequestTest.scala b/core/src/test/scala/unit/kafka/server/FetchRequestTest.scala
index 726757d..f1811ad 100644
--- a/core/src/test/scala/unit/kafka/server/FetchRequestTest.scala
+++ b/core/src/test/scala/unit/kafka/server/FetchRequestTest.scala
@@ -342,7 +342,7 @@ class FetchRequestTest extends BaseRequestTest {
topicConfig.setProperty(LogConfig.MinInSyncReplicasProp, 2.toString)
configs.foreach { case (k, v) => topicConfig.setProperty(k, v) }
topics.flatMap { topic =>
- val partitionToLeader = createTopic(zkUtils, topic, numPartitions = numPartitions, replicationFactor = 2,
+ val partitionToLeader = createTopic(zkClient, topic, numPartitions = numPartitions, replicationFactor = 2,
servers = servers, topicConfig = topicConfig)
partitionToLeader.map { case (partition, leader) => new TopicPartition(topic, partition) -> leader }
}.toMap
diff --git a/core/src/test/scala/unit/kafka/server/LeaderElectionTest.scala b/core/src/test/scala/unit/kafka/server/LeaderElectionTest.scala
index 56f5f6d..9cbc260 100755
--- a/core/src/test/scala/unit/kafka/server/LeaderElectionTest.scala
+++ b/core/src/test/scala/unit/kafka/server/LeaderElectionTest.scala
@@ -72,7 +72,7 @@ class LeaderElectionTest extends ZooKeeperTestHarness {
val partitionId = 0
// create topic with 1 partition, 2 replicas, one on each broker
- val leader1 = createTopic(zkUtils, topic, partitionReplicaAssignment = Map(0 -> Seq(0, 1)), servers = servers)(0)
+ val leader1 = createTopic(zkClient, topic, partitionReplicaAssignment = Map(0 -> Seq(0, 1)), servers = servers)(0)
val leaderEpoch1 = zkUtils.getEpochForPartition(topic, partitionId)
debug("leader Epoch: " + leaderEpoch1)
@@ -84,7 +84,7 @@ class LeaderElectionTest extends ZooKeeperTestHarness {
// kill the server hosting the preferred replica
servers.last.shutdown()
// check if leader moves to the other server
- val leader2 = waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId,
+ val leader2 = waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId,
oldLeaderOpt = if (leader1 == 0) None else Some(leader1))
val leaderEpoch2 = zkUtils.getEpochForPartition(topic, partitionId)
debug("Leader is elected to be: %s".format(leader1))
@@ -98,7 +98,7 @@ class LeaderElectionTest extends ZooKeeperTestHarness {
servers.last.startup()
servers.head.shutdown()
Thread.sleep(zookeeper.tickTime)
- val leader3 = waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId,
+ val leader3 = waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId,
oldLeaderOpt = if (leader2 == 1) None else Some(leader2))
val leaderEpoch3 = zkUtils.getEpochForPartition(topic, partitionId)
debug("leader Epoch: " + leaderEpoch3)
@@ -117,7 +117,7 @@ class LeaderElectionTest extends ZooKeeperTestHarness {
val partitionId = 0
// create topic with 1 partition, 2 replicas, one on each broker
- val leader1 = createTopic(zkUtils, topic, partitionReplicaAssignment = Map(0 -> Seq(0, 1)), servers = servers)(0)
+ val leader1 = createTopic(zkClient, topic, partitionReplicaAssignment = Map(0 -> Seq(0, 1)), servers = servers)(0)
val leaderEpoch1 = zkUtils.getEpochForPartition(topic, partitionId)
debug("leader Epoch: " + leaderEpoch1)
diff --git a/core/src/test/scala/unit/kafka/server/LogDirFailureTest.scala b/core/src/test/scala/unit/kafka/server/LogDirFailureTest.scala
index bf1ee35..6b3fff3 100644
--- a/core/src/test/scala/unit/kafka/server/LogDirFailureTest.scala
+++ b/core/src/test/scala/unit/kafka/server/LogDirFailureTest.scala
@@ -24,13 +24,14 @@ import kafka.server.LogDirFailureTest._
import kafka.api.IntegrationTestHarness
import kafka.controller.{OfflineReplica, PartitionAndReplica}
import kafka.utils.{CoreUtils, Exit, TestUtils, ZkUtils}
+import kafka.zk.LogDirEventNotificationZNode
import org.apache.kafka.clients.consumer.KafkaConsumer
import org.apache.kafka.clients.producer.{ProducerConfig, ProducerRecord}
import org.apache.kafka.common.TopicPartition
import org.apache.kafka.common.utils.Utils
import org.apache.kafka.common.errors.{KafkaStorageException, NotLeaderForPartitionException}
import org.junit.{Before, Test}
-import org.junit.Assert.{assertTrue, assertFalse, assertEquals}
+import org.junit.Assert.{assertEquals, assertFalse, assertTrue}
import scala.collection.JavaConverters._
@@ -54,7 +55,7 @@ class LogDirFailureTest extends IntegrationTestHarness {
@Before
override def setUp() {
super.setUp()
- TestUtils.createTopic(zkUtils, topic, partitionNum, serverCount, servers = servers)
+ TestUtils.createTopic(zkClient, topic, partitionNum, serverCount, servers = servers)
}
@Test
@@ -190,7 +191,7 @@ class LogDirFailureTest extends IntegrationTestHarness {
}, "Expected some messages", 3000L)
// There should be no remaining LogDirEventNotification znode
- assertTrue(zkUtils.getChildrenParentMayNotExist(ZkUtils.LogDirEventNotificationPath).isEmpty)
+ assertTrue(zkUtils.getChildrenParentMayNotExist(LogDirEventNotificationZNode.path).isEmpty)
// The controller should have marked the replica on the original leader as offline
val controllerServer = servers.find(_.kafkaController.isActive).get
diff --git a/core/src/test/scala/unit/kafka/server/LogOffsetTest.scala b/core/src/test/scala/unit/kafka/server/LogOffsetTest.scala
index b0a7d72..9533b00 100755
--- a/core/src/test/scala/unit/kafka/server/LogOffsetTest.scala
+++ b/core/src/test/scala/unit/kafka/server/LogOffsetTest.scala
@@ -154,7 +154,7 @@ class LogOffsetTest extends ZooKeeperTestHarness {
val topic = topicPartition.split("-").head
// setup brokers in ZooKeeper as owners of partitions for this test
- createTopic(zkUtils, topic, numPartitions = 1, replicationFactor = 1, servers = Seq(server))
+ createTopic(zkClient, topic, numPartitions = 1, replicationFactor = 1, servers = Seq(server))
var offsetChanged = false
for (_ <- 1 to 14) {
diff --git a/core/src/test/scala/unit/kafka/server/LogRecoveryTest.scala b/core/src/test/scala/unit/kafka/server/LogRecoveryTest.scala
index fa373f5..d4ac10c 100755
--- a/core/src/test/scala/unit/kafka/server/LogRecoveryTest.scala
+++ b/core/src/test/scala/unit/kafka/server/LogRecoveryTest.scala
@@ -85,7 +85,7 @@ class LogRecoveryTest extends ZooKeeperTestHarness {
servers = List(server1, server2)
// create topic with 1 partition, 2 replicas, one on each broker
- createTopic(zkUtils, topic, partitionReplicaAssignment = Map(0 -> Seq(0,1)), servers = servers)
+ createTopic(zkClient, topic, partitionReplicaAssignment = Map(0 -> Seq(0,1)), servers = servers)
// create the producer
updateProducer()
@@ -117,7 +117,7 @@ class LogRecoveryTest extends ZooKeeperTestHarness {
@Test
def testHWCheckpointWithFailuresSingleLogSegment(): Unit = {
- var leader = waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId)
+ var leader = waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId)
assertEquals(0L, hwFile1.read.getOrElse(topicPartition, 0L))
@@ -130,7 +130,7 @@ class LogRecoveryTest extends ZooKeeperTestHarness {
assertEquals(hw, hwFile1.read.getOrElse(topicPartition, 0L))
// check if leader moves to the other server
- leader = waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId, oldLeaderOpt = Some(leader))
+ leader = waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId, oldLeaderOpt = Some(leader))
assertEquals("Leader must move to broker 1", 1, leader)
// bring the preferred replica back
@@ -138,7 +138,7 @@ class LogRecoveryTest extends ZooKeeperTestHarness {
// Update producer with new server settings
updateProducer()
- leader = waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId)
+ leader = waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId)
assertTrue("Leader must remain on broker 1, in case of ZooKeeper session expiration it can move to broker 0",
leader == 0 || leader == 1)
@@ -149,7 +149,7 @@ class LogRecoveryTest extends ZooKeeperTestHarness {
server2.startup()
updateProducer()
- leader = waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId, oldLeaderOpt = Some(leader))
+ leader = waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId, oldLeaderOpt = Some(leader))
assertTrue("Leader must remain on broker 0, in case of ZooKeeper session expiration it can move to broker 1",
leader == 0 || leader == 1)
@@ -184,7 +184,7 @@ class LogRecoveryTest extends ZooKeeperTestHarness {
@Test
def testHWCheckpointWithFailuresMultipleLogSegments(): Unit = {
- var leader = waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId)
+ var leader = waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId)
sendMessages(2)
var hw = 2L
@@ -202,7 +202,7 @@ class LogRecoveryTest extends ZooKeeperTestHarness {
server2.startup()
updateProducer()
// check if leader moves to the other server
- leader = waitUntilLeaderIsElectedOrChanged(zkUtils, topic, partitionId, oldLeaderOpt = Some(leader))
+ leader = waitUntilLeaderIsElectedOrChanged(zkClient, topic, partitionId, oldLeaderOpt = Some(leader))
assertEquals("Leader must move to broker 1", 1, leader)
assertEquals(hw, hwFile1.read.getOrElse(topicPartition, 0L))
diff --git a/core/src/test/scala/unit/kafka/server/MetadataRequestTest.scala b/core/src/test/scala/unit/kafka/server/MetadataRequestTest.scala
index 877d156..51e1d95 100644
--- a/core/src/test/scala/unit/kafka/server/MetadataRequestTest.scala
+++ b/core/src/test/scala/unit/kafka/server/MetadataRequestTest.scala
@@ -85,8 +85,8 @@ class MetadataRequestTest extends BaseRequestTest {
val internalTopic = Topic.GROUP_METADATA_TOPIC_NAME
val notInternalTopic = "notInternal"
// create the topics
- TestUtils.createTopic(zkUtils, internalTopic, 3, 2, servers)
- TestUtils.createTopic(zkUtils, notInternalTopic, 3, 2, servers)
+ TestUtils.createTopic(zkClient, internalTopic, 3, 2, servers)
+ TestUtils.createTopic(zkClient, notInternalTopic, 3, 2, servers)
val metadataResponse = sendMetadataRequest(MetadataRequest.Builder.allTopics.build(1.toShort))
assertTrue("Response should have no errors", metadataResponse.errors.isEmpty)
@@ -104,8 +104,8 @@ class MetadataRequestTest extends BaseRequestTest {
@Test
def testNoTopicsRequest() {
// create some topics
- TestUtils.createTopic(zkUtils, "t1", 3, 2, servers)
- TestUtils.createTopic(zkUtils, "t2", 3, 2, servers)
+ TestUtils.createTopic(zkClient, "t1", 3, 2, servers)
+ TestUtils.createTopic(zkClient, "t2", 3, 2, servers)
// v0, Doesn't support a "no topics" request
// v1, Empty list represents "no topics"
@@ -119,7 +119,7 @@ class MetadataRequestTest extends BaseRequestTest {
def checkAutoCreatedTopic(existingTopic: String, autoCreatedTopic: String, response: MetadataResponse): Unit = {
assertNull(response.errors.get(existingTopic))
assertEquals(Errors.LEADER_NOT_AVAILABLE, response.errors.get(autoCreatedTopic))
- assertEquals(Some(servers.head.config.numPartitions), zkUtils.getTopicPartitionCount(autoCreatedTopic))
+ assertEquals(Some(servers.head.config.numPartitions), zkClient.getTopicPartitionCount(autoCreatedTopic))
for (i <- 0 until servers.head.config.numPartitions)
TestUtils.waitUntilMetadataIsPropagated(servers, autoCreatedTopic, i)
}
@@ -128,7 +128,7 @@ class MetadataRequestTest extends BaseRequestTest {
val topic2 = "t2"
val topic3 = "t3"
val topic4 = "t4"
- TestUtils.createTopic(zkUtils, topic1, 1, 1, servers)
+ TestUtils.createTopic(zkClient, topic1, 1, 1, servers)
val response1 = sendMetadataRequest(new MetadataRequest(Seq(topic1, topic2).asJava, true, ApiKeys.METADATA.latestVersion))
checkAutoCreatedTopic(topic1, topic2, response1)
@@ -141,14 +141,14 @@ class MetadataRequestTest extends BaseRequestTest {
val response3 = sendMetadataRequest(new MetadataRequest(Seq(topic3, topic4).asJava, false, 4))
assertNull(response3.errors.get(topic3))
assertEquals(Errors.UNKNOWN_TOPIC_OR_PARTITION, response3.errors.get(topic4))
- assertEquals(None, zkUtils.getTopicPartitionCount(topic4))
+ assertEquals(None, zkClient.getTopicPartitionCount(topic4))
}
@Test
def testAllTopicsRequest() {
// create some topics
- TestUtils.createTopic(zkUtils, "t1", 3, 2, servers)
- TestUtils.createTopic(zkUtils, "t2", 3, 2, servers)
+ TestUtils.createTopic(zkClient, "t1", 3, 2, servers)
+ TestUtils.createTopic(zkClient, "t2", 3, 2, servers)
// v0, Empty list represents all topics
val metadataResponseV0 = sendMetadataRequest(new MetadataRequest(List[String]().asJava, true, 0.toShort))
@@ -167,7 +167,7 @@ class MetadataRequestTest extends BaseRequestTest {
@Test
def testPreferredReplica(): Unit = {
val replicaAssignment = Map(0 -> Seq(1, 2, 0), 1 -> Seq(2, 0, 1))
- TestUtils.createTopic(zkUtils, "t1", replicaAssignment, servers)
+ TestUtils.createTopic(zkClient, "t1", replicaAssignment, servers)
// Call controller and one different broker to ensure that metadata propagation works correctly
val responses = Seq(
sendMetadataRequest(new MetadataRequest.Builder(Seq("t1").asJava, true).build(), Some(controllerSocketServer)),
@@ -194,7 +194,7 @@ class MetadataRequestTest extends BaseRequestTest {
val replicaCount = 3
// create a topic with 3 replicas
- TestUtils.createTopic(zkUtils, replicaDownTopic, 1, replicaCount, servers)
+ TestUtils.createTopic(zkClient, replicaDownTopic, 1, replicaCount, servers)
// Kill a replica node that is not the leader
val metadataResponse = sendMetadataRequest(new MetadataRequest(List(replicaDownTopic).asJava, true, 1.toShort))
diff --git a/core/src/test/scala/unit/kafka/server/OffsetCommitTest.scala b/core/src/test/scala/unit/kafka/server/OffsetCommitTest.scala
index 61e17e3..0793fa3 100755
--- a/core/src/test/scala/unit/kafka/server/OffsetCommitTest.scala
+++ b/core/src/test/scala/unit/kafka/server/OffsetCommitTest.scala
@@ -78,7 +78,7 @@ class OffsetCommitTest extends ZooKeeperTestHarness {
val topicAndPartition = TopicAndPartition(topic, 0)
val expectedReplicaAssignment = Map(0 -> List(1))
// create the topic
- createTopic(zkUtils, topic, partitionReplicaAssignment = expectedReplicaAssignment, servers = Seq(server))
+ createTopic(zkClient, topic, partitionReplicaAssignment = expectedReplicaAssignment, servers = Seq(server))
val commitRequest = OffsetCommitRequest(group, immutable.Map(topicAndPartition -> OffsetAndMetadata(offset = 42L)))
val commitResponse = simpleConsumer.commitOffsets(commitRequest)
@@ -127,10 +127,10 @@ class OffsetCommitTest extends ZooKeeperTestHarness {
val topic4 = "topic-4" // Topic that group never consumes
val topic5 = "topic-5" // Non-existent topic
- createTopic(zkUtils, topic1, servers = Seq(server), numPartitions = 1)
- createTopic(zkUtils, topic2, servers = Seq(server), numPartitions = 2)
- createTopic(zkUtils, topic3, servers = Seq(server), numPartitions = 1)
- createTopic(zkUtils, topic4, servers = Seq(server), numPartitions = 1)
+ createTopic(zkClient, topic1, servers = Seq(server), numPartitions = 1)
+ createTopic(zkClient, topic2, servers = Seq(server), numPartitions = 2)
+ createTopic(zkClient, topic3, servers = Seq(server), numPartitions = 1)
+ createTopic(zkClient, topic4, servers = Seq(server), numPartitions = 1)
val commitRequest = OffsetCommitRequest("test-group", immutable.Map(
TopicAndPartition(topic1, 0) -> OffsetAndMetadata(offset=42L, metadata="metadata one"),
@@ -193,7 +193,7 @@ class OffsetCommitTest extends ZooKeeperTestHarness {
def testLargeMetadataPayload() {
val topicAndPartition = TopicAndPartition("large-metadata", 0)
val expectedReplicaAssignment = Map(0 -> List(1))
- createTopic(zkUtils, topicAndPartition.topic, partitionReplicaAssignment = expectedReplicaAssignment,
+ createTopic(zkClient, topicAndPartition.topic, partitionReplicaAssignment = expectedReplicaAssignment,
servers = Seq(server))
val commitRequest = OffsetCommitRequest("test-group", immutable.Map(topicAndPartition -> OffsetAndMetadata(
@@ -218,7 +218,7 @@ class OffsetCommitTest extends ZooKeeperTestHarness {
// set up topic partition
val topic = "topic"
val topicPartition = TopicAndPartition(topic, 0)
- createTopic(zkUtils, topic, servers = Seq(server), numPartitions = 1)
+ createTopic(zkClient, topic, servers = Seq(server), numPartitions = 1)
val fetchRequest = OffsetFetchRequest(group, Seq(TopicAndPartition(topic, 0)))
@@ -291,7 +291,7 @@ class OffsetCommitTest extends ZooKeeperTestHarness {
val topic1 = "topicDoesNotExists"
val topic2 = "topic-2"
- createTopic(zkUtils, topic2, servers = Seq(server), numPartitions = 1)
+ createTopic(zkClient, topic2, servers = Seq(server), numPartitions = 1)
// Commit an offset
val commitRequest = OffsetCommitRequest(group, immutable.Map(
@@ -309,7 +309,7 @@ class OffsetCommitTest extends ZooKeeperTestHarness {
// set up topic partition
val topic = "topic"
val topicPartition = TopicAndPartition(topic, 0)
- createTopic(zkUtils, topic, servers = Seq(server), numPartitions = 1)
+ createTopic(zkClient, topic, servers = Seq(server), numPartitions = 1)
val commitRequest = OffsetCommitRequest(group, immutable.Map(topicPartition -> OffsetAndMetadata(offset = 42L)))
val commitResponse = simpleConsumer.commitOffsets(commitRequest)
@@ -318,7 +318,7 @@ class OffsetCommitTest extends ZooKeeperTestHarness {
// start topic deletion
adminZkClient.deleteTopic(topic)
- TestUtils.verifyTopicDeletion(zkUtils, topic, 1, Seq(server))
+ TestUtils.verifyTopicDeletion(zkClient, topic, 1, Seq(server))
Thread.sleep(retentionCheckInterval * 2)
// check if offsets deleted
diff --git a/core/src/test/scala/unit/kafka/server/ProduceRequestTest.scala b/core/src/test/scala/unit/kafka/server/ProduceRequestTest.scala
index 5141ad5..6024499 100644
--- a/core/src/test/scala/unit/kafka/server/ProduceRequestTest.scala
+++ b/core/src/test/scala/unit/kafka/server/ProduceRequestTest.scala
@@ -61,7 +61,7 @@ class ProduceRequestTest extends BaseRequestTest {
/* returns a pair of partition id and leader id */
private def createTopicAndFindPartitionWithLeader(topic: String): (Int, Int) = {
- val partitionToLeader = TestUtils.createTopic(zkUtils, topic, 3, 2, servers)
+ val partitionToLeader = TestUtils.createTopic(zkClient, topic, 3, 2, servers)
partitionToLeader.collectFirst {
case (partition, leader) if leader != -1 => (partition, leader)
}.getOrElse(fail(s"No leader elected for topic $topic"))
diff --git a/core/src/test/scala/unit/kafka/server/ReplicaFetchTest.scala b/core/src/test/scala/unit/kafka/server/ReplicaFetchTest.scala
index b8c45a5..c478ba2 100644
--- a/core/src/test/scala/unit/kafka/server/ReplicaFetchTest.scala
+++ b/core/src/test/scala/unit/kafka/server/ReplicaFetchTest.scala
@@ -51,7 +51,7 @@ class ReplicaFetchTest extends ZooKeeperTestHarness {
// create a topic and partition and await leadership
for (topic <- List(topic1,topic2)) {
- createTopic(zkUtils, topic, numPartitions = 1, replicationFactor = 2, servers = brokers)
+ createTopic(zkClient, topic, numPartitions = 1, replicationFactor = 2, servers = brokers)
}
// send test messages to leader
diff --git a/core/src/test/scala/unit/kafka/server/RequestQuotaTest.scala b/core/src/test/scala/unit/kafka/server/RequestQuotaTest.scala
index ee75933..5c80288 100644
--- a/core/src/test/scala/unit/kafka/server/RequestQuotaTest.scala
+++ b/core/src/test/scala/unit/kafka/server/RequestQuotaTest.scala
@@ -74,7 +74,7 @@ class RequestQuotaTest extends BaseRequestTest {
RequestQuotaTest.principal = KafkaPrincipal.ANONYMOUS
super.setUp()
- TestUtils.createTopic(zkUtils, topic, numPartitions, 1, servers)
+ TestUtils.createTopic(zkClient, topic, numPartitions, 1, servers)
leaderNode = servers.head
// Change default client-id request quota to a small value and a single unthrottledClient with a large quota
diff --git a/core/src/test/scala/unit/kafka/server/ServerGenerateClusterIdTest.scala b/core/src/test/scala/unit/kafka/server/ServerGenerateClusterIdTest.scala
index 1ec80fa..54ba887 100755
--- a/core/src/test/scala/unit/kafka/server/ServerGenerateClusterIdTest.scala
+++ b/core/src/test/scala/unit/kafka/server/ServerGenerateClusterIdTest.scala
@@ -62,7 +62,7 @@ class ServerGenerateClusterIdTest extends ZooKeeperTestHarness {
// Make sure that the cluster id is persistent.
assertTrue(zkUtils.pathExists(ZkUtils.ClusterIdPath))
- assertEquals(zkUtils.getClusterId, Some(clusterIdOnFirstBoot))
+ assertEquals(zkClient.getClusterId, Some(clusterIdOnFirstBoot))
// Restart the server check to confirm that it uses the clusterId generated previously
server1 = TestUtils.createServer(config1)
@@ -75,7 +75,7 @@ class ServerGenerateClusterIdTest extends ZooKeeperTestHarness {
// Make sure that the cluster id is persistent after multiple reboots.
assertTrue(zkUtils.pathExists(ZkUtils.ClusterIdPath))
- assertEquals(zkUtils.getClusterId, Some(clusterIdOnFirstBoot))
+ assertEquals(zkClient.getClusterId, Some(clusterIdOnFirstBoot))
TestUtils.verifyNonDaemonThreadsStatus(this.getClass.getName)
}
diff --git a/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala b/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala
index c8c3076..596c353 100755
--- a/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala
+++ b/core/src/test/scala/unit/kafka/server/ServerShutdownTest.scala
@@ -63,7 +63,7 @@ class ServerShutdownTest extends ZooKeeperTestHarness {
var producer = createProducer(server)
// create topic
- createTopic(zkUtils, topic, numPartitions = 1, replicationFactor = 1, servers = Seq(server))
+ createTopic(zkClient, topic, numPartitions = 1, replicationFactor = 1, servers = Seq(server))
// send some messages
sent1.map(value => producer.send(new ProducerRecord(topic, 0, value))).foreach(_.get)
@@ -137,7 +137,7 @@ class ServerShutdownTest extends ZooKeeperTestHarness {
def testCleanShutdownAfterFailedStartupDueToCorruptLogs() {
val server = new KafkaServer(config)
server.startup()
- createTopic(zkUtils, topic, numPartitions = 1, replicationFactor = 1, servers = Seq(server))
+ createTopic(zkClient, topic, numPartitions = 1, replicationFactor = 1, servers = Seq(server))
server.shutdown()
server.awaitShutdown()
config.logDirs.foreach { dirName =>
diff --git a/core/src/test/scala/unit/kafka/server/ServerStartupTest.scala b/core/src/test/scala/unit/kafka/server/ServerStartupTest.scala
index ff9178a..3414c36 100755
--- a/core/src/test/scala/unit/kafka/server/ServerStartupTest.scala
+++ b/core/src/test/scala/unit/kafka/server/ServerStartupTest.scala
@@ -109,7 +109,7 @@ class ServerStartupTest extends ZooKeeperTestHarness {
class BrokerStateInterceptor() extends BrokerState {
override def newState(newState: BrokerStates): Unit = {
- val brokers = zkUtils.getAllBrokersInCluster()
+ val brokers = zkClient.getAllBrokersInCluster
assertEquals(1, brokers.size)
assertEquals(brokerId, brokers.head.id)
}
diff --git a/core/src/test/scala/unit/kafka/server/epoch/EpochDrivenReplicationProtocolAcceptanceTest.scala b/core/src/test/scala/unit/kafka/server/epoch/EpochDrivenReplicationProtocolAcceptanceTest.scala
index a44f900..6288d8f 100644
--- a/core/src/test/scala/unit/kafka/server/epoch/EpochDrivenReplicationProtocolAcceptanceTest.scala
+++ b/core/src/test/scala/unit/kafka/server/epoch/EpochDrivenReplicationProtocolAcceptanceTest.scala
@@ -274,7 +274,7 @@ class EpochDrivenReplicationProtocolAcceptanceTest extends ZooKeeperTestHarness
//Now invoke the fast leader change bug
(0 until 5).foreach { i =>
- val leaderId = zkUtils.getLeaderForPartition(topic, 0).get
+ val leaderId = zkClient.getLeaderForPartition(new TopicPartition(topic, 0)).get
val leader = brokers.filter(_.config.brokerId == leaderId)(0)
val follower = brokers.filter(_.config.brokerId != leaderId)(0)
@@ -379,13 +379,13 @@ class EpochDrivenReplicationProtocolAcceptanceTest extends ZooKeeperTestHarness
private def leader(): KafkaServer = {
assertEquals(2, brokers.size)
- val leaderId = zkUtils.getLeaderForPartition(topic, 0).get
+ val leaderId = zkClient.getLeaderForPartition(new TopicPartition(topic, 0)).get
brokers.filter(_.config.brokerId == leaderId)(0)
}
private def follower(): KafkaServer = {
assertEquals(2, brokers.size)
- val leader = zkUtils.getLeaderForPartition(topic, 0).get
+ val leader = zkClient.getLeaderForPartition(new TopicPartition(topic, 0)).get
brokers.filter(_.config.brokerId != leader)(0)
}
diff --git a/core/src/test/scala/unit/kafka/server/epoch/LeaderEpochIntegrationTest.scala b/core/src/test/scala/unit/kafka/server/epoch/LeaderEpochIntegrationTest.scala
index eaafb2a..7781801 100644
--- a/core/src/test/scala/unit/kafka/server/epoch/LeaderEpochIntegrationTest.scala
+++ b/core/src/test/scala/unit/kafka/server/epoch/LeaderEpochIntegrationTest.scala
@@ -64,7 +64,7 @@ class LeaderEpochIntegrationTest extends ZooKeeperTestHarness with Logging {
// Given two topics with replication of a single partition
for (topic <- List(topic1, topic2)) {
- createTopic(zkUtils, topic, Map(0 -> Seq(0, 1)), servers = brokers)
+ createTopic(zkClient, topic, Map(0 -> Seq(0, 1)), servers = brokers)
}
// When we send four messages
diff --git a/core/src/test/scala/unit/kafka/utils/ReplicationUtilsTest.scala b/core/src/test/scala/unit/kafka/utils/ReplicationUtilsTest.scala
index 05f8379..3a42c3b 100644
--- a/core/src/test/scala/unit/kafka/utils/ReplicationUtilsTest.scala
+++ b/core/src/test/scala/unit/kafka/utils/ReplicationUtilsTest.scala
@@ -63,7 +63,7 @@ class ReplicationUtilsTest extends ZooKeeperTestHarness {
EasyMock.expect(replicaManager.zkClient).andReturn(zkClient)
EasyMock.replay(replicaManager)
- zkUtils.makeSurePersistentPathExists(ZkUtils.IsrChangeNotificationPath)
+ zkClient.makeSurePersistentPathExists(ZkUtils.IsrChangeNotificationPath)
val replicas = List(0, 1)
diff --git a/core/src/test/scala/unit/kafka/utils/TestUtils.scala b/core/src/test/scala/unit/kafka/utils/TestUtils.scala
index bb15e7b..c8a81c7 100755
--- a/core/src/test/scala/unit/kafka/utils/TestUtils.scala
+++ b/core/src/test/scala/unit/kafka/utils/TestUtils.scala
@@ -26,7 +26,6 @@ import java.util.{Collections, Properties}
import java.util.concurrent.{Callable, Executors, TimeUnit}
import javax.net.ssl.X509TrustManager
-import kafka.admin.AdminUtils
import kafka.api._
import kafka.cluster.{Broker, EndPoint}
import kafka.common.TopicAndPartition
@@ -40,6 +39,7 @@ import kafka.server._
import kafka.server.checkpoints.OffsetCheckpointFile
import ZkUtils._
import Implicits._
+import kafka.zk.{AdminZkClient, BrokerIdsZNode, BrokerInfo, KafkaZkClient}
import org.apache.kafka.clients.CommonClientConfigs
import org.apache.kafka.clients.consumer.{ConsumerRecord, KafkaConsumer, OffsetAndMetadata, RangeAssignor}
import org.apache.kafka.clients.producer.{KafkaProducer, ProducerConfig, ProducerRecord}
@@ -279,18 +279,19 @@ object TestUtils extends Logging {
* Wait until the leader is elected and the metadata is propagated to all brokers.
* Return the leader for each partition.
*/
- def createTopic(zkUtils: ZkUtils,
+ def createTopic(zkClient: KafkaZkClient,
topic: String,
numPartitions: Int = 1,
replicationFactor: Int = 1,
servers: Seq[KafkaServer],
topicConfig: Properties = new Properties): scala.collection.immutable.Map[Int, Int] = {
+ val adminZkClient = new AdminZkClient(zkClient)
// create topic
- AdminUtils.createTopic(zkUtils, topic, numPartitions, replicationFactor, topicConfig)
+ adminZkClient.createTopic(topic, numPartitions, replicationFactor, topicConfig)
// wait until the update metadata request for new topic reaches all servers
(0 until numPartitions).map { i =>
TestUtils.waitUntilMetadataIsPropagated(servers, topic, i)
- i -> TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic, i)
+ i -> TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic, i)
}.toMap
}
@@ -299,14 +300,15 @@ object TestUtils extends Logging {
* Wait until the leader is elected and the metadata is propagated to all brokers.
* Return the leader for each partition.
*/
- def createTopic(zkUtils: ZkUtils, topic: String, partitionReplicaAssignment: collection.Map[Int, Seq[Int]],
+ def createTopic(zkClient: KafkaZkClient, topic: String, partitionReplicaAssignment: collection.Map[Int, Seq[Int]],
servers: Seq[KafkaServer]): scala.collection.immutable.Map[Int, Int] = {
+ val adminZkClient = new AdminZkClient(zkClient)
// create topic
- AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK(zkUtils, topic, partitionReplicaAssignment)
+ adminZkClient.createOrUpdateTopicPartitionAssignmentPathInZK(topic, partitionReplicaAssignment)
// wait until the update metadata request for new topic reaches all servers
partitionReplicaAssignment.keySet.map { case i =>
TestUtils.waitUntilMetadataIsPropagated(servers, topic, i)
- i -> TestUtils.waitUntilLeaderIsElectedOrChanged(zkUtils, topic, i)
+ i -> TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic, i)
}.toMap
}
@@ -314,9 +316,9 @@ object TestUtils extends Logging {
* Create the consumer offsets/group metadata topic and wait until the leader is elected and metadata is propagated
* to all brokers.
*/
- def createOffsetsTopic(zkUtils: ZkUtils, servers: Seq[KafkaServer]): Unit = {
+ def createOffsetsTopic(zkClient: KafkaZkClient, servers: Seq[KafkaServer]): Unit = {
val server = servers.head
- createTopic(zkUtils, Topic.GROUP_METADATA_TOPIC_NAME,
+ createTopic(zkClient, Topic.GROUP_METADATA_TOPIC_NAME,
server.config.getInt(KafkaConfig.OffsetsTopicPartitionsProp),
server.config.getShort(KafkaConfig.OffsetsTopicReplicationFactorProp).toInt,
servers,
@@ -695,23 +697,24 @@ object TestUtils extends Logging {
}
}
- def createBrokersInZk(zkUtils: ZkUtils, ids: Seq[Int]): Seq[Broker] =
- createBrokersInZk(ids.map(kafka.admin.BrokerMetadata(_, None)), zkUtils)
+ def createBrokersInZk(zkClient: KafkaZkClient, ids: Seq[Int]): Seq[Broker] =
+ createBrokersInZk(ids.map(kafka.admin.BrokerMetadata(_, None)), zkClient)
- def createBrokersInZk(brokerMetadatas: Seq[kafka.admin.BrokerMetadata], zkUtils: ZkUtils): Seq[Broker] = {
+ def createBrokersInZk(brokerMetadatas: Seq[kafka.admin.BrokerMetadata], zkClient: KafkaZkClient): Seq[Broker] = {
+ zkClient.makeSurePersistentPathExists(BrokerIdsZNode.path)
val brokers = brokerMetadatas.map { b =>
val protocol = SecurityProtocol.PLAINTEXT
val listenerName = ListenerName.forSecurityProtocol(protocol)
Broker(b.id, Seq(EndPoint("localhost", 6667, listenerName, protocol)), b.rack)
}
- brokers.foreach(b => zkUtils.registerBrokerInZk(b.id, "localhost", 6667, b.endPoints, jmxPort = -1,
- rack = b.rack, ApiVersion.latestVersion))
+ brokers.foreach(b => zkClient.registerBrokerInZk(new BrokerInfo(b.id, "localhost", 6667,
+ b.endPoints, jmxPort = -1, rack = b.rack, ApiVersion.latestVersion)))
brokers
}
- def deleteBrokersInZk(zkUtils: ZkUtils, ids: Seq[Int]): Seq[Broker] = {
+ def deleteBrokersInZk(zkClient: KafkaZkClient, ids: Seq[Int]): Seq[Broker] = {
val brokers = ids.map(createBroker(_, "localhost", 6667, SecurityProtocol.PLAINTEXT))
- brokers.foreach(b => zkUtils.deletePath(ZkUtils.BrokerIdsPath + "/" + b))
+ brokers.foreach(b => zkClient.deletePath(BrokerIdsZNode.path + "/" + b))
brokers
}
@@ -779,7 +782,7 @@ object TestUtils extends Logging {
* LeaderDuringDelete).
* @throws AssertionError if the expected condition is not true within the timeout.
*/
- def waitUntilLeaderIsElectedOrChanged(zkUtils: ZkUtils, topic: String, partition: Int, timeoutMs: Long = 30000L,
+ def waitUntilLeaderIsElectedOrChanged(zkClient: KafkaZkClient, topic: String, partition: Int, timeoutMs: Long = 30000L,
oldLeaderOpt: Option[Int] = None, newLeaderOpt: Option[Int] = None): Int = {
require(!(oldLeaderOpt.isDefined && newLeaderOpt.isDefined), "Can't define both the old and the new leader")
val startTime = System.currentTimeMillis()
@@ -792,7 +795,7 @@ object TestUtils extends Logging {
var electedOrChangedLeader: Option[Int] = None
while (electedOrChangedLeader.isEmpty && System.currentTimeMillis() < startTime + timeoutMs) {
// check if leader is elected
- leader = zkUtils.getLeaderForPartition(topic, partition)
+ leader = zkClient.getLeaderForPartition(new TopicPartition(topic, partition))
leader match {
case Some(l) => (newLeaderOpt, oldLeaderOpt) match {
case (Some(newLeader), _) if newLeader == l =>
@@ -1008,10 +1011,6 @@ object TestUtils extends Logging {
"Reassigned partition [%s,%d] is under-replicated as reported by the leader %d".format(topic, partitionToBeReassigned, leader.get))
}
- def checkIfReassignPartitionPathExists(zkUtils: ZkUtils): Boolean = {
- zkUtils.pathExists(ZkUtils.ReassignPartitionsPath)
- }
-
def verifyNonDaemonThreadsStatus(threadNamePrefix: String) {
val threadCount = Thread.getAllStackTraces.keySet.asScala.count { t =>
!t.isDaemon && t.isAlive && t.getName.startsWith(threadNamePrefix)
@@ -1164,12 +1163,12 @@ object TestUtils extends Logging {
messages.reverse
}
- def verifyTopicDeletion(zkUtils: ZkUtils, topic: String, numPartitions: Int, servers: Seq[KafkaServer]) {
+ def verifyTopicDeletion(zkClient: KafkaZkClient, topic: String, numPartitions: Int, servers: Seq[KafkaServer]) {
val topicPartitions = (0 until numPartitions).map(new TopicPartition(topic, _))
// wait until admin path for delete topic is deleted, signaling completion of topic deletion
- TestUtils.waitUntilTrue(() => !zkUtils.isTopicMarkedForDeletion(topic),
+ TestUtils.waitUntilTrue(() => !zkClient.isTopicMarkedForDeletion(topic),
"Admin path /admin/delete_topic/%s path not deleted even after a replica is restarted".format(topic))
- TestUtils.waitUntilTrue(() => !zkUtils.pathExists(getTopicPath(topic)),
+ TestUtils.waitUntilTrue(() => !zkClient.topicExists(topic),
"Topic path /brokers/topics/%s not deleted after /admin/delete_topic/%s path is deleted".format(topic, topic))
// ensure that the topic-partition has been deleted from all brokers' replica managers
TestUtils.waitUntilTrue(() =>
diff --git a/core/src/test/scala/unit/kafka/zk/AdminZkClientTest.scala b/core/src/test/scala/unit/kafka/zk/AdminZkClientTest.scala
index 993dcf2..1fdc3ea 100644
--- a/core/src/test/scala/unit/kafka/zk/AdminZkClientTest.scala
+++ b/core/src/test/scala/unit/kafka/zk/AdminZkClientTest.scala
@@ -50,7 +50,7 @@ class AdminZkClientTest extends ZooKeeperTestHarness with Logging with RackAware
@Test
def testManualReplicaAssignment() {
val brokers = List(0, 1, 2, 3, 4)
- TestUtils.createBrokersInZk(zkUtils, brokers)
+ TestUtils.createBrokersInZk(zkClient, brokers)
// duplicate brokers
intercept[InvalidReplicaAssignmentException] {
@@ -101,7 +101,7 @@ class AdminZkClientTest extends ZooKeeperTestHarness with Logging with RackAware
11 -> 1
)
val topic = "test"
- TestUtils.createBrokersInZk(zkUtils, List(0, 1, 2, 3, 4))
+ TestUtils.createBrokersInZk(zkClient, List(0, 1, 2, 3, 4))
// create the topic
adminZkClient.createOrUpdateTopicPartitionAssignmentPathInZK(topic, expectedReplicaAssignment)
// create leaders for all partitions
@@ -121,7 +121,7 @@ class AdminZkClientTest extends ZooKeeperTestHarness with Logging with RackAware
def testTopicCreationWithCollision() {
val topic = "test.topic"
val collidingTopic = "test_topic"
- TestUtils.createBrokersInZk(zkUtils, List(0, 1, 2, 3, 4))
+ TestUtils.createBrokersInZk(zkClient, List(0, 1, 2, 3, 4))
// create the topic
adminZkClient.createTopic(topic, 3, 1)
@@ -296,7 +296,7 @@ class AdminZkClientTest extends ZooKeeperTestHarness with Logging with RackAware
val brokerList = 0 to 5
val rackInfo = Map(0 -> "rack1", 1 -> "rack2", 2 -> "rack2", 3 -> "rack1", 5 -> "rack3")
val brokerMetadatas = toBrokerMetadata(rackInfo, brokersWithoutRack = brokerList.filterNot(rackInfo.keySet))
- TestUtils.createBrokersInZk(brokerMetadatas, zkUtils)
+ TestUtils.createBrokersInZk(brokerMetadatas, zkClient)
val processedMetadatas1 = adminZkClient.getBrokerMetadatas(RackAwareMode.Disabled)
assertEquals(brokerList, processedMetadatas1.map(_.id))
--
To stop receiving notification emails like this one, please contact
['"commits@kafka.apache.org" <co...@kafka.apache.org>'].