leizhiyuan opened a new issue, #17087:
URL: https://github.com/apache/pulsar/issues/17087

   ### Search before asking
   
   - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) 
and found nothing similar.
   
   
   ### Version
   
   master branch
   
   ### Minimal reproduce step
   
   just add a test case 
   org.apache.pulsar.broker.namespace.NamespaceServiceTest
   
   testModularLoadManagerRemoveBundleAndLoad
   
   ```
    @Test
       public void testModularLoadManagerRemoveBundleAndLoad() throws Exception 
{
           final String BUNDLE_DATA_PATH = "/loadbalance/bundle-data";
           final String namespace = "prop/ns-abc";
           final String topic1 = "persistent://" + namespace + "/topic1";
           final String topic2 = "persistent://" + namespace + "/topic2";
   
           // configure broker with ModularLoadManager
           conf.setLoadManagerClassName(ModularLoadManagerImpl.class.getName());
           conf.setForceDeleteNamespaceAllowed(true);
           restartBroker();
   
           LoadManager loadManager = spy(pulsar.getLoadManager().get());
           Field loadManagerField = 
NamespaceService.class.getDeclaredField("loadManager");
           loadManagerField.setAccessible(true);
           doReturn(true).when(loadManager).isCentralized();
           SimpleResourceUnit resourceUnit = new 
SimpleResourceUnit(pulsar.getSafeWebServiceAddress(), null);
        //   Optional<ResourceUnit> res = Optional.of(resourceUnit);
       //    
doReturn(res).when(loadManager).getLeastLoaded(any(ServiceUnitId.class));
           loadManagerField.set(pulsar.getNamespaceService(), new 
AtomicReference<>(loadManager));
   
   
           NamespaceName nsname = NamespaceName.get(namespace);
   
           @Cleanup
           PulsarClient pulsarClient = 
PulsarClient.builder().serviceUrl(pulsar.getBrokerServiceUrl()).build();
           @Cleanup
           Consumer<byte[]> consumer1 = pulsarClient.newConsumer().topic(topic1)
                   .subscriptionName("my-subscriber-name1").subscribe();
           @Cleanup
           Consumer<byte[]> consumer2 = pulsarClient.newConsumer().topic(topic2)
                   .subscriptionName("my-subscriber-name2").subscribe();
   
   
           NamespaceBundle bundle =
                   
pulsar.getNamespaceService().getNamespaceBundleFactory().getBundle(TopicName.get(topic1));
   
           loadManager.getLeastLoaded(bundle);
   
           //create znode for bundle-data
           pulsar.getBrokerService().updateRates();
           loadManager.writeLoadReportOnZookeeper();
           loadManager.writeResourceQuotasToZooKeeper();
   
           String path = BUNDLE_DATA_PATH + "/" + nsname.toString() + 
"/0x00000000_0xffffffff";
   
           Optional<GetResult> getResult = 
pulsar.getLocalMetadataStore().get(path).get();
           assertTrue(getResult.isPresent());
   
   
           //delete namespace which will remove bundle and load
           
pulsar.getAdminClient().namespaces().deleteNamespace(nsname.toString(),true);
   
           TimeUnit.SECONDS.sleep(5);
           getResult = pulsar.getLocalMetadataStore().get(path).get();
           assertFalse(getResult.isPresent());
   
           // update broker bundle report to zk
           loadManager.writeLoadReportOnZookeeper();
           loadManager.writeResourceQuotasToZooKeeper();
   
           getResult = pulsar.getLocalMetadataStore().get(path).get();
           assertTrue(getResult.isPresent());
   
       }
   ```
   
   ### What did you expect to see?
   
   after delete namespace 
   
   ```
      getResult = pulsar.getLocalMetadataStore().get(path).get();
           assertFalse(getResult.isPresent());
   ```
   
   
   ### What did you see instead?
   
   true
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


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