|
48 | 48 | import static org.testng.Assert.assertNull;
|
49 | 49 | import static org.testng.Assert.assertTrue;
|
50 | 50 | import static org.testng.Assert.fail;
|
51 |
| - |
52 | 51 | import com.google.common.collect.Sets;
|
53 | 52 | import java.util.LinkedHashMap;
|
54 | 53 | import java.util.Set;
|
| 54 | +import java.util.UUID; |
| 55 | +import java.util.concurrent.CompletableFuture; |
55 | 56 | import java.util.concurrent.ExecutionException;
|
56 | 57 | import java.util.concurrent.TimeUnit;
|
57 | 58 | import java.util.concurrent.atomic.AtomicInteger;
|
|
63 | 64 | import java.util.List;
|
64 | 65 | import java.util.Map;
|
65 | 66 | import java.util.Optional;
|
66 |
| -import java.util.concurrent.CompletableFuture; |
67 | 67 | import org.apache.commons.lang3.reflect.FieldUtils;
|
68 | 68 | import org.apache.pulsar.broker.PulsarService;
|
69 | 69 | import org.apache.pulsar.broker.ServiceConfiguration;
|
@@ -927,6 +927,43 @@ public void testDisableBroker() throws Exception {
|
927 | 927 | }
|
928 | 928 | }
|
929 | 929 |
|
| 930 | + @Test(timeOut = 30 * 1000) |
| 931 | + public void testListTopic() throws Exception { |
| 932 | + final String namespace = "public/testListTopic"; |
| 933 | + admin.namespaces().createNamespace(namespace, 3); |
| 934 | + |
| 935 | + final String persistentTopicName = TopicName.get( |
| 936 | + "persistent", NamespaceName.get(namespace), |
| 937 | + "get_topics_mode_" + UUID.randomUUID()).toString(); |
| 938 | + |
| 939 | + final String nonPersistentTopicName = TopicName.get( |
| 940 | + "non-persistent", NamespaceName.get(namespace), |
| 941 | + "get_topics_mode_" + UUID.randomUUID()).toString(); |
| 942 | + admin.topics().createPartitionedTopic(persistentTopicName, 3); |
| 943 | + admin.topics().createPartitionedTopic(nonPersistentTopicName, 3); |
| 944 | + pulsarClient.newProducer().topic(persistentTopicName).create().close(); |
| 945 | + pulsarClient.newProducer().topic(nonPersistentTopicName).create().close(); |
| 946 | + |
| 947 | + BundlesData bundlesData = admin.namespaces().getBundles(namespace); |
| 948 | + List<String> boundaries = bundlesData.getBoundaries(); |
| 949 | + int topicNum = 0; |
| 950 | + for (int i = 0; i < boundaries.size() - 1; i++) { |
| 951 | + String bundle = String.format("%s_%s", boundaries.get(i), boundaries.get(i + 1)); |
| 952 | + List<String> topic = admin.topics().getListInBundle(namespace, bundle); |
| 953 | + if (topic == null) { |
| 954 | + continue; |
| 955 | + } |
| 956 | + topicNum += topic.size(); |
| 957 | + for (String s : topic) { |
| 958 | + assertFalse(TopicName.get(s).isPersistent()); |
| 959 | + } |
| 960 | + } |
| 961 | + assertEquals(topicNum, 3); |
| 962 | + |
| 963 | + List<String> list = admin.topics().getList(namespace); |
| 964 | + assertEquals(list.size(), 6); |
| 965 | + } |
| 966 | + |
930 | 967 | private static abstract class MockBrokerFilter implements BrokerFilter {
|
931 | 968 |
|
932 | 969 | @Override
|
|
0 commit comments