Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.pulsar.client.api.PulsarClientException;
import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.common.nar.NarClassLoader;
import org.awaitility.Awaitility;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
Expand Down Expand Up @@ -114,7 +115,7 @@ public void testWebserviceRequest() throws PulsarAdminException {
BrokerInterceptor listener = pulsar.getBrokerInterceptor();
Assert.assertTrue(listener instanceof CounterBrokerInterceptor);
admin.namespaces().createNamespace("public/test", 4);
Assert.assertTrue(((CounterBrokerInterceptor)listener).getCount() >= 1);
Awaitility.await().until(() -> ((CounterBrokerInterceptor) listener).getCount() >= 1);
}

@Test
Expand All @@ -123,7 +124,7 @@ public void testPulsarCommand() throws PulsarClientException {
Assert.assertTrue(listener instanceof CounterBrokerInterceptor);
pulsarClient.newProducer(Schema.BOOL).topic("test").create();
// CONNECT and PRODUCER
Assert.assertTrue(((CounterBrokerInterceptor)listener).getCount() >= 2);
Awaitility.await().until(() -> ((CounterBrokerInterceptor) listener).getCount() >= 2);
}

@Test
Expand All @@ -133,7 +134,7 @@ public void testConnectionCreation() throws PulsarClientException {
pulsarClient.newProducer(Schema.BOOL).topic("test").create();
pulsarClient.newConsumer(Schema.STRING).topic("test1").subscriptionName("test-sub").subscribe();
// single connection for both producer and consumer
assertEquals(((CounterBrokerInterceptor) listener).getConnectionCreationCount(), 1);
Awaitility.await().until(() -> ((CounterBrokerInterceptor) listener).getConnectionCreationCount() == 1);
}

@Test
Expand All @@ -142,7 +143,7 @@ public void testProducerCreation() throws PulsarClientException {
Assert.assertTrue(listener instanceof CounterBrokerInterceptor);
assertEquals(((CounterBrokerInterceptor) listener).getProducerCount(), 0);
pulsarClient.newProducer(Schema.BOOL).topic("test").create();
assertEquals(((CounterBrokerInterceptor) listener).getProducerCount(), 1);
Awaitility.await().until(() -> ((CounterBrokerInterceptor) listener).getProducerCount() == 1);
}

@Test
Expand All @@ -151,7 +152,7 @@ public void testConsumerCreation() throws PulsarClientException {
Assert.assertTrue(listener instanceof CounterBrokerInterceptor);
assertEquals(((CounterBrokerInterceptor) listener).getConsumerCount(), 0);
pulsarClient.newConsumer(Schema.STRING).topic("test1").subscriptionName("test-sub").subscribe();
assertEquals(((CounterBrokerInterceptor) listener).getConsumerCount(), 1);
Awaitility.await().until(() -> ((CounterBrokerInterceptor) listener).getConsumerCount() == 1);
}

@Test
Expand All @@ -178,8 +179,8 @@ public void testBeforeSendMessage() throws PulsarClientException {

assertEquals(msg.getValue(), "hello world");

assertEquals(((CounterBrokerInterceptor) listener).getBeforeSendCount(), 1);
assertEquals(((CounterBrokerInterceptor)listener).getMessageDispatchCount(),1);
Awaitility.await().until(() -> ((CounterBrokerInterceptor) listener).getBeforeSendCount() == 1);
Awaitility.await().until(() -> ((CounterBrokerInterceptor) listener).getMessageDispatchCount() == 1);
}

@Test
Expand All @@ -195,8 +196,7 @@ public void testInterceptAck() throws Exception {
Message<String> message = consumer.receive();
consumer.acknowledge(message);
}

Assert.assertEquals(((CounterBrokerInterceptor) interceptor).getHandleAckCount(), 1);
Awaitility.await().until(() -> ((CounterBrokerInterceptor) interceptor).getHandleAckCount() == 1);
}

@Test
Expand Down Expand Up @@ -225,6 +225,7 @@ public void onResponse(Call call, Response response) throws IOException {
}
});
future.get();
Awaitility.await().until(() -> !interceptor.getResponseList().isEmpty());
CounterBrokerInterceptor.ResponseEvent responseEvent = interceptor.getResponseList().get(0);
Assert.assertEquals(responseEvent.getRequestUri(), "/admin/v3/test/asyncGet/my-topic/1000");
Assert.assertEquals(responseEvent.getResponseStatus(),
Expand Down