You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Jay Kreps (JIRA)" <ji...@apache.org> on 2015/01/24 05:54:34 UTC

[jira] [Commented] (KAFKA-1897) Enhance MockProducer for more sophisticated tests

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

Jay Kreps commented on KAFKA-1897:
----------------------------------

Thanks for reporting this. It would be great to make that mock as usable as possible.

1. Can't you just call new Cluster(nodes, partitions) passing in the nodes and partitions you want to have? Are you saying this doesn't work or just that it is inconvenient? We can add a constructor to MockProducer that calls new Cluster() for you perhaps...? We already have a constructor that doesn't require you to specify the cluster and ignores the partition if you don't care. The issue here is that if anything in your test depends on the partitioning then you will want to control the test cluster you are setting up, right? So right now the assumption if you care about partitioning you make a Cluster and pass it in, if you don't you use the other constructor...
2. I think it does support this, no? Usage looks like this:
{code}
MockProducer p = new MockProducer(false);
Future<?> f = p.send(myRecord);
assertFalse(f.isComplete());
p.completeNext();
assertTrue(f.isComplete());
{code}

For both of these I'm not sure if the issue here is documentation or a gap in the code. Or maybe it is brokern? If it is documentation I wonder if you could give a patch that gives a better usage example in the Javadoc and would have helped you understand it better? If the gap is missing functionality maybe you could make some suggestion?

> Enhance MockProducer for more sophisticated tests
> -------------------------------------------------
>
>                 Key: KAFKA-1897
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1897
>             Project: Kafka
>          Issue Type: Bug
>          Components: producer 
>            Reporter: Navina Ramesh
>            Assignee: Jun Rao
>             Fix For: 0.8.2
>
>
> Based on the experience of upgrading the kafka producer in Samza, we faced two main constraints when using MockProducer: 
> 1. The constructor requires a cluster specification and the tools to create a test cluster is not exposed. It is available from TestUtils in Kafka, however that jar is not published. This issue is currently being addressed in KAFKA-1861.
> 2. No support for testing a blocking client call. For example, "flush" in Samza blocks on the future returned by the latest send request. In order to test this, the MockProducer which buffers it should run in a concurrent mode. There is currently no provision to do this. We want the MockProducer to buffer the send and then, complete the callback concurrently while we wait for "flush" to unblock. 
> We can write unit tests that have improved coverage if we can add support for concurrent execution of the MockProducer and unit test thread. For example implementation, please refer to the latest version of KafkaSystemProducer.scala in the Apache Samza repository.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)