23
23
import java .util .UUID ;
24
24
import java .util .concurrent .TimeUnit ;
25
25
import lombok .Cleanup ;
26
+ import org .apache .pulsar .client .admin .PulsarAdmin ;
26
27
import org .apache .pulsar .client .api .Producer ;
27
28
import org .apache .pulsar .client .api .PulsarClient ;
29
+ import org .apache .pulsar .common .naming .TopicName ;
28
30
import org .apache .pulsar .common .policies .data .TenantInfoImpl ;
29
31
import org .awaitility .Awaitility ;
30
32
import org .testng .Assert ;
@@ -88,6 +90,7 @@ public void testRemoveClusterFromNamespace() throws Exception {
88
90
.build ();
89
91
90
92
final String topicName = "persistent://pulsar1/ns1/testRemoveClusterFromNamespace-" + UUID .randomUUID ();
93
+ admin1 .topics ().createPartitionedTopic (topicName , 1 );
91
94
92
95
Producer <byte []> producer = client .newProducer ()
93
96
.topic (topicName )
@@ -98,9 +101,12 @@ public void testRemoveClusterFromNamespace() throws Exception {
98
101
producer .close ();
99
102
client .close ();
100
103
101
- Replicator replicator = pulsar1 .getBrokerService ().getTopicReference (topicName )
104
+ Replicator replicator = pulsar1 .getBrokerService ()
105
+ .getTopicReference (TopicName .get (topicName ).getPartition (0 ).toString ())
102
106
.get ().getReplicators ().get ("r3" );
103
107
108
+ PulsarAdmin replicatorAdmin = pulsar1 .getBrokerService ().getClusterAdmins ().get ("r3" );
109
+
104
110
Awaitility .await ().untilAsserted (() -> Assert .assertTrue (replicator .isConnected ()));
105
111
106
112
admin1 .clusters ().deleteCluster ("r3" );
@@ -110,5 +116,13 @@ public void testRemoveClusterFromNamespace() throws Exception {
110
116
111
117
Awaitility .await ().untilAsserted (() -> Assert .assertNull (
112
118
pulsar1 .getBrokerService ().getReplicationClients ().get ("r3" )));
119
+ Awaitility .await ().untilAsserted (() -> Assert .assertNull (
120
+ pulsar1 .getBrokerService ().getClusterAdmins ().get ("r3" )));
121
+ try {
122
+ replicatorAdmin .clusters ().getClusters ();
123
+ Assert .fail ("Should get an error that pulsarAdmin has been closed" );
124
+ } catch (Exception e ) {
125
+ Assert .assertTrue (e .getMessage ().contains ("has been closed" ));
126
+ }
113
127
}
114
128
}
0 commit comments