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

Ewen Cheslack-Postava commented on KAFKA-2103:
----------------------------------------------

Agreed with [~becket_qin] that the test shouldn't be assuming things out of 
it's control. I made some changes to this test in KAFKA-1501 and part of the 
point of the patch that ultimately resolved 1501 is that it removes as many 
cases of a getNextUnusedPort() as possible. I'd discourage trying to use it 
here (one does exist in integration.kafka.api.FixedPortTestUtils, but note that 
it's under the *integration* package for a reason).

Some notes:

* I left a note when refactoring that using fixed values here was ok because 
things were mocked. I didn't notice that if you work through a couple layers of 
that code, it ends up parsing the broker list for getting metadata -- not all 
of the code is properly mocked for the unit test.
* Turns out that TestUtils.createBrokerConfig was broken -- it was not properly 
setting the port in the config. This seems to be the real issue for this 
particular test since I chose a broker port that is incredibly unlikely to be 
bound whereas before it was using the default 9092 which is probably commonly 
bound on developers' machines. I've submitted that patch as a temporary fix, 
but it doesn't really resolve the underlying issue that this unit test is 
actually trying to communicate with the server rather than using a mocked out 
implementation.
* I tried an approach where we can allocate ports but don't close them, use 
those ports numbers, and then during teardown clean it up. I think this is the 
only way to safely use real ports allocated dynamically. This works, but has to 
wait for the connections that it's trying to start to timeout. We could use 
FixedPortTestUtils' existing method, but that can run into the same issues we 
were trying to resolve in KAFKA-1501.

> kafka.producer.AsyncProducerTest failure.
> -----------------------------------------
>
>                 Key: KAFKA-2103
>                 URL: https://issues.apache.org/jira/browse/KAFKA-2103
>             Project: Kafka
>          Issue Type: Sub-task
>            Reporter: Jiangjie Qin
>            Assignee: Ewen Cheslack-Postava
>         Attachments: KAFKA-2103.patch
>
>
> I saw this test consistently failing on trunk.
> The recent changes are KAFKA-2099, KAFKA-1926, KAFKA-1809.
> kafka.producer.AsyncProducerTest > testNoBroker FAILED
>     org.scalatest.junit.JUnitTestFailedError: Should fail with 
> FailedToSendMessageException
>         at 
> org.scalatest.junit.AssertionsForJUnit$class.newAssertionFailedException(AssertionsForJUnit.scala:101)
>         at 
> org.scalatest.junit.JUnit3Suite.newAssertionFailedException(JUnit3Suite.scala:149)
>         at org.scalatest.Assertions$class.fail(Assertions.scala:711)
>         at org.scalatest.junit.JUnit3Suite.fail(JUnit3Suite.scala:149)
>         at 
> kafka.producer.AsyncProducerTest.testNoBroker(AsyncProducerTest.scala:300)
> kafka.producer.AsyncProducerTest > testIncompatibleEncoder PASSED
> kafka.producer.AsyncProducerTest > testRandomPartitioner PASSED
> kafka.producer.AsyncProducerTest > testFailedSendRetryLogic FAILED
>     kafka.common.FailedToSendMessageException: Failed to send messages after 
> 3 tries.
>         at 
> kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:91)
>         at 
> kafka.producer.AsyncProducerTest.testFailedSendRetryLogic(AsyncProducerTest.scala:415)



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

Reply via email to