From ab20ce383649ad197fff11631290a4b7dd6e0574 Mon Sep 17 00:00:00 2001 From: Jai ASher Date: Wed, 5 Apr 2017 12:58:10 -0700 Subject: [PATCH 1/6] Fixed BasicEndToEndTes.testResendViaSendCallback --- pulsar-client-cpp/tests/BasicEndToEndTest.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pulsar-client-cpp/tests/BasicEndToEndTest.cc b/pulsar-client-cpp/tests/BasicEndToEndTest.cc index bc18b82dbf5e8..fa71f8a49c026 100644 --- a/pulsar-client-cpp/tests/BasicEndToEndTest.cc +++ b/pulsar-client-cpp/tests/BasicEndToEndTest.cc @@ -129,6 +129,7 @@ void resendMessage(Result r, const Message& msg, Producer &producer) { } lock.unlock(); } + usleep(2 * 1000); producer.sendAsync(MessageBuilder().build(), boost::bind(resendMessage, _1, _2, producer)); } @@ -780,10 +781,10 @@ TEST(BasicEndToEndTest, testMessageListenerPause) int temp = 1000; for (int i = 0; i < 10000; i++ ) { if(i && i%1000 == 0) { - usleep(5 * 1000 * 1000); + usleep(2 * 1000 * 1000); ASSERT_EQ(globalCount, temp); consumer.resumeMessageListener(); - usleep(5 * 1000 * 1000); + usleep(2 * 1000 * 1000); ASSERT_EQ(globalCount, i); temp = globalCount; consumer.pauseMessageListener(); @@ -794,8 +795,8 @@ TEST(BasicEndToEndTest, testMessageListenerPause) ASSERT_EQ(globalCount, temp); consumer.resumeMessageListener(); - // Sleeping for 5 seconds - usleep(5 * 1000 * 1000); + // Sleeping for 2 seconds + usleep(2 * 1000 * 1000); ASSERT_EQ(globalCount, 10000); consumer.close(); producer.closeAsync(0); @@ -804,7 +805,9 @@ TEST(BasicEndToEndTest, testMessageListenerPause) TEST(BasicEndToEndTest, testResendViaSendCallback) { - Client client(lookupUrl); + ClientConfiguration clientConfiguration; + clientConfiguration.setIOThreads(1); + Client client(lookupUrl, clientConfiguration); std::string topicName = "persistent://my-property/my-cluster/my-namespace/testResendViaListener"; Producer producer; @@ -822,8 +825,9 @@ TEST(BasicEndToEndTest, testMessageListenerPause) // Send asynchronously for 3 seconds // Expect timeouts since we have set timeout to 1 ms // On receiving timeout send the message using the CMS client IO thread via cb function. - producer.sendAsync(MessageBuilder().build(), boost::bind(resendMessage, _1, _2, producer)); - + for (int i = 0; i<1000; i++) { + producer.sendAsync(MessageBuilder().build(), boost::bind(resendMessage, _1, _2, producer)); + } // 3 seconds usleep(3 * 1000 * 1000); Lock lock(mutex_); From 9e566b4102579d9ed9a5079058862010e100b13d Mon Sep 17 00:00:00 2001 From: jai1 Date: Wed, 5 Apr 2017 16:23:41 -0700 Subject: [PATCH 2/6] Update travis-build.sh --- pulsar-client-cpp/travis-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulsar-client-cpp/travis-build.sh b/pulsar-client-cpp/travis-build.sh index 883dba8bcd5d2..a365d921fae39 100755 --- a/pulsar-client-cpp/travis-build.sh +++ b/pulsar-client-cpp/travis-build.sh @@ -55,7 +55,7 @@ exec_cmd() { if [ "$3" = "all" -o "$3" = "dep" ]; then # Install dependant packages - exec_cmd "apt-get update && apt-get install -y cmake gcc-4.4 cpp-4.4 gcc-4.4-base libssl-dev libcurl4-openssl-dev liblog4cxx10-dev libprotobuf-dev libboost1.55-all-dev libgtest-dev libxml2-utils g++-4.4"; + exec_cmd "apt-get update && apt-get install -y cmake gcc-4.4 cpp-4.4 gcc-4.4-base libssl-dev libcurl4-openssl-dev liblog4cxx10-dev libprotobuf-dev libboost1.55-all-dev libgtest-dev libxml2-utils g++-4.4 libjsoncpp-dev"; if [ ! -f "$1/libgtest.a" ]; then echo "Not Found: $1/libgtest.a" exec_cmd "pushd /usr/src/gtest && CC=gcc-4.4 CXX=g++-4.4 cmake . && make && cp libgtest.a $1/ && popd"; From b6145e409eb92fc7eb7aa70a2be9ea08d48d6a61 Mon Sep 17 00:00:00 2001 From: Jai ASher Date: Wed, 5 Apr 2017 19:21:41 -0700 Subject: [PATCH 3/6] Added include path for json headers --- pulsar-client-cpp/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pulsar-client-cpp/CMakeLists.txt b/pulsar-client-cpp/CMakeLists.txt index 7907acbaaf9bd..42d2799c8b4de 100644 --- a/pulsar-client-cpp/CMakeLists.txt +++ b/pulsar-client-cpp/CMakeLists.txt @@ -32,12 +32,17 @@ find_library(LOG4CXX_LIBRARY_PATH log4cxx) find_library(CURL_LIBRARY_PATH curl) find_path(LOG4CXX_INCLUDE_PATH log4cxx/logger.h) find_path(GTEST_INCLUDE_PATH gtest/gtest.h) +find_path(JSON_INCLUDE_PATH jsoncpp) find_library(LIB_JSON jsoncpp) if (NOT LIB_JSON) find_library(LIB_JSON json_cpp) endif (NOT LIB_JSON) +if (NOT JSON_INCLUDE_PATH) + find_path(JSON_INCLUDE_PATH json) +endif (NOT JSON_INCLUDE_PATH) + set(ADDITIONAL_LIBRARIES $ENV{PULSAR_ADDITIONAL_LIBRARIES}) link_directories( $ENV{PULSAR_ADDITIONAL_LIBRARY_PATH} ) @@ -50,6 +55,7 @@ include_directories( ${PROTOBUF_INCLUDE_DIR} ${LOG4CXX_INCLUDE_PATH} ${GTEST_INCLUDE_PATH} + ${JSON_INCLUDE_PATH} ) set(COMMON_LIBS From c109b4cfb9f5c495cd8fb2533a8aba9962cde921 Mon Sep 17 00:00:00 2001 From: jai1 Date: Thu, 6 Apr 2017 00:24:43 -0700 Subject: [PATCH 4/6] Update travis-build.sh --- pulsar-client-cpp/travis-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulsar-client-cpp/travis-build.sh b/pulsar-client-cpp/travis-build.sh index a365d921fae39..21cff6f8a87f7 100755 --- a/pulsar-client-cpp/travis-build.sh +++ b/pulsar-client-cpp/travis-build.sh @@ -71,7 +71,7 @@ if [ "$3" = "all" -o "$3" = "dep" ]; then fi if [ "$3" = "all" -o "$3" = "compile" ]; then - export PATH=$PATH:$1/ + export PATH=$PATH:$1/:/usr/include/jsoncpp/ # Compile and run unit tests exec_cmd "pushd $2/pulsar-client-cpp && CC=gcc-4.4 CXX=g++-4.4 cmake . && make && popd"; PULSAR_STANDALONE_CONF=$2/pulsar-client-cpp/tests/standalone.conf $2/bin/pulsar standalone & From 643d57bc95d599d045010d634a5063b64b62a537 Mon Sep 17 00:00:00 2001 From: jai1 Date: Thu, 6 Apr 2017 00:37:07 -0700 Subject: [PATCH 5/6] Update travis-build.sh --- pulsar-client-cpp/travis-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulsar-client-cpp/travis-build.sh b/pulsar-client-cpp/travis-build.sh index 21cff6f8a87f7..a365d921fae39 100755 --- a/pulsar-client-cpp/travis-build.sh +++ b/pulsar-client-cpp/travis-build.sh @@ -71,7 +71,7 @@ if [ "$3" = "all" -o "$3" = "dep" ]; then fi if [ "$3" = "all" -o "$3" = "compile" ]; then - export PATH=$PATH:$1/:/usr/include/jsoncpp/ + export PATH=$PATH:$1/ # Compile and run unit tests exec_cmd "pushd $2/pulsar-client-cpp && CC=gcc-4.4 CXX=g++-4.4 cmake . && make && popd"; PULSAR_STANDALONE_CONF=$2/pulsar-client-cpp/tests/standalone.conf $2/bin/pulsar standalone & From bacfc95cbad58d0b2787f595c42177ef28b54046 Mon Sep 17 00:00:00 2001 From: jai1 Date: Thu, 6 Apr 2017 00:38:35 -0700 Subject: [PATCH 6/6] Update CMakeLists.txt --- pulsar-client-cpp/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pulsar-client-cpp/CMakeLists.txt b/pulsar-client-cpp/CMakeLists.txt index 42d2799c8b4de..85be551d031dd 100644 --- a/pulsar-client-cpp/CMakeLists.txt +++ b/pulsar-client-cpp/CMakeLists.txt @@ -41,6 +41,8 @@ endif (NOT LIB_JSON) if (NOT JSON_INCLUDE_PATH) find_path(JSON_INCLUDE_PATH json) +else (NOT JSON_INCLUDE_PATH) + set(JSON_INCLUDE_PATH ${JSON_INCLUDE_PATH}/jsoncpp/) endif (NOT JSON_INCLUDE_PATH) set(ADDITIONAL_LIBRARIES $ENV{PULSAR_ADDITIONAL_LIBRARIES})