Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed BasicEndToEndTest.testResendViaSendCallback #333

Merged
merged 8 commits into from
Apr 6, 2017
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions pulsar-client-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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} )

Expand All @@ -50,6 +57,7 @@ include_directories(
${PROTOBUF_INCLUDE_DIR}
${LOG4CXX_INCLUDE_PATH}
${GTEST_INCLUDE_PATH}
${JSON_INCLUDE_PATH}
)

set(COMMON_LIBS
Expand Down
18 changes: 11 additions & 7 deletions pulsar-client-cpp/tests/BasicEndToEndTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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_);
Expand Down
2 changes: 1 addition & 1 deletion pulsar-client-cpp/travis-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down