jiazhai opened a new issue #9207:
URL: https://github.com/apache/pulsar/issues/9207


   @aloyszhang help fixed issue by PR #9193, which caused by mis-use localZk 
and globalZk. 
   It would be a great help if we could use 2 mocked zk in the 
MockedPulsarServiceBaseTest, one zk for localZk() and another for globalZk. So 
it could help protect this kind of error happens again.
   
   e.g. in NamespacesTest.java the globalZk and localZk is the same zk:
   ```
       @Override
       @BeforeMethod
       public void setup() throws Exception {
           super.internalSetup();
   
           namespaces = spy(new Namespaces());
           namespaces.setServletContext(new MockServletContext());
           namespaces.setPulsar(pulsar);
           doReturn(mockZooKeeper).when(namespaces).globalZk();   < ===
           doReturn(mockZooKeeper).when(namespaces).localZk();     < ===
   ...
   ```
   
   If we create 2 MockZooKeeper, then in the place where `mockZooKeeper` is 
returned, we could choose between global and local as needed.
   ```
           doReturn(mockGlobalZooKeeper).when(xxx).globalZk();
           doReturn(mockLocalZooKeeper).when(xxx).localZk();
   ```
   


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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to