You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/10/21 05:54:55 UTC

[GitHub] [kafka] shekhar-rajak opened a new pull request, #12777: Replace EasyMock and PowerMock with Mockito - TimeOrderedWindowStoreTest

shekhar-rajak opened a new pull request, #12777:
URL: https://github.com/apache/kafka/pull/12777

   Related to KAFKA-14059 and KAFKA-14132
   
   This is similar to the Open PR: https://github.com/apache/kafka/pull/12739
   
   ### Committer Checklist (excluded from commit message)
   - [x] Verify design and implementation 
   - [x] Verify test coverage and CI build status
   - [x] Verify documentation (including upgrade notes)
   


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] divijvaidya commented on a diff in pull request #12777: Replace EasyMock and PowerMock with Mockito - TimeOrderedWindowStoreTest

Posted by GitBox <gi...@apache.org>.
divijvaidya commented on code in PR #12777:
URL: https://github.com/apache/kafka/pull/12777#discussion_r1002953413


##########
streams/src/test/java/org/apache/kafka/streams/state/internals/TimeOrderedWindowStoreTest.java:
##########
@@ -1166,58 +1164,47 @@ public void shouldNotThrowInvalidBackwardRangeExceptionWithNegativeFromKey() {
     @Test
     public void shouldCloseCacheAndWrappedStoreAfterErrorDuringCacheFlush() {
         setUpCloseTests();
-        EasyMock.reset(cache);
-        cache.flush(CACHE_NAMESPACE);
-        EasyMock.expectLastCall().andThrow(new RuntimeException("Simulating an error on flush"));
-        cache.close(CACHE_NAMESPACE);
-        EasyMock.replay(cache);
-        EasyMock.reset(underlyingStore);
-        underlyingStore.close();
-        EasyMock.replay(underlyingStore);
+        reset(cache);
+        doThrow(new RuntimeException(
+                "Simulating an error on flush"))
+                .when(cache).flush(CACHE_NAMESPACE);
+        reset(underlyingStore);
 
         assertThrows(RuntimeException.class, cachingStore::close);
-        EasyMock.verify(cache, underlyingStore);
+        verifyAndTearDownCloseTests();
     }
 
     @Test
     public void shouldCloseWrappedStoreAfterErrorDuringCacheClose() {
         setUpCloseTests();
-        EasyMock.reset(cache);
-        cache.flush(CACHE_NAMESPACE);
-        cache.close(CACHE_NAMESPACE);
-        EasyMock.expectLastCall().andThrow(new RuntimeException("Simulating an error on close"));
-        EasyMock.replay(cache);
-        EasyMock.reset(underlyingStore);
-        underlyingStore.close();
-        EasyMock.replay(underlyingStore);
+        reset(cache);
+        doThrow(new RuntimeException("Simulating an error on close"))
+                .when(cache).close(CACHE_NAMESPACE);
 
+        reset(underlyingStore);
         assertThrows(RuntimeException.class, cachingStore::close);
-        EasyMock.verify(cache, underlyingStore);
+        verifyAndTearDownCloseTests();
     }
 
     @Test
     public void shouldCloseCacheAfterErrorDuringStateStoreClose() {
         setUpCloseTests();
-        EasyMock.reset(cache);
-        cache.flush(CACHE_NAMESPACE);
-        cache.close(CACHE_NAMESPACE);
-        EasyMock.replay(cache);
-        EasyMock.reset(underlyingStore);
-        underlyingStore.close();
-        EasyMock.expectLastCall().andThrow(new RuntimeException("Simulating an error on close"));
-        EasyMock.replay(underlyingStore);
+        reset(cache);

Review Comment:
   I don't think we require `reset` here because `cache` member is being reset already in `setUpCloseTests` just in the previous line. Same for `underlying` store and other tests.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] divijvaidya commented on a diff in pull request #12777: Replace EasyMock and PowerMock with Mockito - TimeOrderedWindowStoreTest

Posted by GitBox <gi...@apache.org>.
divijvaidya commented on code in PR #12777:
URL: https://github.com/apache/kafka/pull/12777#discussion_r1006648492


##########
streams/src/test/java/org/apache/kafka/streams/state/internals/TimeOrderedWindowStoreTest.java:
##########
@@ -1166,58 +1164,43 @@ public void shouldNotThrowInvalidBackwardRangeExceptionWithNegativeFromKey() {
     @Test
     public void shouldCloseCacheAndWrappedStoreAfterErrorDuringCacheFlush() {
         setUpCloseTests();
-        EasyMock.reset(cache);
-        cache.flush(CACHE_NAMESPACE);
-        EasyMock.expectLastCall().andThrow(new RuntimeException("Simulating an error on flush"));
-        cache.close(CACHE_NAMESPACE);
-        EasyMock.replay(cache);
-        EasyMock.reset(underlyingStore);
-        underlyingStore.close();
-        EasyMock.replay(underlyingStore);
+        doThrow(new RuntimeException(
+                "Simulating an error on flush"))
+                .when(cache).flush(CACHE_NAMESPACE);
+        reset(underlyingStore);
 
         assertThrows(RuntimeException.class, cachingStore::close);
-        EasyMock.verify(cache, underlyingStore);
+        verifyAndTearDownCloseTests();
     }
 
     @Test
     public void shouldCloseWrappedStoreAfterErrorDuringCacheClose() {
         setUpCloseTests();
-        EasyMock.reset(cache);
-        cache.flush(CACHE_NAMESPACE);
-        cache.close(CACHE_NAMESPACE);
-        EasyMock.expectLastCall().andThrow(new RuntimeException("Simulating an error on close"));
-        EasyMock.replay(cache);
-        EasyMock.reset(underlyingStore);
-        underlyingStore.close();
-        EasyMock.replay(underlyingStore);
+        doThrow(new RuntimeException("Simulating an error on close"))
+                .when(cache).close(CACHE_NAMESPACE);
 
+        reset(underlyingStore);

Review Comment:
   do we need this?



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] clolov commented on pull request #12777: Replace EasyMock and PowerMock with Mockito - TimeOrderedWindowStoreTest

Posted by GitBox <gi...@apache.org>.
clolov commented on PR #12777:
URL: https://github.com/apache/kafka/pull/12777#issuecomment-1323475825

   Hello @bbejeck! I have seen you collaborate with Divij Vaidya on a few pull requests and I was hoping you would lend us a hand in reviewing this pull request to get https://issues.apache.org/jira/browse/KAFKA-14133 over the line 😊


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] clolov commented on pull request #12777: Replace EasyMock and PowerMock with Mockito - TimeOrderedWindowStoreTest

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on PR #12777:
URL: https://github.com/apache/kafka/pull/12777#issuecomment-1413738931

   @cadonna is it possible get a review here as well? @shekhar-rajak, if there are any comments is it possible for you to address them. I will circle back in a week's time and if there are still outstanding comments I will takeover this pull request to get it to completion.


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] shekhar-rajak commented on pull request #12777: Replace EasyMock and PowerMock with Mockito - TimeOrderedWindowStoreTest

Posted by "shekhar-rajak (via GitHub)" <gi...@apache.org>.
shekhar-rajak commented on PR #12777:
URL: https://github.com/apache/kafka/pull/12777#issuecomment-1414050155

   Hi,
   
   This PR already have one approval and ready to merge. 
   
   


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] shekhar-rajak commented on pull request #12777: Replace EasyMock and PowerMock with Mockito - TimeOrderedWindowStoreTest

Posted by GitBox <gi...@apache.org>.
shekhar-rajak commented on PR #12777:
URL: https://github.com/apache/kafka/pull/12777#issuecomment-1293213497

   @divijvaidya  Please have a look now. 


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] shekhar-rajak commented on a diff in pull request #12777: Replace EasyMock and PowerMock with Mockito - TimeOrderedWindowStoreTest

Posted by GitBox <gi...@apache.org>.
shekhar-rajak commented on code in PR #12777:
URL: https://github.com/apache/kafka/pull/12777#discussion_r1004126495


##########
streams/src/test/java/org/apache/kafka/streams/state/internals/TimeOrderedWindowStoreTest.java:
##########
@@ -1166,58 +1164,47 @@ public void shouldNotThrowInvalidBackwardRangeExceptionWithNegativeFromKey() {
     @Test
     public void shouldCloseCacheAndWrappedStoreAfterErrorDuringCacheFlush() {
         setUpCloseTests();
-        EasyMock.reset(cache);
-        cache.flush(CACHE_NAMESPACE);
-        EasyMock.expectLastCall().andThrow(new RuntimeException("Simulating an error on flush"));
-        cache.close(CACHE_NAMESPACE);
-        EasyMock.replay(cache);
-        EasyMock.reset(underlyingStore);
-        underlyingStore.close();
-        EasyMock.replay(underlyingStore);
+        reset(cache);
+        doThrow(new RuntimeException(
+                "Simulating an error on flush"))
+                .when(cache).flush(CACHE_NAMESPACE);
+        reset(underlyingStore);
 
         assertThrows(RuntimeException.class, cachingStore::close);
-        EasyMock.verify(cache, underlyingStore);
+        verifyAndTearDownCloseTests();
     }
 
     @Test
     public void shouldCloseWrappedStoreAfterErrorDuringCacheClose() {
         setUpCloseTests();
-        EasyMock.reset(cache);
-        cache.flush(CACHE_NAMESPACE);
-        cache.close(CACHE_NAMESPACE);
-        EasyMock.expectLastCall().andThrow(new RuntimeException("Simulating an error on close"));
-        EasyMock.replay(cache);
-        EasyMock.reset(underlyingStore);
-        underlyingStore.close();
-        EasyMock.replay(underlyingStore);
+        reset(cache);
+        doThrow(new RuntimeException("Simulating an error on close"))
+                .when(cache).close(CACHE_NAMESPACE);
 
+        reset(underlyingStore);
         assertThrows(RuntimeException.class, cachingStore::close);
-        EasyMock.verify(cache, underlyingStore);
+        verifyAndTearDownCloseTests();
     }
 
     @Test
     public void shouldCloseCacheAfterErrorDuringStateStoreClose() {
         setUpCloseTests();
-        EasyMock.reset(cache);
-        cache.flush(CACHE_NAMESPACE);
-        cache.close(CACHE_NAMESPACE);
-        EasyMock.replay(cache);
-        EasyMock.reset(underlyingStore);
-        underlyingStore.close();
-        EasyMock.expectLastCall().andThrow(new RuntimeException("Simulating an error on close"));
-        EasyMock.replay(underlyingStore);
+        reset(cache);

Review Comment:
   I think you are saying it is getting reset with the previous test case last line `verifyAndTearDownCloseTests();` . I have removed these `reset`. Thanks!



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] guozhangwang merged pull request #12777: Replace EasyMock and PowerMock with Mockito - TimeOrderedWindowStoreTest

Posted by "guozhangwang (via GitHub)" <gi...@apache.org>.
guozhangwang merged PR #12777:
URL: https://github.com/apache/kafka/pull/12777


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] clolov commented on pull request #12777: Replace EasyMock and PowerMock with Mockito - TimeOrderedWindowStoreTest

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on PR #12777:
URL: https://github.com/apache/kafka/pull/12777#issuecomment-1416159492

   Great, thank you very much @guozhangwang!


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org