You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/05/05 21:57:08 UTC

[GitHub] [kafka] ambroff commented on a change in pull request #4540: KAFKA-6469 Batch ISR change notifications

ambroff commented on a change in pull request #4540:
URL: https://github.com/apache/kafka/pull/4540#discussion_r420430926



##########
File path: core/src/test/scala/integration/kafka/server/ReplicaManagerTest.scala
##########
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package integration.kafka.server
+
+import kafka.server.KafkaConfig
+import kafka.utils.TestUtils
+import kafka.zk.ZooKeeperTestHarness
+import org.apache.kafka.common.TopicPartition
+import org.apache.kafka.common.utils.MockTime
+import org.junit.Test
+import org.junit.Assert._
+
+class ReplicaManagerTest extends ZooKeeperTestHarness {
+  @Test
+  def testMaybePropagateIsrChanges(): Unit = {
+    val config = KafkaConfig.fromProps(TestUtils.createBrokerConfig(1, zkConnect))
+    val mockTime = new MockTime(10000)
+    val server = TestUtils.createServer(config, mockTime)
+
+    // Topic name which is the maximum length of 249.
+    val largeTopicName = ("topic-" padTo(249, "x")).mkString
+
+    // 5000 partitions. Large partition numbers chosen to make the serialized values as long as possible.
+    (10000 to 15000)
+      .map(n => new TopicPartition(largeTopicName, n))
+      .foreach(server.replicaManager.recordIsrChange)
+
+    server.replicaManager.maybePropagateIsrChanges()
+
+    val isrChangeNotificationQueuePath = "/isr_change_notification"
+    val node0 = "isr_change_0000000000"
+    val node1 = "isr_change_0000000001"
+
+    assertEquals(
+      zkClient.getChildren(isrChangeNotificationQueuePath).toSet,
+      Set(node0, node1))
+
+    val (_, stat0) = zkClient.getDataAndStat(isrChangeNotificationQueuePath + "/" + node0)
+    val (_, stat1) = zkClient.getDataAndStat(isrChangeNotificationQueuePath + "/" + node1)
+
+    assertEquals(840028, stat0.getDataLength)
+    assertEquals(560308, stat1.getDataLength)

Review comment:
       Good point I moved the test to the existing `ReplicaManagerTest`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org