Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
d62cf072
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
d62cf072
编写于
2月 18, 2017
作者:
J
jai1
提交者:
Matteo Merli
2月 18, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Partitioned topics fix (#226)
上级
b6f061a7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
60 deletion
+56
-60
pulsar-client-cpp/tests/BasicEndToEndTest.cc
pulsar-client-cpp/tests/BasicEndToEndTest.cc
+28
-37
pulsar-client-cpp/tests/BatchMessageTest.cc
pulsar-client-cpp/tests/BatchMessageTest.cc
+4
-6
pulsar-client-cpp/tests/HttpHelper.cc
pulsar-client-cpp/tests/HttpHelper.cc
+24
-17
未找到文件。
pulsar-client-cpp/tests/BasicEndToEndTest.cc
浏览文件 @
d62cf072
...
...
@@ -354,13 +354,12 @@ TEST(BasicEndToEndTest, testPartitionedProducerConsumer)
std
::
string
topicName
=
"persistent://prop/unit/ns/partition-test"
;
// call admin api to make it partitioned
std
::
string
url
=
lookupUrl
+
"/
admin/persistent/prop/unit/ns/partition-test/partitions"
;
int
res
=
makePutRequest
(
lookupU
rl
,
"3"
);
std
::
string
url
=
adminUrl
+
"
admin/persistent/prop/unit/ns/partition-test/partitions"
;
int
res
=
makePutRequest
(
u
rl
,
"3"
);
if
(
res
!=
204
&&
res
!=
409
)
{
LOG_DEBUG
(
"Unable to create partitioned topic."
);
return
;
}
LOG_INFO
(
"res = "
<<
res
);
ASSERT_FALSE
(
res
!=
204
&&
res
!=
409
);
Producer
producer
;
Result
result
=
client
.
createProducer
(
topicName
,
producer
);
ASSERT_EQ
(
ResultOk
,
result
);
...
...
@@ -386,7 +385,7 @@ TEST(BasicEndToEndTest, testPartitionedProducerConsumer)
client
.
shutdown
();
}
TEST
(
BasicEndToEndTest
,
testMessageTooBig
)
TEST
(
BasicEndToEndTest
,
testMessageTooBig
)
{
ClientConfiguration
config
;
Client
client
(
lookupUrl
);
...
...
@@ -512,13 +511,11 @@ TEST(BasicEndToEndTest, testSinglePartitionRoutingPolicy)
std
::
string
topicName
=
"persistent://prop/unit/ns/partition-testSinglePartitionRoutingPolicy"
;
// call admin api to make it partitioned
std
::
string
url
=
lookupUrl
+
"/
admin/persistent/prop/unit/ns/partition-testSinglePartitionRoutingPolicy/partitions"
;
int
res
=
makePutRequest
(
lookupU
rl
,
"5"
);
std
::
string
url
=
adminUrl
+
"
admin/persistent/prop/unit/ns/partition-testSinglePartitionRoutingPolicy/partitions"
;
int
res
=
makePutRequest
(
u
rl
,
"5"
);
if
(
res
!=
204
&&
res
!=
409
)
{
LOG_DEBUG
(
"Unable to create partitioned topic."
);
return
;
}
LOG_INFO
(
"res = "
<<
res
);
ASSERT_FALSE
(
res
!=
204
&&
res
!=
409
);
Producer
producer
;
ProducerConfiguration
producerConfiguration
;
...
...
@@ -573,13 +570,11 @@ TEST(BasicEndToEndTest, testSinglePartitionRoutingPolicy)
std
::
string
topicName
=
"persistent://prop/unit/ns/partition-testDuplicateConsumerCreationOnPartitionedTopic"
;
// call admin api to make it partitioned
std
::
string
url
=
lookupUrl
+
"/
admin/persistent/prop/unit/ns/testDuplicateConsumerCreationOnPartitionedTopic/partitions"
;
int
res
=
makePutRequest
(
lookupU
rl
,
"5"
);
std
::
string
url
=
adminUrl
+
"
admin/persistent/prop/unit/ns/testDuplicateConsumerCreationOnPartitionedTopic/partitions"
;
int
res
=
makePutRequest
(
u
rl
,
"5"
);
if
(
res
!=
204
&&
res
!=
409
)
{
LOG_DEBUG
(
"Unable to create partitioned topic."
);
return
;
}
LOG_INFO
(
"res = "
<<
res
);
ASSERT_FALSE
(
res
!=
204
&&
res
!=
409
);
usleep
(
2
*
1000
*
1000
);
...
...
@@ -626,13 +621,11 @@ TEST(BasicEndToEndTest, testRoundRobinRoutingPolicy)
Client
client
(
lookupUrl
);
std
::
string
topicName
=
"persistent://prop/unit/ns/partition-testRoundRobinRoutingPolicy"
;
// call admin api to make it partitioned
std
::
string
url
=
lookupUrl
+
"/
admin/persistent/prop/unit/ns/partition-testRoundRobinRoutingPolicy/partitions"
;
int
res
=
makePutRequest
(
lookupU
rl
,
"5"
);
std
::
string
url
=
adminUrl
+
"
admin/persistent/prop/unit/ns/partition-testRoundRobinRoutingPolicy/partitions"
;
int
res
=
makePutRequest
(
u
rl
,
"5"
);
if
(
res
!=
204
&&
res
!=
409
)
{
LOG_DEBUG
(
"Unable to create partitioned topic."
);
return
;
}
LOG_INFO
(
"res = "
<<
res
);
ASSERT_FALSE
(
res
!=
204
&&
res
!=
409
);
Producer
producer
;
ProducerConfiguration
tempProducerConfiguration
;
...
...
@@ -693,13 +686,11 @@ TEST(BasicEndToEndTest, testMessageListener)
Client
client
(
lookupUrl
);
std
::
string
topicName
=
"persistent://prop/unit/ns/partition-testMessageListener"
;
// call admin api to make it partitioned
std
::
string
url
=
lookupUrl
+
"/
admin/persistent/prop/unit/ns/partition-testMessageListener/partitions"
;
int
res
=
makePutRequest
(
lookupU
rl
,
"5"
);
std
::
string
url
=
adminUrl
+
"
admin/persistent/prop/unit/ns/partition-testMessageListener/partitions"
;
int
res
=
makePutRequest
(
u
rl
,
"5"
);
if
(
res
!=
204
&&
res
!=
409
)
{
LOG_DEBUG
(
"Unable to create partitioned topic."
);
return
;
}
LOG_INFO
(
"res = "
<<
res
);
ASSERT_FALSE
(
res
!=
204
&&
res
!=
409
);
Producer
producer
;
ProducerConfiguration
producerConfiguration
;
...
...
@@ -738,13 +729,13 @@ TEST(BasicEndToEndTest, testMessageListenerPause)
std
::
string
topicName
=
"persistent://property/cluster/namespace/partition-testMessageListener-pauses"
;
// call admin api to make it partitioned
std
::
string
url
=
lookupUrl
+
"/admin/persistent/prop/unit/ns/partition-testMessageListener-pauses/partitions"
;
int
res
=
makePutRequest
(
lookupUrl
,
"5"
);
std
::
string
url
=
adminUrl
+
"admin/persistent/property/cluster/namespace/partition-testMessageListener-pauses/partitions"
;
int
res
=
makePutRequest
(
url
,
"5"
);
LOG_INFO
(
"res = "
<<
res
);
ASSERT_FALSE
(
res
!=
204
&&
res
!=
409
);
if
(
res
!=
204
&&
res
!=
409
)
{
LOG_DEBUG
(
"Unable to create partitioned topic."
);
return
;
}
Producer
producer
;
ProducerConfiguration
producerConfiguration
;
producerConfiguration
.
setPartitionsRoutingMode
(
ProducerConfiguration
::
UseSinglePartition
);
...
...
pulsar-client-cpp/tests/BatchMessageTest.cc
浏览文件 @
d62cf072
...
...
@@ -763,14 +763,12 @@ TEST(BatchMessageTest, testPartitionedTopics) {
std
::
string
topicName
=
"persistent://property/cluster/namespace/test-partitioned-batch-messages-"
+
boost
::
lexical_cast
<
std
::
string
>
(
epochTime
)
;
// call admin api to make it partitioned
std
::
string
url
=
lookupUrl
+
"/admin/persistent/prop/unit/ns
/test-partitioned-batch-messages-"
std
::
string
url
=
adminUrl
+
"admin/persistent/property/cluster/namespace
/test-partitioned-batch-messages-"
+
boost
::
lexical_cast
<
std
::
string
>
(
epochTime
)
+
"/partitions"
;
int
res
=
makePutRequest
(
lookupU
rl
,
"7"
);
int
res
=
makePutRequest
(
u
rl
,
"7"
);
if
(
res
!=
204
&&
res
!=
409
)
{
LOG_DEBUG
(
"Unable to create partitioned topic."
);
return
;
}
LOG_INFO
(
"res = "
<<
res
);
ASSERT_FALSE
(
res
!=
204
&&
res
!=
409
);
usleep
(
2
*
1000
*
1000
);
...
...
pulsar-client-cpp/tests/HttpHelper.cc
浏览文件 @
d62cf072
...
...
@@ -19,20 +19,27 @@
#include <curl/curl.h>
int
makePutRequest
(
const
std
::
string
&
url
,
const
std
::
string
&
body
)
{
CURL
*
curl
=
curl_easy_init
();
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_CUSTOMREQUEST
,
"PUT"
);
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDS
,
body
.
c_str
());
int
res
=
curl_easy_perform
(
curl
);
if
(
res
!=
CURLE_OK
)
{
return
-
1
;
}
int
httpResult
=
0
;
curl_easy_getinfo
(
curl
,
CURLINFO_RESPONSE_CODE
,
&
httpResult
);
curl_easy_cleanup
(
curl
);
return
httpResult
;
}
int
makePutRequest
(
const
std
::
string
&
url
,
const
std
::
string
&
body
)
{
CURL
*
curl
=
curl_easy_init
();
struct
curl_slist
*
list
=
NULL
;
list
=
curl_slist_append
(
list
,
"Content-Type: application/json"
);
curl_easy_setopt
(
curl
,
CURLOPT_HTTPHEADER
,
list
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_CUSTOMREQUEST
,
"PUT"
);
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDS
,
body
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_VERBOSE
,
1L
);
int
res
=
curl_easy_perform
(
curl
);
curl_slist_free_all
(
list
);
/* free the list again */
if
(
res
!=
CURLE_OK
)
{
return
-
1
;
}
int
httpResult
=
0
;
curl_easy_getinfo
(
curl
,
CURLINFO_RESPONSE_CODE
,
&
httpResult
);
curl_easy_cleanup
(
curl
);
return
httpResult
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录