clolov commented on code in PR #14716:
URL: https://github.com/apache/kafka/pull/14716#discussion_r1553349919
##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##########
@@ -1652,81 +1598,64 @@ public void shouldReInitializeTopologyWhenResuming()
throws IOException {
assertTrue(source1.initialized);
assertTrue(source2.initialized);
- EasyMock.verify(stateManager, recordCollector);
-
- EasyMock.reset(recordCollector);
- EasyMock.expect(recordCollector.offsets()).andReturn(emptyMap());
- EasyMock.replay(recordCollector);
assertThat("Map did not contain the partition",
task.highWaterMark().containsKey(partition1));
+
+ verify(recordCollector).offsets();
}
@Test
public void
shouldNotCheckpointOffsetsAgainOnCommitIfSnapshotNotChangedMuch() {
final Long offset = 543L;
-
EasyMock.expect(recordCollector.offsets()).andReturn(singletonMap(changelogPartition,
offset)).anyTimes();
- stateManager.checkpoint();
- EasyMock.expectLastCall().once();
- EasyMock.expect(stateManager.changelogOffsets())
- .andReturn(singletonMap(changelogPartition, 10L)) // restoration
checkpoint
- .andReturn(singletonMap(changelogPartition, 10L))
- .andReturn(singletonMap(changelogPartition, 20L));
- EasyMock.expectLastCall();
- EasyMock.replay(stateManager, recordCollector);
+
when(recordCollector.offsets()).thenReturn(singletonMap(changelogPartition,
offset));
+ when(stateManager.changelogOffsets())
+ .thenReturn(singletonMap(changelogPartition, 10L)) // restoration
checkpoint
+ .thenReturn(singletonMap(changelogPartition, 10L))
+ .thenReturn(singletonMap(changelogPartition, 20L));
task = createStatefulTask(createConfig("100"), true);
task.initializeIfNeeded();
- task.completeRestoration(noOpResetter -> { });
+ task.completeRestoration(noOpResetter -> { }); // should checkpoint
task.prepareCommit();
- task.postCommit(true); // should checkpoint
+ task.postCommit(true); // should checkpoint
task.prepareCommit();
- task.postCommit(false); // should not checkpoint
+ task.postCommit(false); // should not checkpoint
- EasyMock.verify(stateManager, recordCollector);
assertThat("Map was empty", task.highWaterMark().size() == 2);
+
+ verify(stateManager, times(2)).checkpoint();
}
@Test
public void shouldCheckpointOffsetsOnCommitIfSnapshotMuchChanged() {
final Long offset = 543L;
-
EasyMock.expect(recordCollector.offsets()).andReturn(singletonMap(changelogPartition,
offset)).anyTimes();
- stateManager.checkpoint();
- EasyMock.expectLastCall().times(2);
-
EasyMock.expect(stateManager.changelogPartitions()).andReturn(singleton(changelogPartition));
- EasyMock.expect(stateManager.changelogOffsets())
- .andReturn(singletonMap(changelogPartition, 0L))
- .andReturn(singletonMap(changelogPartition, 10L))
- .andReturn(singletonMap(changelogPartition, 12000L));
- stateManager.registerStore(stateStore,
stateStore.stateRestoreCallback, null);
- EasyMock.expectLastCall();
- EasyMock.replay(stateManager, recordCollector);
+
when(recordCollector.offsets()).thenReturn(singletonMap(changelogPartition,
offset));
+ when(stateManager.changelogOffsets())
+ .thenReturn(singletonMap(changelogPartition, 0L))
+ .thenReturn(singletonMap(changelogPartition, 10L))
+ .thenReturn(singletonMap(changelogPartition, 12000L));
task = createStatefulTask(createConfig("100"), true);
task.initializeIfNeeded();
- task.completeRestoration(noOpResetter -> { });
+ task.completeRestoration(noOpResetter -> { }); // should checkpoint
task.prepareCommit();
- task.postCommit(true);
+ task.postCommit(true); // should checkpoint
task.prepareCommit();
- task.postCommit(false);
+ task.postCommit(false); // should checkpoint since the offset delta is
greater than the threshold
- EasyMock.verify(recordCollector);
assertThat("Map was empty", task.highWaterMark().size() == 2);
+
+ verify(stateManager, times(3)).checkpoint();
}
@Test
public void shouldNotCheckpointOffsetsOnCommitIfEosIsEnabled() {
-
EasyMock.expect(stateManager.changelogPartitions()).andReturn(singleton(changelogPartition));
- stateManager.registerStore(stateStore,
stateStore.stateRestoreCallback, null);
Review Comment:
According to Mockito neither of these were called
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]