-
Notifications
You must be signed in to change notification settings - Fork 14.8k
KAFKA-19683: More test replacements [5/N] #20818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
| @Test | ||
| public void shouldNotCommitIfNoRevokedTasksNeedCommittingWithEOSv2() { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in ff6b3b0
|
@lucasbru, tagging for review :) |
There was a problem hiding this 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
StateMachineTaskwith mockedStreamTask/StandbyTaskusing the builder pattern - Updates test setup to use mocked
TasksRegistryinstead 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.
There was a problem hiding this 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); |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
| @Test | ||
| public void shouldNotCommitIfNoRevokedTasksNeedCommittingWithEOSv2() { |
There was a problem hiding this comment.
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.
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 |
Replaced more tests in
TaskManagerTest.javaReviewers: Lucas Brutschy [email protected]