You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/10/08 19:24:06 UTC

[GitHub] sijie closed pull request #2746: [clients][kafka] Fix topic name & race condition on kafka wrapper

sijie closed pull request #2746:  [clients][kafka] Fix topic name & race condition on kafka wrapper
URL: https://github.com/apache/pulsar/pull/2746
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/buildtools/src/main/resources/log4j2.xml b/buildtools/src/main/resources/log4j2.xml
index 85a7c1e59c..a658b55b32 100644
--- a/buildtools/src/main/resources/log4j2.xml
+++ b/buildtools/src/main/resources/log4j2.xml
@@ -31,5 +31,6 @@
         </Root>
         <Logger name="org.apache.pulsar" level="info"/>
         <Logger name="org.apache.bookkeeper" level="info"/>
+        <Logger name="org.apache.kafka" level="info"/>
     </Loggers>
 </Configuration>
diff --git a/pulsar-client-kafka-compat/pulsar-client-kafka/src/main/java/org/apache/kafka/clients/consumer/PulsarKafkaConsumer.java b/pulsar-client-kafka-compat/pulsar-client-kafka/src/main/java/org/apache/kafka/clients/consumer/PulsarKafkaConsumer.java
index 0ce91c2b6b..cf1e716b76 100644
--- a/pulsar-client-kafka-compat/pulsar-client-kafka/src/main/java/org/apache/kafka/clients/consumer/PulsarKafkaConsumer.java
+++ b/pulsar-client-kafka-compat/pulsar-client-kafka/src/main/java/org/apache/kafka/clients/consumer/PulsarKafkaConsumer.java
@@ -37,6 +37,7 @@
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
+import lombok.extern.slf4j.Slf4j;
 import org.apache.kafka.clients.producer.ProducerConfig;
 import org.apache.kafka.common.Metric;
 import org.apache.kafka.common.MetricName;
@@ -62,6 +63,7 @@
 import org.apache.pulsar.common.naming.TopicName;
 import org.apache.pulsar.common.util.FutureUtil;
 
+@Slf4j
 public class PulsarKafkaConsumer<K, V> implements Consumer<K, V>, MessageListener<byte[]> {
 
     private static final long serialVersionUID = 1L;
@@ -216,18 +218,28 @@ public void subscribe(Collection<String> topics, ConsumerRebalanceListener callb
                         CompletableFuture<org.apache.pulsar.client.api.Consumer<byte[]>> future = consumerBuilder.clone()
                                 .topic(partitionName).subscribeAsync();
                         int partitionIndex = i;
-                        TopicPartition tp = new TopicPartition(topic, partitionIndex);
-                        future.thenAccept(consumer -> consumers.putIfAbsent(tp, consumer));
-                        futures.add(future);
+                        TopicPartition tp = new TopicPartition(
+                            TopicName.get(topic).getPartitionedTopicName(),
+                            partitionIndex);
+                        futures.add(future.thenApply(consumer -> {
+                            log.info("Add consumer {} for partition {}", consumer, tp);
+                            consumers.putIfAbsent(tp, consumer);
+                            return consumer;
+                        }));
                         topicPartitions.add(tp);
                     }
                 } else {
                     // Topic has a single partition
                     CompletableFuture<org.apache.pulsar.client.api.Consumer<byte[]>> future = consumerBuilder.topic(topic)
                             .subscribeAsync();
-                    TopicPartition tp = new TopicPartition(topic, 0);
-                    future.thenAccept(consumer -> consumers.putIfAbsent(tp, consumer));
-                    futures.add(future);
+                    TopicPartition tp = new TopicPartition(
+                        TopicName.get(topic).getPartitionedTopicName(),
+                        0);
+                    futures.add(future.thenApply(consumer -> {
+                        log.info("Add consumer {} for partition {}", consumer, tp);
+                        consumers.putIfAbsent(tp, consumer);
+                        return consumer;
+                    }));
                     topicPartitions.add(tp);
                 }
             }
@@ -290,7 +302,7 @@ public void unsubscribe() {
 
             int numberOfRecords = 0;
 
-            while (item != null && ++numberOfRecords < MAX_RECORDS_IN_SINGLE_POLL) {
+            while (item != null) {
                 TopicName topicName = TopicName.get(item.consumer.getTopic());
                 String topic = topicName.getPartitionedTopicName();
                 int partition = topicName.isPartitioned() ? topicName.getPartitionIndex() : 0;
@@ -320,11 +332,15 @@ public void unsubscribe() {
                 // Update last offset seen by application
                 lastReceivedOffset.put(tp, offset);
 
+                if (++numberOfRecords < MAX_RECORDS_IN_SINGLE_POLL) {
+                    break;
+                }
+
                 // Check if we have an item already available
                 item = receivedMessages.poll(0, TimeUnit.MILLISECONDS);
             }
 
-            if (isAutoCommit) {
+            if (isAutoCommit && !records.isEmpty()) {
                 // Commit the offset of previously dequeued messages
                 commitAsync();
             }
@@ -395,7 +411,6 @@ public void commitAsync(Map<TopicPartition, OffsetAndMetadata> offsets, OffsetCo
 
         offsets.forEach((topicPartition, offsetAndMetadata) -> {
             org.apache.pulsar.client.api.Consumer<byte[]> consumer = consumers.get(topicPartition);
-
             lastCommittedOffset.put(topicPartition, offsetAndMetadata);
             futures.add(consumer.acknowledgeCumulativeAsync(MessageIdUtils.getMessageId(offsetAndMetadata.offset())));
         });
@@ -435,6 +450,8 @@ public void seekToBeginning(Collection<TopicPartition> partitions) {
         if (partitions.isEmpty()) {
             partitions = consumers.keySet();
         }
+        lastCommittedOffset.clear();
+        lastReceivedOffset.clear();
 
         for (TopicPartition tp : partitions) {
             org.apache.pulsar.client.api.Consumer<byte[]> c = consumers.get(tp);
@@ -456,6 +473,8 @@ public void seekToEnd(Collection<TopicPartition> partitions) {
         if (partitions.isEmpty()) {
             partitions = consumers.keySet();
         }
+        lastCommittedOffset.clear();
+        lastReceivedOffset.clear();
 
         for (TopicPartition tp : partitions) {
             org.apache.pulsar.client.api.Consumer<byte[]> c = consumers.get(tp);
diff --git a/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-2-bookie-1-broker-unstarted-with-s3.yaml b/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-2-bookie-1-broker-unstarted-with-s3.yaml
deleted file mode 100644
index ec46571249..0000000000
--- a/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-2-bookie-1-broker-unstarted-with-s3.yaml
+++ /dev/null
@@ -1,164 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-networks:
-  pulsarnet*:
-    driver: bridge
-
-zookeeper*:
-  image: apachepulsar/pulsar-test-latest-version:latest
-  await:
-    strategy: org.apache.pulsar.tests.NoopAwaitStrategy
-  env: [ZOOKEEPER_SERVERS=zookeeper]
-  labels:
-    cluster: test
-    service: zookeeper
-  entryPoint: [bin/run-local-zk.sh]
-  aliases:
-    - zookeeper
-  beforeStop:
-    - customBeforeStopAction:
-        strategy: org.apache.pulsar.tests.PulsarLogsToTargetDirStopAction
-    - customBeforeStopAction:
-        strategy: org.apache.pulsar.tests.ZKJournalToTargetDirStopAction
-  networkMode: pulsarnet*
-
-configuration-store*:
-  image: apachepulsar/pulsar-test-latest-version:latest
-  await:
-    strategy: org.apache.pulsar.tests.NoopAwaitStrategy
-  env: [ZOOKEEPER_SERVERS=configuration-store]
-  labels:
-    cluster: test
-    service: configuration-store
-  entryPoint: [bin/run-global-zk.sh]
-  aliases:
-    - configuration-store
-  beforeStop:
-    - customBeforeStopAction:
-        strategy: org.apache.pulsar.tests.PulsarLogsToTargetDirStopAction
-    - customBeforeStopAction:
-        strategy: org.apache.pulsar.tests.ZKJournalToTargetDirStopAction
-  networkMode: pulsarnet*
-
-init*:
-  image: apachepulsar/pulsar-test-latest-version:latest
-  await:
-    strategy: org.apache.pulsar.tests.NoopAwaitStrategy
-  env:
-    - clusterName=test
-    - zkServers=zookeeper
-    - configurationStore=configuration-store:2184
-    - pulsarNode=pulsar-broker1
-  labels:
-    cluster: test
-    service: init
-  entryPoint: [bin/init-cluster.sh]
-  beforeStop:
-    - customBeforeStopAction:
-        strategy: org.apache.pulsar.tests.LogToTargetDirStopAction
-  networkMode: pulsarnet*
-
-bookkeeper1*:
-  image: apachepulsar/pulsar-test-latest-version:latest
-  await:
-    strategy: org.apache.pulsar.tests.NoopAwaitStrategy
-  env:
-    - clusterName=test
-    - zkServers=zookeeper
-    - useHostNameAsBookieID=true
-  labels:
-    cluster: test
-    service: bookie
-  entryPoint: [bin/run-bookie.sh]
-  beforeStop:
-    - customBeforeStopAction:
-        strategy: org.apache.pulsar.tests.PulsarLogsToTargetDirStopAction
-  networkMode: pulsarnet*
-
-bookkeeper2*:
-  image: apachepulsar/pulsar-test-latest-version:latest
-  await:
-    strategy: org.apache.pulsar.tests.NoopAwaitStrategy
-  env:
-    - clusterName=test
-    - zkServers=zookeeper
-    - useHostNameAsBookieID=true
-  labels:
-    cluster: test
-    service: bookie
-  entryPoint: [bin/run-bookie.sh]
-  beforeStop:
-    - customBeforeStopAction:
-        strategy: org.apache.pulsar.tests.PulsarLogsToTargetDirStopAction
-  networkMode: pulsarnet*
-
-pulsar-broker1*:
-  image: apachepulsar/pulsar-test-latest-version:latest
-  await:
-    strategy: org.apache.pulsar.tests.NoopAwaitStrategy
-  aliases:
-    - pulsar-broker1
-  env:
-    - zookeeperServers=zookeeper
-    - configurationStoreServers=configuration-store:2184
-    - clusterName=test
-    - NO_AUTOSTART=true
-  labels:
-    cluster: test
-    service: pulsar-broker
-  entryPoint: [bin/run-broker.sh]
-  beforeStop:
-    - customBeforeStopAction:
-        strategy: org.apache.pulsar.tests.PulsarLogsToTargetDirStopAction
-  networkMode: pulsarnet*
-
-pulsar-proxy*:
-  image: apachepulsar/pulsar-test-latest-version:latest
-  await:
-    strategy: org.apache.pulsar.tests.NoopAwaitStrategy
-  env:
-    - zookeeperServers=zookeeper
-    - configurationStoreServers=configuration-store:2184
-    - clusterName=test
-    - NO_AUTOSTART=true
-  labels:
-    cluster: test
-    service: pulsar-proxy
-  entryPoint: [bin/run-proxy.sh]
-  beforeStop:
-    - customBeforeStopAction:
-        strategy: org.apache.pulsar.tests.PulsarLogsToTargetDirStopAction
-  networkMode: pulsarnet*
-
-s3*:
-  ## use latest adobe/s3mock, for issue: https://github.com/adobe/S3Mock/issues/32
-  ## TODO: https://github.com/apache/incubator-pulsar/issues/2133
-  image: apachepulsar/s3mock
-  await:
-    strategy: org.apache.pulsar.tests.NoopAwaitStrategy
-  env:
-    - initialBuckets=pulsar-integtest
-  labels:
-    cluster: test
-    service: s3
-  beforeStop:
-    - customBeforeStopAction:
-        strategy: org.apache.pulsar.tests.LogToTargetDirStopAction
-  networkMode: pulsarnet*
diff --git a/tests/integration/pom.xml b/tests/integration/pom.xml
index 653c076dc5..7f084b01f6 100644
--- a/tests/integration/pom.xml
+++ b/tests/integration/pom.xml
@@ -138,6 +138,17 @@
 
   <build>
     <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
diff --git a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/topologies/PulsarStandaloneTestBase.java b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/topologies/PulsarStandaloneTestBase.java
index 48c7fe6beb..40be9ba9e4 100644
--- a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/topologies/PulsarStandaloneTestBase.java
+++ b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/topologies/PulsarStandaloneTestBase.java
@@ -62,7 +62,6 @@ protected void startCluster() throws Exception {
         container = new StandaloneContainer(clusterName)
             .withNetwork(network)
             .withNetworkAliases(StandaloneContainer.NAME + "-" + clusterName);
-        container.tailContainerLog();
         container.start();
         log.info("Pulsar cluster {} is up running:", clusterName);
         log.info("\tBinary Service Url : {}", container.getPlainTextServiceUrl());
diff --git a/tests/pom.xml b/tests/pom.xml
index 074d4bc50c..5c410b1ee0 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -34,6 +34,7 @@
   <modules>
     <module>docker-images</module>
     <module>integration</module>
+    <module>pulsar-kafka-compat-client-test</module>
   </modules>
   <build>
     <plugins>
diff --git a/tests/pulsar-kafka-compat-client-test/pom.xml b/tests/pulsar-kafka-compat-client-test/pom.xml
new file mode 100644
index 0000000000..196f682001
--- /dev/null
+++ b/tests/pulsar-kafka-compat-client-test/pom.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.pulsar.tests</groupId>
+    <artifactId>tests-parent</artifactId>
+    <version>2.2.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>pulsar-kafka-compat-client-test</artifactId>
+  <packaging>jar</packaging>
+  <name>Apache Pulsar :: Tests :: Pulsar Kafka Compat Client Tests</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.pulsar.tests</groupId>
+      <artifactId>integration</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.kafka</groupId>
+          <artifactId>kafka-clients</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.testcontainers</groupId>
+      <artifactId>testcontainers</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.pulsar</groupId>
+      <artifactId>pulsar-client-admin</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.pulsar</groupId>
+      <artifactId>pulsar-client-kafka</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.kafka</groupId>
+          <artifactId>kafka-clients</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <!-- only run tests when -DintegrationTests is specified //-->
+          <skipTests>true</skipTests>
+          <systemPropertyVariables>
+            <currentVersion>${project.version}</currentVersion>
+            <maven.buildDirectory>${project.build.directory}</maven.buildDirectory>
+          </systemPropertyVariables>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>integrationTests</id>
+      <activation>
+        <property>
+          <name>integrationTests</name>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <properties>
+                <property>
+                  <name>listener</name>
+                  <value>org.apache.pulsar.tests.PulsarTestListener</value>
+                </property>
+              </properties>
+              <argLine>-Xmx2G -XX:MaxDirectMemorySize=8G
+              -Dio.netty.leakDetectionLevel=advanced
+              </argLine>
+              <skipTests>false</skipTests>
+              <forkCount>1</forkCount>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
diff --git a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/compat/kafka/KafkaApiTest.java b/tests/pulsar-kafka-compat-client-test/src/test/java/org/apache/pulsar/tests/integration/compat/kafka/KafkaApiTest.java
similarity index 88%
rename from tests/integration/src/test/java/org/apache/pulsar/tests/integration/compat/kafka/KafkaApiTest.java
rename to tests/pulsar-kafka-compat-client-test/src/test/java/org/apache/pulsar/tests/integration/compat/kafka/KafkaApiTest.java
index 3dd8940416..fe2a4d9a07 100644
--- a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/compat/kafka/KafkaApiTest.java
+++ b/tests/pulsar-kafka-compat-client-test/src/test/java/org/apache/pulsar/tests/integration/compat/kafka/KafkaApiTest.java
@@ -51,25 +51,32 @@
 import org.apache.pulsar.client.admin.PulsarAdmin;
 import org.apache.pulsar.client.api.Message;
 import org.apache.pulsar.client.api.PulsarClient;
-import org.apache.pulsar.tests.integration.suites.PulsarTestSuite;
+import org.apache.pulsar.tests.integration.suites.PulsarStandaloneTestSuite;
 import org.testng.annotations.Test;
 
-@Test(enabled = false)
 @Slf4j
-public class KafkaApiTest extends PulsarTestSuite {
+public class KafkaApiTest extends PulsarStandaloneTestSuite {
+
+    private static String getPlainTextServiceUrl() {
+        return container.getPlainTextServiceUrl();
+    }
+
+    private static String getHttpServiceUrl() {
+        return container.getHttpServiceUrl();
+    }
 
     @Test(timeOut = 30000)
     public void testSimpleProducerConsumer() throws Exception {
         String topic = "persistent://public/default/testSimpleProducerConsumer";
 
         Properties producerProperties = new Properties();
-        producerProperties.put("bootstrap.servers", pulsarCluster.getPlainTextServiceUrl());
+        producerProperties.put("bootstrap.servers", getPlainTextServiceUrl());
         producerProperties.put("key.serializer", IntegerSerializer.class.getName());
         producerProperties.put("value.serializer", StringSerializer.class.getName());
         Producer<Integer, String> producer = new KafkaProducer<>(producerProperties);
 
         Properties consumerProperties = new Properties();
-        consumerProperties.put("bootstrap.servers", pulsarCluster.getPlainTextServiceUrl());
+        consumerProperties.put("bootstrap.servers", getPlainTextServiceUrl());
         consumerProperties.put("group.id", "my-subscription-name");
         consumerProperties.put("key.deserializer", IntegerDeserializer.class.getName());
         consumerProperties.put("value.deserializer", StringDeserializer.class.getName());
@@ -110,16 +117,20 @@ public void testSimpleConsumer() throws Exception {
         String topic = "testSimpleConsumer";
 
         Properties props = new Properties();
-        props.put("bootstrap.servers", pulsarCluster.getPlainTextServiceUrl());
+        props.put("bootstrap.servers", getPlainTextServiceUrl());
         props.put("group.id", "my-subscription-name");
         props.put("enable.auto.commit", "false");
         props.put("key.deserializer", StringDeserializer.class.getName());
         props.put("value.deserializer", StringDeserializer.class.getName());
 
+        @Cleanup
         Consumer<String, String> consumer = new KafkaConsumer<>(props);
         consumer.subscribe(Arrays.asList(topic));
 
-        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(pulsarCluster.getPlainTextServiceUrl()).build();
+        @Cleanup
+        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(getPlainTextServiceUrl()).build();
+
+        @Cleanup
         org.apache.pulsar.client.api.Producer<byte[]> pulsarProducer = pulsarClient.newProducer().topic(topic).create();
 
         for (int i = 0; i < 10; i++) {
@@ -129,17 +140,21 @@ public void testSimpleConsumer() throws Exception {
         AtomicInteger received = new AtomicInteger();
         while (received.get() < 10) {
             ConsumerRecords<String, String> records = consumer.poll(100);
-            records.forEach(record -> {
-                assertEquals(record.key(), Integer.toString(received.get()));
-                assertEquals(record.value(), "hello-" + received.get());
-
-                received.incrementAndGet();
-            });
-
-            consumer.commitSync();
+            if (!records.isEmpty()) {
+                records.forEach(record -> {
+                    String key = Integer.toString(received.get());
+                    String value = "hello-" + received.get();
+                    log.info("Receive record : key = {}, value = {}, topic = {}, ptn = {}",
+                        key, value, record.topic(), record.partition());
+                    assertEquals(record.key(), key);
+                    assertEquals(record.value(), value);
+
+                    received.incrementAndGet();
+                });
+
+                consumer.commitSync();
+            }
         }
-
-        consumer.close();
     }
 
     @Test
@@ -147,7 +162,7 @@ public void testConsumerAutoCommit() throws Exception {
         String topic = "testConsumerAutoCommit";
 
         Properties props = new Properties();
-        props.put("bootstrap.servers", pulsarCluster.getPlainTextServiceUrl());
+        props.put("bootstrap.servers", getPlainTextServiceUrl());
         props.put("group.id", "my-subscription-name");
         props.put("enable.auto.commit", "true");
         props.put("key.deserializer", StringDeserializer.class.getName());
@@ -157,7 +172,7 @@ public void testConsumerAutoCommit() throws Exception {
         consumer.subscribe(Arrays.asList(topic));
 
         @Cleanup
-        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(pulsarCluster.getPlainTextServiceUrl()).build();
+        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(getPlainTextServiceUrl()).build();
         org.apache.pulsar.client.api.Producer<byte[]> pulsarProducer = pulsarClient.newProducer().topic(topic).create();
 
         for (int i = 0; i < 10; i++) {
@@ -190,7 +205,7 @@ public void testConsumerManualOffsetCommit() throws Exception {
         String topic = "testConsumerManualOffsetCommit";
 
         Properties props = new Properties();
-        props.put("bootstrap.servers", pulsarCluster.getPlainTextServiceUrl());
+        props.put("bootstrap.servers", getPlainTextServiceUrl());
         props.put("group.id", "my-subscription-name");
         props.put("enable.auto.commit", "false");
         props.put("key.deserializer", StringDeserializer.class.getName());
@@ -200,7 +215,7 @@ public void testConsumerManualOffsetCommit() throws Exception {
         consumer.subscribe(Arrays.asList(topic));
 
         @Cleanup
-        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(pulsarCluster.getPlainTextServiceUrl()).build();
+        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(getPlainTextServiceUrl()).build();
         org.apache.pulsar.client.api.Producer<byte[]> pulsarProducer = pulsarClient.newProducer().topic(topic).create();
 
         for (int i = 0; i < 10; i++) {
@@ -240,18 +255,18 @@ public void testPartitions() throws Exception {
 
         // Create 8 partitions in topic
         @Cleanup
-        PulsarAdmin admin = PulsarAdmin.builder().serviceHttpUrl(pulsarCluster.getHttpServiceUrl()).build();
+        PulsarAdmin admin = PulsarAdmin.builder().serviceHttpUrl(getHttpServiceUrl()).build();
         admin.topics().createPartitionedTopic(topic, 8);
 
         Properties props = new Properties();
-        props.put("bootstrap.servers", pulsarCluster.getPlainTextServiceUrl());
+        props.put("bootstrap.servers", getPlainTextServiceUrl());
         props.put("group.id", "my-subscription-name");
         props.put("enable.auto.commit", "true");
         props.put("key.deserializer", StringDeserializer.class.getName());
         props.put("value.deserializer", StringDeserializer.class.getName());
 
         @Cleanup
-        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(pulsarCluster.getPlainTextServiceUrl()).build();
+        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(getPlainTextServiceUrl()).build();
         org.apache.pulsar.client.api.Producer<byte[]> pulsarProducer = pulsarClient.newProducer().topic(topic)
                 .messageRoutingMode(org.apache.pulsar.client.api.MessageRoutingMode.RoundRobinPartition).create();
 
@@ -287,10 +302,10 @@ public void testPartitions() throws Exception {
 
     @Test
     public void testConsumerSeek() throws Exception {
-        String topic = "testSimpleConsumer";
+        String topic = "testConsumerSeek";
 
         Properties props = new Properties();
-        props.put("bootstrap.servers", pulsarCluster.getPlainTextServiceUrl());
+        props.put("bootstrap.servers", getPlainTextServiceUrl());
         props.put("group.id", "my-subscription-name");
         props.put("enable.auto.commit", "false");
         props.put("key.deserializer", StringDeserializer.class.getName());
@@ -301,7 +316,7 @@ public void testConsumerSeek() throws Exception {
         consumer.subscribe(Arrays.asList(topic));
 
         @Cleanup
-        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(pulsarCluster.getPlainTextServiceUrl()).build();
+        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(getPlainTextServiceUrl()).build();
         org.apache.pulsar.client.api.Producer<byte[]> pulsarProducer = pulsarClient.newProducer().topic(topic).create();
 
         for (int i = 0; i < 10; i++) {
@@ -344,10 +359,10 @@ public void testConsumerSeek() throws Exception {
 
     @Test
     public void testConsumerSeekToEnd() throws Exception {
-        String topic = "testSimpleConsumer";
+        String topic = "testConsumerSeekToEnd";
 
         Properties props = new Properties();
-        props.put("bootstrap.servers", pulsarCluster.getPlainTextServiceUrl());
+        props.put("bootstrap.servers", getPlainTextServiceUrl());
         props.put("group.id", "my-subscription-name");
         props.put("enable.auto.commit", "false");
         props.put("key.deserializer", StringDeserializer.class.getName());
@@ -358,7 +373,7 @@ public void testConsumerSeekToEnd() throws Exception {
         consumer.subscribe(Arrays.asList(topic));
 
         @Cleanup
-        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(pulsarCluster.getPlainTextServiceUrl()).build();
+        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(getPlainTextServiceUrl()).build();
         org.apache.pulsar.client.api.Producer<byte[]> pulsarProducer = pulsarClient.newProducer().topic(topic).create();
 
         for (int i = 0; i < 10; i++) {
@@ -399,13 +414,13 @@ public void testSimpleProducer() throws Exception {
         String topic = "testSimpleProducer";
 
         @Cleanup
-        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(pulsarCluster.getPlainTextServiceUrl()).build();
+        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(getPlainTextServiceUrl()).build();
         org.apache.pulsar.client.api.Consumer<byte[]> pulsarConsumer = pulsarClient.newConsumer().topic(topic)
                 .subscriptionName("my-subscription")
                 .subscribe();
 
         Properties props = new Properties();
-        props.put("bootstrap.servers", pulsarCluster.getPlainTextServiceUrl());
+        props.put("bootstrap.servers", getPlainTextServiceUrl());
 
         props.put("key.serializer", IntegerSerializer.class.getName());
         props.put("value.serializer", StringSerializer.class.getName());
@@ -431,14 +446,14 @@ public void testProducerCallback() throws Exception {
         String topic = "testProducerCallback";
 
         @Cleanup
-        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(pulsarCluster.getPlainTextServiceUrl()).build();
+        PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(getPlainTextServiceUrl()).build();
         org.apache.pulsar.client.api.Consumer<byte[]> pulsarConsumer = pulsarClient.newConsumer()
                 .topic(topic)
                 .subscriptionName("my-subscription")
                 .subscribe();
 
         Properties props = new Properties();
-        props.put("bootstrap.servers", pulsarCluster.getPlainTextServiceUrl());
+        props.put("bootstrap.servers", getPlainTextServiceUrl());
 
         props.put("key.serializer", IntegerSerializer.class.getName());
         props.put("value.serializer", StringSerializer.class.getName());


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services