lhotari opened a new pull request #9286:
URL: https://github.com/apache/pulsar/pull/9286


   ### Motivation
   
   MessageIdTest class contains 2 of the flaky test cases in the Pulsar code 
base:
   * 
`org.apache.pulsar.client.impl.MessageIdTest.testChecksumVersionComptability` 
and 
   * `org.apache.pulsar.client.impl.MessageIdTest.testChecksumReconnection`
   
   These 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
   - await for termination of executors
   - close the listen channel synchronously
   - use shutdown instead of shutdownNow in AbstractMetadataStore.close
     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
   - 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


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to