This repository was archived by the owner on Jan 24, 2024. It is now read-only.
Fix flaky testCreateInvalidTopics#361
Merged
jiazhai merged 2 commits intostreamnative:masterfrom Feb 1, 2021
Merged
Conversation
jiazhai
approved these changes
Feb 1, 2021
BewareMyPower
added a commit
that referenced
this pull request
Feb 9, 2021
The `testCreateInvalidTopics` sometimes failed in CI environment, like
```
Error: testCreateInvalidTopics(io.streamnative.pulsar.handlers.kop.KafkaRequestHandlerTest) Time elapsed: 5.022 s <<< FAILURE!
java.lang.AssertionError: expected [true] but found [false]
at org.testng.Assert.fail(Assert.java:96)
at org.testng.Assert.failNotEquals(Assert.java:776)
at org.testng.Assert.assertTrue(Assert.java:44)
at org.testng.Assert.assertTrue(Assert.java:54)
at io.streamnative.pulsar.handlers.kop.KafkaRequestHandlerTest.testCreateInvalidTopics(KafkaRequestHandlerTest.java:359)
```
However here we only use `assertTrue` to check the cause type of the `ExecutionException` but not printed it. So this PR adds error logs for debugging.
Normally it should returns a `TimeoutException`. However, the `KafkaAdmin` could also generate an `UnknownServerException` sometimes, whose error message is just what the server's response is. Here's a sample output of a CI failure:
> Failed to create topics: {xxx/testCreateInvalidTopics-0=1} caused by org.apache.kafka.common.errors.UnknownServerException: Invalid short topic name 'xxx/testCreateInvalidTopics-0', it should be in the format of <tenant>/<namespace>/<topic> or <topic>
The exception message is from `KopTopic#expandToFullName` that is thrown in `AdminManager#createTopicsAsync`.
So this PR looses the check of exception type to make the test pass.
jiazhai
pushed a commit
that referenced
this pull request
Jun 28, 2021
Fixes #591 ### Motivation Kafka Connect use `Admin#createTopics` and check the `TopicExistsException` exception for existed topics. See https://github.com/apache/kafka/blob/ef3cd68c852daf21d8e207fa8e21c8770f4041d7/connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java#L394 for details. However, currently `Admin#createTopics` will return an `UnknownServerException` for any failure when create topics. In addition, the handler for CreateTopics request has other problems. 1. The default partition number (-1) is not handled, which may throw exception from `createPartitionedTopicAsync`. 2. If topic name is invalid, the future won't be completed until timeout. See #361, TimeoutException will be thrown in this case. ### Modifications 1. When the topic to create already exists, return a `TopicExistsException`. 2. Add a `tryComplete` method to complete a future of topic creation that may also complete the future of response. 3. Add related tests. ===== * Fix some bugs for create topic request * Fix KStreamAggregationTest * Catch KoPTopicException instead of RuntimeException
BewareMyPower
added a commit
that referenced
this pull request
Jun 29, 2021
Fixes #591 ### Motivation Kafka Connect use `Admin#createTopics` and check the `TopicExistsException` exception for existed topics. See https://github.com/apache/kafka/blob/ef3cd68c852daf21d8e207fa8e21c8770f4041d7/connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java#L394 for details. However, currently `Admin#createTopics` will return an `UnknownServerException` for any failure when create topics. In addition, the handler for CreateTopics request has other problems. 1. The default partition number (-1) is not handled, which may throw exception from `createPartitionedTopicAsync`. 2. If topic name is invalid, the future won't be completed until timeout. See #361, TimeoutException will be thrown in this case. ### Modifications 1. When the topic to create already exists, return a `TopicExistsException`. 2. Add a `tryComplete` method to complete a future of topic creation that may also complete the future of response. 3. Add related tests. ===== * Fix some bugs for create topic request * Fix KStreamAggregationTest * Catch KoPTopicException instead of RuntimeException
BewareMyPower
added a commit
that referenced
this pull request
Jun 29, 2021
Fixes #591 Kafka Connect use `Admin#createTopics` and check the `TopicExistsException` exception for existed topics. See https://github.com/apache/kafka/blob/ef3cd68c852daf21d8e207fa8e21c8770f4041d7/connect/runtime/src/main/java/org/apache/kafka/connect/util/TopicAdmin.java#L394 for details. However, currently `Admin#createTopics` will return an `UnknownServerException` for any failure when create topics. In addition, the handler for CreateTopics request has other problems. 1. The default partition number (-1) is not handled, which may throw exception from `createPartitionedTopicAsync`. 2. If topic name is invalid, the future won't be completed until timeout. See #361, TimeoutException will be thrown in this case. 1. When the topic to create already exists, return a `TopicExistsException`. 2. Add a `tryComplete` method to complete a future of topic creation that may also complete the future of response. 3. Add related tests. ===== * Fix some bugs for create topic request * Fix KStreamAggregationTest * Catch KoPTopicException instead of RuntimeException
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
testCreateInvalidTopicssometimes failed in CI environment, likeHowever here we only use
assertTrueto check the cause type of theExecutionExceptionbut not printed it. So this PR adds error logs for debugging.Normally it should returns a
TimeoutException. However, theKafkaAdmincould also generate anUnknownServerExceptionsometimes, whose error message is just what the server's response is. Here's a sample output of a CI failure:The exception message is from
KopTopic#expandToFullNamethat is thrown inAdminManager#createTopicsAsync.So this PR looses the check of exception type to make the test pass.