Skip to content
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
BewareMyPower:bewaremypower/add-error-logs
Feb 1, 2021
Merged

Fix flaky testCreateInvalidTopics#361
jiazhai merged 2 commits intostreamnative:masterfrom
BewareMyPower:bewaremypower/add-error-logs

Conversation

@BewareMyPower
Copy link
Copy Markdown
Collaborator

@BewareMyPower BewareMyPower commented Jan 27, 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 // or

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.

@BewareMyPower BewareMyPower self-assigned this Jan 27, 2021
@BewareMyPower BewareMyPower added the type/cleanup Indicates tech-debt or other work which may not be user facing label Jan 27, 2021
@BewareMyPower BewareMyPower changed the title Add error logs for flaky testCreateInvalidTopics Fix flaky testCreateInvalidTopics Jan 27, 2021
@BewareMyPower BewareMyPower added type/bug and removed type/cleanup Indicates tech-debt or other work which may not be user facing labels Jan 28, 2021
@jiazhai jiazhai merged commit 7250531 into streamnative:master 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.
@BewareMyPower BewareMyPower deleted the bewaremypower/add-error-logs branch March 10, 2021 09:10
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants