You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Jonathan Natkins (JIRA)" <ji...@apache.org> on 2014/07/22 21:30:42 UTC

[jira] [Comment Edited] (KAFKA-1420) Replace AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK with TestUtils.createTopic in all unit tests

    [ https://issues.apache.org/jira/browse/KAFKA-1420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14070756#comment-14070756 ] 

Jonathan Natkins edited comment on KAFKA-1420 at 7/22/14 7:30 PM:
------------------------------------------------------------------

Hi Guozhang,

The particular case I'm confused by is a test like this:

{code}
  @Test
  def testManualReplicaAssignment() {
    val brokers = List(0, 1, 2, 3, 4)
    TestUtils.createBrokersInZk(zkClient, brokers)

    // duplicate brokers
    intercept[IllegalArgumentException] {
      AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK(zkClient, "test", Map(0->Seq(0,0)))
    }

    // inconsistent replication factor
    intercept[IllegalArgumentException] {
      AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK(zkClient, "test", Map(0->Seq(0,1), 1->Seq(0)))
    }

    // good assignment
    val assignment = Map(0 -> List(0, 1, 2),
                         1 -> List(1, 2, 3))
    AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK(zkClient, "test", assignment)
    val found = ZkUtils.getPartitionAssignmentForTopics(zkClient, Seq("test"))
    assertEquals(assignment, found("test"))
  }
{code}

This test uses createOrUpdate, but creates brokers via createBrokersInZk, which doesn't return a reference to a KafkaServer.

The createTopic call, on the other hand, has two implementations:

{code}
def createTopic(zkClient: ZkClient, topic: String, numPartitions: Int = 1, replicationFactor: Int = 1,
                  servers: Seq[KafkaServer])

def createTopic(zkClient: ZkClient, topic: String, partitionReplicaAssignment: collection.Map[Int, Seq[Int]],
                  servers: Seq[KafkaServer])
{code}

In both cases, I need a Seq[KafkaServer]. It's unclear to me how to convert the aforementioned test to use createTopic, without materially changing the semantics of the test. Currently it doesn't use a real Kafka server, but to use createTopic would require me to get a hold of some real servers.

How would a conversion like this be done? Hopefully this clarifies why I'm confused.


was (Author: natty):
Hi Guozhang,

The particular case I'm confused by is a test like this:

{code:scala}
  @Test
  def testManualReplicaAssignment() {
    val brokers = List(0, 1, 2, 3, 4)
    TestUtils.createBrokersInZk(zkClient, brokers)

    // duplicate brokers
    intercept[IllegalArgumentException] {
      AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK(zkClient, "test", Map(0->Seq(0,0)))
    }

    // inconsistent replication factor
    intercept[IllegalArgumentException] {
      AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK(zkClient, "test", Map(0->Seq(0,1), 1->Seq(0)))
    }

    // good assignment
    val assignment = Map(0 -> List(0, 1, 2),
                         1 -> List(1, 2, 3))
    AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK(zkClient, "test", assignment)
    val found = ZkUtils.getPartitionAssignmentForTopics(zkClient, Seq("test"))
    assertEquals(assignment, found("test"))
  }
{code}

This test uses createOrUpdate, but creates brokers via createBrokersInZk, which doesn't return a reference to a KafkaServer.

The createTopic call, on the other hand, has two implementations:

{code:scala}
def createTopic(zkClient: ZkClient, topic: String, numPartitions: Int = 1, replicationFactor: Int = 1,
                  servers: Seq[KafkaServer])

def createTopic(zkClient: ZkClient, topic: String, partitionReplicaAssignment: collection.Map[Int, Seq[Int]],
                  servers: Seq[KafkaServer])
{scala}

In both cases, I need a Seq[KafkaServer]. It's unclear to me how to convert the aforementioned test to use createTopic, without materially changing the semantics of the test. Currently it doesn't use a real Kafka server, but to use createTopic would require me to get a hold of some real servers.

How would a conversion like this be done? Hopefully this clarifies why I'm confused.

> Replace AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK with TestUtils.createTopic in all unit tests
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-1420
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1420
>             Project: Kafka
>          Issue Type: Bug
>            Reporter: Guozhang Wang
>              Labels: newbie
>             Fix For: 0.8.2
>
>
> This is a follow-up JIRA from KAFKA-1389



--
This message was sent by Atlassian JIRA
(v6.2#6252)