Fix flaky MessageIdTest and introduce some testing improvements - #9286
Merged
Conversation
eolivelli
reviewed
Jan 22, 2021
Contributor
|
@codelipenghui @zymap @sijie @rdhabalia this patch is going to fix the most Flaky test in the suite. please take a look thank you @lhotari for contributing this work |
lhotari
force-pushed
the
lh-fix-flaky-messageidtest
branch
from
January 22, 2021 16:16
44ccd34 to
06f8229
Compare
merlimat
reviewed
Jan 22, 2021
merlimat
left a comment
Contributor
There was a problem hiding this comment.
Very nice work, just a couple of comments on executors
sijie
requested changes
Jan 23, 2021
- it makes it easier to override for tests
- useful for tests. Instead of relying on Mockito, there's a pure Java way to inject behavior to producer implementations for testing purposes
…ons and test flakiness - provides features for simulating failure conditions, for example the case of the broker connection disconnecting
lhotari
force-pushed
the
lh-fix-flaky-messageidtest
branch
from
January 25, 2021 10:13
06f8229 to
59d29f0
Compare
merlimat
approved these changes
Jan 25, 2021
Contributor
|
@lhotari It seems there's a genuine test failure: |
Member
Author
@merlimat Thanks for the heads up. I'll address it tomorrow. |
sijie
approved these changes
Jan 25, 2021
Member
Author
|
/pulsarbot run-failure-checks |
merlimat
pushed a commit
to merlimat/pulsar
that referenced
this pull request
Apr 6, 2021
…he#9286) * Refactor PulsarClient initialization and lifecycle management in tests * Add getter and setter to access remoteEndpointProtocolVersion field - it makes it easier to override for tests * Add hooks for overriding the producer implementation in PulsarClientImpl - useful for tests. Instead of relying on Mockito, there's a pure Java way to inject behavior to producer implementations for testing purposes * Introduce PulsarTestClient that contains ways to prevent race conditions and test flakiness - provides features for simulating failure conditions, for example the case of the broker connection disconnecting * Add solution for using Enums classes as source for TestNG DataProvider * Fix flaky MessageIdTest and move checksum related tests to new class * Fix NPE in PartitionedProducerImplTest
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
MessageIdTest class contains 2 of the flaky test cases in the Pulsar code base:
org.apache.pulsar.client.impl.MessageIdTest.testChecksumVersionComptabilityandorg.apache.pulsar.client.impl.MessageIdTest.testChecksumReconnectionThese test cases don't have much to do with
MessageId, but are tests for validating message checksum handling in cases where there are pre 1.15 version brokers and post 1.15 version brokers in a mixed broker environment. The tests might not be very relevant any more. However it was taken as a learning experiment to fix these tests and refactor them so that the flakiness of the test code would be eliminated. Similar patterns might be needed in other tests to eliminate flakiness.Modifications
The changes aren't only to fix MessageIdTest. Most changes could help reduce flakiness of other tests as well.
Improve shutdown of the broker and related services to reduce test flakiness
so that in-flight tasks get processed
Handle special case where the executor rejects the task and the callback was never called
Improve logging in MockedPulsarServiceBaseTest related to stopping and starting
Refactor PulsarClient initialization and lifecycle management in tests
Add getter and setter to access remoteEndpointProtocolVersion field
Add hooks for overriding the producer implementation in PulsarClientImpl
way to inject behavior to producer implementations for testing purposes
Introduce PulsarTestClient that contains ways to prevent race conditions and test flakiness
the case of the broker connection disconnecting
Add solution for using Enums classes as source for TestNG DataProvider
Fix flaky MessageIdTest and move checksum related tests to new class