congbobo184 commented on a change in pull request #11494:
URL: https://github.com/apache/pulsar/pull/11494#discussion_r682564360
##########
File path:
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java
##########
@@ -167,4 +175,29 @@ public void testGetTxnID() throws Exception {
Assert.assertEquals(txnID.getLeastSigBits(), 1);
Assert.assertEquals(txnID.getMostSigBits(), 0);
}
+
+ @Test
+ public void testSubscriptionRecreateTopic()
+ throws PulsarAdminException, NoSuchFieldException,
IllegalAccessException, PulsarClientException {
+ String topic = "persistent://pulsar/system/testReCreateTopic";
+ admin.topics().createNonPartitionedTopic(topic);
+ PulsarService pulsarService = super.getPulsarServiceList().get(0);
+ ManagedLedgerFactory managedLedgerFactory =
pulsarService.getBrokerService().getManagedLedgerFactory();
+ pulsarService.getBrokerService().getTopics().clear();
+ Field field = ManagedLedgerFactoryImpl.class.getDeclaredField("ledgers");
+ field.setAccessible(true);
+ ConcurrentHashMap<String, CompletableFuture<ManagedLedgerImpl>> ledgers =
+ (ConcurrentHashMap<String,
CompletableFuture<ManagedLedgerImpl>>)field.get(managedLedgerFactory);
+ ledgers.remove(TopicName.get(topic).getPersistenceNamingEncoding());
+ admin.topics().unload(topic);
Review comment:
dont need unload.
##########
File path:
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java
##########
@@ -167,4 +175,29 @@ public void testGetTxnID() throws Exception {
Assert.assertEquals(txnID.getLeastSigBits(), 1);
Assert.assertEquals(txnID.getMostSigBits(), 0);
}
+
+ @Test
+ public void testSubscriptionRecreateTopic()
+ throws PulsarAdminException, NoSuchFieldException,
IllegalAccessException, PulsarClientException {
+ String topic = "persistent://pulsar/system/testReCreateTopic";
+ admin.topics().createNonPartitionedTopic(topic);
+ PulsarService pulsarService = super.getPulsarServiceList().get(0);
+ ManagedLedgerFactory managedLedgerFactory =
pulsarService.getBrokerService().getManagedLedgerFactory();
+ pulsarService.getBrokerService().getTopics().clear();
+ Field field = ManagedLedgerFactoryImpl.class.getDeclaredField("ledgers");
+ field.setAccessible(true);
+ ConcurrentHashMap<String, CompletableFuture<ManagedLedgerImpl>> ledgers =
+ (ConcurrentHashMap<String,
CompletableFuture<ManagedLedgerImpl>>)field.get(managedLedgerFactory);
+ ledgers.remove(TopicName.get(topic).getPersistenceNamingEncoding());
+ admin.topics().unload(topic);
+ try {
+ admin.topics().createNonPartitionedTopic(topic);
+ Assert.fail();
+ } catch (PulsarAdminException.ConflictException e){
+ log.info("Cann`t create topic again");
Review comment:
should Assert this exception
--
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]