Skip to content

Conversation

@shashankhs11
Copy link
Contributor

@shashankhs11 shashankhs11 commented Nov 4, 2025

Replaced more tests in TaskManagerTest.java

Reviewers: Lucas Brutschy [email protected]

@github-actions github-actions bot added streams tests Test fixes (including flaky tests) triage PRs from the community labels Nov 4, 2025
Comment on lines 3148 to 3149
@Test
public void shouldNotCommitIfNoRevokedTasksNeedCommittingWithEOSv2() {
Copy link
Contributor Author

@shashankhs11 shashankhs11 Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test tests the same behaviour as the above test shouldNotCommitIfNoRevokedTasksNeedCommitting.
I wasn't able to understand/figure out on how the behavior varies through the different processing modes.

Just for my understanding, it would differ only if the revoked tasks needs committing right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. We could consider parametrizing on ProcessingMode here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in ff6b3b0

@shashankhs11
Copy link
Contributor Author

@lucasbru, tagging for review :)

@lucasbru lucasbru self-assigned this Nov 4, 2025
@lucasbru lucasbru requested review from Copilot and lucasbru November 4, 2025 13:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors test methods in TaskManagerTest.java to use mocked StreamTask and StandbyTask objects created via a builder pattern instead of the custom StateMachineTask test helper class. The changes improve test maintainability by using more realistic mocks and explicit verification of task interactions.

  • Replaces StateMachineTask with mocked StreamTask/StandbyTask using the builder pattern
  • Updates test setup to use mocked TasksRegistry instead of relying on task creation and state management
  • Converts verification from state assertions to explicit mock verification calls

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@lucasbru lucasbru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot, but it seems there is a little gap in the state updater code here, since we do not handle timeout exceptions during initializations as before. I wonder if we could fix it in this PR, as it shouldn't be a huge change?

);
assertThat(taskManager.standbyTaskMap(), Matchers.anEmptyMap());
verify(changeLogReader).enforceRestoreActive();
verifyNoInteractions(consumer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove verifyNoInteractions(consumer)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added back in 7d74633

}

@Test
public void shouldNotCompleteRestorationIfTasksCannotInitialize() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait. We should actually also handle TimeoutException in the production code. I suppose you removed TimeoutException because state updater doesn't handle it.

We should fix that, because initializeIfNeeded may throw a timeout exception.

If we get a TimeoutException inside addTasksToStateUpdater, we should

            task.maybeInitTaskTimeoutOrThrow(now, timeoutException);
            tasks.addPendingTasksToInit(Collections.singleton(task));
            updateOrCreateBackoffRecord(task.id(), nowMs);

and otherwise, we should

                task.clearTaskTimeout();

after the initialization.

And then we should bring back this behavior in the test

Copy link
Contributor Author

@shashankhs11 shashankhs11 Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened KAFKA-19864 to track and isolate this change -- #20829

Comment on lines 3148 to 3149
@Test
public void shouldNotCommitIfNoRevokedTasksNeedCommittingWithEOSv2() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. We could consider parametrizing on ProcessingMode here.

@shashankhs11
Copy link
Contributor Author

shashankhs11 commented Nov 5, 2025

@lucasbru

I wonder if we could fix it in this PR, as it shouldn't be a huge change?

I created KAFKA-19864 to track and isolate this change -- #20829 is ready for review.

The thinking behind this was that since the commits are squashed and merged to trunk and this PR also updates few other tests, I thought it would be better if we file isolate this change in case we need to revert for any reason in the future.

@github-actions github-actions bot removed the triage PRs from the community label Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

streams tests Test fixes (including flaky tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants