merlimat commented on a change in pull request #1858: Cpp client: add 
readCompacted in consumer config
URL: https://github.com/apache/incubator-pulsar/pull/1858#discussion_r192163363
 
 

 ##########
 File path: pulsar-client-cpp/tests/ConsumerConfigurationTest.cc
 ##########
 @@ -0,0 +1,105 @@
+/**
+ * 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.
+ */
+#include <pulsar/Client.h>
+#include <gtest/gtest.h>
+
+#include "../lib/Future.h"
+#include "../lib/Utils.h"
+
+using namespace pulsar;
+
+TEST(ConsumerConfigurationTest, testReadCompactPersistentExclusive) {
+    std::string lookupUrl = "pulsar://localhost:8885";
+    std::string topicName = "persistent://prop/unit/ns1/persist-topic";
+    std::string subName = "test-persist-exclusive";
+
+    Result result;
+
+    ConsumerConfiguration config;
+    config.setReadCompacted(true);
+    config.setConsumerType(ConsumerExclusive);
+
+    ClientConfiguration clientConfig;
+    Client client(lookupUrl, clientConfig);
+
+    Consumer consumer;
+    result = client.subscribe(topicName, subName, config, consumer);
+    ASSERT_EQ(ResultOk, result);
+    consumer.close();
+}
+
+TEST(ConsumerConfigurationTest, testReadCompactPersistentFailover) {
+    std::string lookupUrl = "pulsar://localhost:8885";
+    std::string topicName = "persistent://prop/unit/ns1/persist-topic";
+    std::string subName = "test-persist-fail-over";
+
+    Result result;
+
+    ConsumerConfiguration config;
+    config.setReadCompacted(true);
+    config.setConsumerType(ConsumerFailover);
+
+    ClientConfiguration clientConfig;
+    Client client(lookupUrl, clientConfig);
+
+    Consumer consumer;
+    result = client.subscribe(topicName, subName, config, consumer);
+    ASSERT_EQ(ResultOk, result);
+    consumer.close();
+}
+
+TEST(ConsumerConfigurationTest, testReadCompactPersistentShared) {
+    std::string lookupUrl = "pulsar://localhost:8885";
+    std::string topicName = "persistent://prop/unit/ns1/persist-topic";
+    std::string subName = "test-persist-shared";
+
+    Result result;
+
+    ConsumerConfiguration config;
+    config.setReadCompacted(true);
+    config.setConsumerType(ConsumerShared);
+
+    ClientConfiguration clientConfig;
+    Client client(lookupUrl, clientConfig);
+
+    Consumer consumer;
+    result = client.subscribe(topicName, subName, config, consumer);
+    ASSERT_EQ(ResultInvalidConfiguration, result);
+    consumer.close();
+}
+
+TEST(ConsumerConfigurationTest, testReadCompactNonPersistentExclusive) {
+    std::string lookupUrl = "pulsar://localhost:8885";
+    std::string topicName = 
"non-persistent://prop/unit/ns1/testNonPersistentTopic";
+    std::string subName = "test-non-persist-exclusive";
+
+    Result result;
+
+    ConsumerConfiguration config;
+    config.setReadCompacted(true);
+    config.setConsumerType(ConsumerExclusive);
+
+    ClientConfiguration clientConfig;
+    Client client(lookupUrl, clientConfig);
+
+    Consumer consumer;
+    result = client.subscribe(topicName, subName, config, consumer);
+    ASSERT_EQ(ResultInvalidConfiguration, result);
+    consumer.close();
+}
 
 Review comment:
   @zhaijack As @ivankelly, it would be good to have an end-to-end test here. 
Since the broker is running when the tests are executed, it's possible to make 
HTTP calls to trigger the compaction and verify the client indeed receives only 
the compacted data. 
   
   It might be easier from the Python unit tests (at least in terms of making 
the rest calls).

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to