You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/09/10 14:53:29 UTC

[GitHub] [pulsar] tisonkun opened a new pull request, #17579: [improve][test] try remove whitebox on MockZooKeeper

tisonkun opened a new pull request, #17579:
URL: https://github.com/apache/pulsar/pull/17579

   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc-required` 
   (Your PR needs to update docs and you will update later)
   
   - [x] `doc-not-needed` 
   (Please explain why)
   
   - [ ] `doc` 
   (Your PR contains doc changes)
   
   - [ ] `doc-complete`
   (Docs have been already added)
   


-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] tisonkun commented on pull request #17579: [improve][test] try remove whitebox on MockZooKeeper

Posted by GitBox <gi...@apache.org>.
tisonkun commented on PR #17579:
URL: https://github.com/apache/pulsar/pull/17579#issuecomment-1242769003

   /pulsarbot run-faillure-checks


-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] eolivelli commented on a diff in pull request #17579: [improve][test] remove WhiteBox on MockZooKeeper

Posted by GitBox <gi...@apache.org>.
eolivelli commented on code in PR #17579:
URL: https://github.com/apache/pulsar/pull/17579#discussion_r967827030


##########
testmocks/src/main/java/org/apache/zookeeper/MockZooKeeper.java:
##########
@@ -144,10 +144,7 @@ public static MockZooKeeper newInstanceForGlobalZK(ExecutorService executor, int
 
     public static MockZooKeeper newInstance(ExecutorService executor, int readOpDelayMs) {
         try {
-            MockZooKeeper zk = createMockZooKeeperInstance(executor, readOpDelayMs);
-            ObjectInstantiator<ClientCnxn> clientCnxnObjectInstantiator = objenesis.getInstantiatorOf(ClientCnxn.class);
-            Whitebox.setInternalState(zk, "cnxn", clientCnxnObjectInstantiator.newInstance());
-            return zk;
+            return createMockZooKeeperInstance(executor, readOpDelayMs);

Review Comment:
   Maybe the older versions of Mockito or other mock frameworks needed it



-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] tisonkun commented on a diff in pull request #17579: [improve][test] try remove whitebox on MockZooKeeper

Posted by GitBox <gi...@apache.org>.
tisonkun commented on code in PR #17579:
URL: https://github.com/apache/pulsar/pull/17579#discussion_r967667287


##########
testmocks/src/main/java/org/apache/zookeeper/MockZooKeeper.java:
##########
@@ -144,10 +144,7 @@ public static MockZooKeeper newInstanceForGlobalZK(ExecutorService executor, int
 
     public static MockZooKeeper newInstance(ExecutorService executor, int readOpDelayMs) {
         try {
-            MockZooKeeper zk = createMockZooKeeperInstance(executor, readOpDelayMs);
-            ObjectInstantiator<ClientCnxn> clientCnxnObjectInstantiator = objenesis.getInstantiatorOf(ClientCnxn.class);
-            Whitebox.setInternalState(zk, "cnxn", clientCnxnObjectInstantiator.newInstance());
-            return zk;
+            return createMockZooKeeperInstance(executor, readOpDelayMs);

Review Comment:
   @eolivelli this change was added by you in https://github.com/apache/pulsar/pull/8590. I don't know why we need this `WhiteBox` based mock and after removing it and running several tests, it seems all green.
   
   Could you share some background here?



-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] tisonkun commented on pull request #17579: [improve][test] remove WhiteBox on MockZooKeeper

Posted by GitBox <gi...@apache.org>.
tisonkun commented on PR #17579:
URL: https://github.com/apache/pulsar/pull/17579#issuecomment-1242828452

   cc @Shoothzj @nicoloboschi 
   
   It's interesting that no test failed after remove the lines:
   
   ```java
               ObjectInstantiator<ClientCnxn> clientCnxnObjectInstantiator = objenesis.getInstantiatorOf(ClientCnxn.class);
               Whitebox.setInternalState(zk, "cnxn", clientCnxnObjectInstantiator.newInstance());
   ```
   
   I suppose that since the `MockZooKeeper` already mockup the interface, no caller will access `cnxn` field and thus it's unnecessary. However, it would be nice if the original author @eolivelli can give more background :)


-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] eolivelli merged pull request #17579: [improve][test] remove WhiteBox on MockZooKeeper

Posted by GitBox <gi...@apache.org>.
eolivelli merged PR #17579:
URL: https://github.com/apache/pulsar/pull/17579


-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] tisonkun commented on pull request #17579: [improve][test] try remove whitebox on MockZooKeeper

Posted by GitBox <gi...@apache.org>.
tisonkun commented on PR #17579:
URL: https://github.com/apache/pulsar/pull/17579#issuecomment-1242769331

   /pulsarbot run-failure-checks


-- 
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: commits-unsubscribe@pulsar.apache.org

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