Skip to content

MINOR: Catch NoRecordsException in testCommaSeparatedRegex() test#5944

Merged
ijuma merged 2 commits intoapache:trunkfrom
stanislavkozlovski:mirror-maker-testCommaSeparatedRegex-test
Dec 8, 2018
Merged

MINOR: Catch NoRecordsException in testCommaSeparatedRegex() test#5944
ijuma merged 2 commits intoapache:trunkfrom
stanislavkozlovski:mirror-maker-testCommaSeparatedRegex-test

Conversation

@stanislavkozlovski
Copy link
Copy Markdown
Contributor

This test sometimes fails with

kafka.tools.MirrorMaker$NoRecordsException
	at kafka.tools.MirrorMaker$ConsumerWrapper.receive(MirrorMaker.scala:483)
	at kafka.tools.MirrorMakerIntegrationTest$$anonfun$testCommaSeparatedRegex$1.apply$mcZ$sp(MirrorMakerIntegrationTest.scala:92)
	at kafka.utils.TestUtils$.waitUntilTrue(TestUtils.scala:738)

It is a bit puzzling as to why this happens in the first place, as the producer call is synchronous and the consumer uses auto.offset.reset=earliest, so it should always return records. But the test originally caught TimeoutException with the comment // this exception is thrown if no record is returned within a short timeout, so safe to ignore, so I think that it is consistent to catch the other error when no records are returned such that we can retry until the test timeout is hit

Now we properly wait until the timeout of TestUtils.waitUntilTrue passes until failing the test.

Now we properly wait until the timeout of `TestUtils.waitUntilTrue` passes until failing the test.
Previously, Producer message sends and topic creations might some times take longer than the first 1s consumer poll
// this exception is thrown if no record is returned within a short timeout, so safe to ignore
case _: TimeoutException => false
// these exceptions are thrown if no records are returned within the 1s timeout, so safe to ignore
case _: TimeoutException | _: NoRecordsException => false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is TimeoutException ever thrown?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we should not hardcode the timeout here as it will go stale if we change the MirrorMaker code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it is not thrown. Nice catch, I hadn't looked into it. TimeoutException is thrown on CommitSync and on ConsoleConsumer#receive(), but not on MirrorMakerConsumer#receive. Must be a left over

Copy link
Copy Markdown
Member

@ijuma ijuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ijuma ijuma merged commit edfa681 into apache:trunk Dec 8, 2018
pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
…ache#5944)

This test sometimes fails with

```
kafka.tools.MirrorMaker$NoRecordsException
	at kafka.tools.MirrorMaker$ConsumerWrapper.receive(MirrorMaker.scala:483)
	at kafka.tools.MirrorMakerIntegrationTest$$anonfun$testCommaSeparatedRegex$1.apply$mcZ$sp(MirrorMakerIntegrationTest.scala:92)
	at kafka.utils.TestUtils$.waitUntilTrue(TestUtils.scala:738)
```

The test should catch `NoRecordsException` instead of `TimeoutException`.

Reviewers: Ismael Juma <ismael@juma.me.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants