You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Vinay Agarwal (Jira)" <ji...@apache.org> on 2024/06/06 15:23:00 UTC
[jira] [Assigned] (KAFKA-16862) Refactor ConsumerTaskTest to be deterministic and avoid tight loops
[ https://issues.apache.org/jira/browse/KAFKA-16862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vinay Agarwal reassigned KAFKA-16862:
-------------------------------------
Assignee: Vinay Agarwal
> 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: Vinay Agarwal
> 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)