Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix timing issue in ConsumerSpec test by adding delay in consumer str…
…eam (#1388) This PR addresses a timing issue in the ConsumerSpec test: `“it’s possible to start a new consumption session from a Consumer that had a consumption session stopped previously”` # Issue: When running the entire test suite, this test occasionally fails with the following assertion error: ``` Assertion failed: ✗ 100000 was not less than 100000 consumed0 did not satisfy isGreaterThan(0L) && isLessThan(numberOfMessages.toLong) consumed0 = 100000 ``` # Cause: - The failure occurs because the first consumer sometimes consumes all messages before consumer.stopConsumption is called. - This happens due to timing variations when the test suite is run in full, possibly because of system performance or resource contention. - As a result, consumed0 equals numberOfMessages, causing the assertion consumed0 < numberOfMessages.toLong to fail. # Solution: - Introduce a slight delay in the consumer stream to prevent it from consuming all messages too quickly. - This ensures that consumer.stopConsumption is called before all messages are consumed. - The test can now reliably check that the consumer can be stopped and restarted. # Testing: - Ran the full test suite multiple times to confirm that the issue is resolved. - Verified that consumed0 is greater than 0 and less than numberOfMessages, satisfying the original assertions.
- Loading branch information