Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
c68e8bc2
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
c68e8bc2
编写于
9月 08, 2016
作者:
M
Matteo Merli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Run ZookeeperCacheTest with MockZK event in same thread to avoid race conditions
上级
9f7461cd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
6 deletion
+32
-6
managed-ledger/src/test/java/org/apache/zookeeper/MockZooKeeper.java
...ger/src/test/java/org/apache/zookeeper/MockZooKeeper.java
+11
-3
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
...yahoo/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
+2
-1
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/service/ServerCnxTest.java
...t/java/com/yahoo/pulsar/broker/service/ServerCnxTest.java
+16
-1
pulsar-zookeeper-utils/src/test/java/com/yahoo/pulsar/zookeeper/ZookeeperCacheTest.java
...t/java/com/yahoo/pulsar/zookeeper/ZookeeperCacheTest.java
+3
-1
未找到文件。
managed-ledger/src/test/java/org/apache/zookeeper/MockZooKeeper.java
浏览文件 @
c68e8bc2
...
...
@@ -62,12 +62,16 @@ public class MockZooKeeper extends ZooKeeper {
private
long
sessionId
=
0L
;
public
static
MockZooKeeper
newInstance
()
{
return
newInstance
(
null
);
}
public
static
MockZooKeeper
newInstance
(
ExecutorService
executor
)
{
try
{
ReflectionFactory
rf
=
ReflectionFactory
.
getReflectionFactory
();
Constructor
objDef
=
Object
.
class
.
getDeclaredConstructor
(
new
Class
[
0
]);
Constructor
intConstr
=
rf
.
newConstructorForSerialization
(
MockZooKeeper
.
class
,
objDef
);
MockZooKeeper
zk
=
MockZooKeeper
.
class
.
cast
(
intConstr
.
newInstance
());
zk
.
init
();
zk
.
init
(
executor
);
return
zk
;
}
catch
(
RuntimeException
e
)
{
throw
e
;
...
...
@@ -76,9 +80,13 @@ public class MockZooKeeper extends ZooKeeper {
}
}
private
void
init
()
{
private
void
init
(
ExecutorService
executor
)
{
tree
=
Maps
.
newTreeMap
();
executor
=
Executors
.
newFixedThreadPool
(
1
,
new
DefaultThreadFactory
(
"mock-zookeeper"
));
if
(
executor
!=
null
)
{
this
.
executor
=
executor
;
}
else
{
this
.
executor
=
Executors
.
newFixedThreadPool
(
1
,
new
DefaultThreadFactory
(
"mock-zookeeper"
));
}
SetMultimap
<
String
,
Watcher
>
w
=
HashMultimap
.
create
();
watchers
=
Multimaps
.
synchronizedSetMultimap
(
w
);
stopped
=
false
;
...
...
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
浏览文件 @
c68e8bc2
...
...
@@ -37,6 +37,7 @@ import org.apache.zookeeper.MockZooKeeper;
import
org.apache.zookeeper.ZooKeeper
;
import
org.apache.zookeeper.data.ACL
;
import
com.google.common.util.concurrent.MoreExecutors
;
import
com.yahoo.pulsar.broker.BookKeeperClientFactory
;
import
com.yahoo.pulsar.broker.PulsarService
;
import
com.yahoo.pulsar.broker.ServiceConfiguration
;
...
...
@@ -148,7 +149,7 @@ public abstract class MockedPulsarServiceBaseTest {
}
private
MockZooKeeper
createMockZooKeeper
()
throws
Exception
{
MockZooKeeper
zk
=
MockZooKeeper
.
newInstance
();
MockZooKeeper
zk
=
MockZooKeeper
.
newInstance
(
MoreExecutors
.
sameThreadExecutor
()
);
List
<
ACL
>
dummyAclList
=
new
ArrayList
<
ACL
>(
0
);
ZkUtils
.
createFullPathOptimistic
(
zk
,
"/ledgers/available/192.168.1.1:"
+
5000
,
...
...
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/service/ServerCnxTest.java
浏览文件 @
c68e8bc2
...
...
@@ -615,6 +615,19 @@ public class ServerCnxTest {
resetChannel
();
setChannelConnected
();
// Delay the topic creation in a deterministic way
CountDownLatch
successTopicCreationDelayLatch
=
new
CountDownLatch
(
1
);
doAnswer
(
new
Answer
<
Object
>()
{
@Override
public
Object
answer
(
InvocationOnMock
invocationOnMock
)
throws
Throwable
{
successTopicCreationDelayLatch
.
await
();
((
OpenLedgerCallback
)
invocationOnMock
.
getArguments
()[
2
]).
openLedgerComplete
(
ledgerMock
,
null
);
return
null
;
}
}).
when
(
mlFactoryMock
).
asyncOpen
(
matches
(
".*success.*"
),
any
(
ManagedLedgerConfig
.
class
),
any
(
OpenLedgerCallback
.
class
),
anyObject
());
// In a create producer timeout from client side we expect to see this sequence of commands :
// 1. create producer
// 2. close producer (when the timeout is triggered, which may be before the producer was created on the broker
...
...
@@ -636,6 +649,8 @@ public class ServerCnxTest {
producerName
);
channel
.
writeInbound
(
createProducer2
);
successTopicCreationDelayLatch
.
countDown
();
// Close succeeds
Object
response
=
getResponse
();
assertEquals
(
response
.
getClass
(),
CommandSuccess
.
class
);
...
...
@@ -653,7 +668,7 @@ public class ServerCnxTest {
channel
.
finish
();
}
@Test
(
timeOut
=
30000
)
@Test
(
timeOut
=
30000
,
enabled
=
false
)
public
void
testCreateProducerMultipleTimeouts
()
throws
Exception
{
resetChannel
();
setChannelConnected
();
...
...
pulsar-zookeeper-utils/src/test/java/com/yahoo/pulsar/zookeeper/ZookeeperCacheTest.java
浏览文件 @
c68e8bc2
...
...
@@ -23,6 +23,7 @@ import static org.testng.AssertJUnit.assertNull;
import
java.util.Set
;
import
java.util.TreeSet
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ScheduledThreadPoolExecutor
;
import
java.util.concurrent.atomic.AtomicInteger
;
...
...
@@ -41,6 +42,7 @@ import org.testng.annotations.Test;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Sets
;
import
com.google.common.util.concurrent.MoreExecutors
;
@Test
public
class
ZookeeperCacheTest
{
...
...
@@ -48,7 +50,7 @@ public class ZookeeperCacheTest {
@BeforeMethod
void
setup
()
throws
Exception
{
zkClient
=
MockZooKeeper
.
newInstance
();
zkClient
=
MockZooKeeper
.
newInstance
(
MoreExecutors
.
sameThreadExecutor
()
);
}
@AfterMethod
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录