[ 
https://issues.apache.org/jira/browse/KAFKA-16862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17854452#comment-17854452
 ] 

Wang Xiaoqing commented on KAFKA-16862:
---------------------------------------

Hi, I have implemented the changes in PR #16303 "KAFKA-16862: Refactor 
ConsumerTaskTest to be deterministic and avoid tight loops".

> Refactor ConsumerTaskTest to be deterministic and avoid tight loops
> -------------------------------------------------------------------
>
>                 Key: KAFKA-16862
>                 URL: https://issues.apache.org/jira/browse/KAFKA-16862
>             Project: Kafka
>          Issue Type: Task
>          Components: Tiered-Storage
>    Affects Versions: 3.8.0
>            Reporter: Greg Harris
>            Assignee: Wang Xiaoqing
>            Priority: Minor
>              Labels: newbie
>
> The ConsumerTaskTest instantiates a MockConsumer, and uses this MockConsumer 
> instance in the ConsumerTask, which is run in a background thread.
> * This causes the background thread to tight loop on MockConsumer#poll, which 
> has no sleep or other delay mechanism. This wastes CPU cycles and makes it 
> impossible to use MockConsumer#schedulePollTask to meaningfully mock out the 
> poll behavior.
> * The test thread then needs to use TestUtils.waitForCondition, which 
> repeatedly polls a result until it is satisfactory, wasting CPU cycles and 
> introducing opportunities for timeout errors. (The test is not currently 
> flaky in CI, so this is less of a concern).
> Instead, the ConsumerTaskTest can be rewritten to not utilize a background 
> thread, and make all calls to the MockConsumer on the same thread. This is 
> the model that the DistributedHerderTest uses with DistributedHerder#tick, 
> and WorkerSinkTaskTest uses with WorkerSinkTask#iteration. 
> AbstractWorkerSourceTaskTest uses a similar model with multiple methods, the 
> most notable being AbstractWorkerSourceTask#sendRecords.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to