lhotari commented on PR #24939:
URL: https://github.com/apache/pulsar/pull/24939#issuecomment-3488067622

   @coderzc Cherry-picking this test to branch-4.0 and branch-4.1 causes the 
test to fail. I had to do some modifications to make it pass.
   
   ```java
       @Test
       public void testCreateNamespaceEventsSystemTopicFactoryException() 
throws Exception {
           final String namespace = "system-topic/namespace-6";
   
           admin.namespaces().createNamespace(namespace);
   
           TopicName topicName = TopicName.get("persistent", 
NamespaceName.get(namespace), "topic-1");
   
           SystemTopicBasedTopicPoliciesService service =
               Mockito.spy((SystemTopicBasedTopicPoliciesService) 
pulsar.getTopicPoliciesService());
   
           // inject exception when create NamespaceEventsSystemTopicFactory
           Mockito.doThrow(new RuntimeException("test exception"))
                   .doCallRealMethod() // <--- replacing Mockito.reset
                   .when(service)
               .getNamespaceEventsSystemTopicFactory();
   
           CompletableFuture<Optional<TopicPolicies>> topicPoliciesFuture;
           Optional<TopicPolicies> topicPoliciesOptional;
           try {
               topicPoliciesFuture =
               service.getTopicPoliciesAsync(topicName, 
TopicPoliciesService.GetType.LOCAL_ONLY);
               topicPoliciesOptional = topicPoliciesFuture.join();
               Assert.fail();
           } catch (Exception e) {
               Assert.assertTrue(e.getCause().getMessage().contains("test 
exception"));
           }
   
           // HERE: using Awaitility to retry
           Awaitility.await().untilAsserted(() -> {
               assertThat(service.updateTopicPoliciesAsync(topicName, false, 
false, topicPolicies ->
                       topicPolicies.setMaxConsumerPerTopic(10)))
                       .succeedsWithin(Duration.ofSeconds(2));
           });
   
           topicPoliciesFuture =
               service.getTopicPoliciesAsync(topicName, 
TopicPoliciesService.GetType.LOCAL_ONLY);
           topicPoliciesOptional = topicPoliciesFuture.join();
   
           Assert.assertNotNull(topicPoliciesOptional);
           Assert.assertTrue(topicPoliciesOptional.isPresent());
   
           TopicPolicies topicPolicies = topicPoliciesOptional.get();
           Assert.assertNotNull(topicPolicies);
           Assert.assertEquals(topicPolicies.getMaxConsumerPerTopic(), 10);
       }
   ```
   
   Is there some other change that would be required for branch-4.0 and 
branch-4.1 that causes this difference in behavior?


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