From 8080e88bdbd4eca230cd8be759cd8b8303ea7a26 Mon Sep 17 00:00:00 2001 From: jai1 Date: Thu, 6 Apr 2017 08:47:25 -0700 Subject: [PATCH] Fixed BasicEndToEndTest.testResendViaSendCallback (#333) * Fixed BasicEndToEndTes.testResendViaSendCallback * Update travis-build.sh * Added include path for json headers * Update travis-build.sh * Update travis-build.sh * Update CMakeLists.txt --- pulsar-client-cpp/CMakeLists.txt | 8 ++++++++ pulsar-client-cpp/tests/BasicEndToEndTest.cc | 18 +++++++++++------- pulsar-client-cpp/travis-build.sh | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/pulsar-client-cpp/CMakeLists.txt b/pulsar-client-cpp/CMakeLists.txt index 7907acbaaf9..85be551d031 100644 --- a/pulsar-client-cpp/CMakeLists.txt +++ b/pulsar-client-cpp/CMakeLists.txt @@ -32,12 +32,19 @@ 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) +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}) link_directories( $ENV{PULSAR_ADDITIONAL_LIBRARY_PATH} ) @@ -50,6 +57,7 @@ include_directories( ${PROTOBUF_INCLUDE_DIR} ${LOG4CXX_INCLUDE_PATH} ${GTEST_INCLUDE_PATH} + ${JSON_INCLUDE_PATH} ) set(COMMON_LIBS diff --git a/pulsar-client-cpp/tests/BasicEndToEndTest.cc b/pulsar-client-cpp/tests/BasicEndToEndTest.cc index bc18b82dbf5..fa71f8a49c0 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_); diff --git a/pulsar-client-cpp/travis-build.sh b/pulsar-client-cpp/travis-build.sh index 883dba8bcd5..a365d921fae 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"; -- GitLab