cadonna commented on code in PR #12524:
URL: https://github.com/apache/kafka/pull/12524#discussion_r976321806


##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/ProcessorStateManagerTest.java:
##########
@@ -360,14 +333,8 @@ public void shouldRecycleStoreAndReregisterChangelog() {
         
assertFalse(changelogReader.isPartitionRegistered(persistentStorePartition));
         assertThat(stateMgr.getStore(persistentStoreName), equalTo(store));
 
-        reset(context, store);
-        context.uninitialize();

Review Comment:
   The pre-migration code verfies that `context.uninitialize()` is called 
during the second `stateMgr.registerStateStores(singletonList(store), 
context);`. That means `verify(context).uninitialize();`  should be after the 
second `stateMgr.registerStateStores(singletonList(store), context);`. There 
you need to use `verify(context, times(2)).uninitialize()` since the test fails 
otherwise. The test should look like this:
   
   ```
       public void shouldRecycleStoreAndReregisterChangelog() {
           final ProcessorStateManager stateMgr = 
getStateManager(Task.TaskType.ACTIVE);
           final StateStore store = mock(StateStore.class);
           when(store.name()).thenReturn(persistentStoreName);
           stateMgr.registerStateStores(singletonList(store), context);
   
           verify(context).uninitialize();
           verify(store).init((StateStoreContext) context, store);
   
           stateMgr.registerStore(store, noopStateRestoreCallback, null);
           
assertTrue(changelogReader.isPartitionRegistered(persistentStorePartition));
   
           stateMgr.recycle();
           
assertFalse(changelogReader.isPartitionRegistered(persistentStorePartition));
           assertThat(stateMgr.getStore(persistentStoreName), equalTo(store));
   
           stateMgr.registerStateStores(singletonList(store), context);
   
           verify(context, times(2)).uninitialize();
           
assertTrue(changelogReader.isPartitionRegistered(persistentStorePartition));
       }
   ```



-- 
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]

Reply via email to