Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
07734944
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
07734944
编写于
5月 22, 2018
作者:
C
Ciju John
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add test for hard replay.
上级
4938c6d0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
83 addition
and
50 deletion
+83
-50
tests/CMakeLists.txt
tests/CMakeLists.txt
+1
-0
tests/restart-scenarios-test.py
tests/restart-scenarios-test.py
+17
-11
tests/testUtils.py
tests/testUtils.py
+65
-39
未找到文件。
tests/CMakeLists.txt
浏览文件 @
07734944
...
...
@@ -56,6 +56,7 @@ add_test(NAME distributed-transactions-test COMMAND tests/distributed-transactio
add_test
(
NAME distributed-transactions-remote-test COMMAND tests/distributed-transactions-remote-test.py -v --dump-error-detail WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
# TODO removed on slim: add_test(NAME restart-scenarios-test_resync COMMAND tests/restart-scenarios-test.py -c resync -p4 -v --dump-error-details WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# add_test(NAME restart-scenarios-test_replay COMMAND tests/restart-scenarios-test.py -c replay -p4 -v --dump-error-details WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test
(
NAME restart-scenarios-test_hard_replay COMMAND tests/restart-scenarios-test.py -c hardReplay -p4 -v --dump-error-details WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
# TODO: add_test(NAME consensus-validation-malicious-producers COMMAND tests/consensus-validation-malicious-producers.py -w 80 --dump-error-details WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
if
(
ENABLE_COVERAGE_TESTING
)
...
...
tests/restart-scenarios-test.py
浏览文件 @
07734944
...
...
@@ -65,8 +65,8 @@ testSuccessful=False
random
.
seed
(
seed
)
# Use a fixed seed for repeatability.
cluster
=
testUtils
.
Cluster
()
walletMgr
=
testUtils
.
WalletMgr
(
Fals
e
)
cluster
=
testUtils
.
Cluster
(
walletd
=
True
)
walletMgr
=
testUtils
.
WalletMgr
(
Tru
e
)
try
:
cluster
.
setChainStrategy
(
chainSyncStrategyStr
)
...
...
@@ -87,6 +87,12 @@ try:
if
not
cluster
.
waitOnClusterBlockNumSync
(
3
):
errorExit
(
"Cluster never stabilized"
)
Print
(
"Stand up EOS wallet keosd"
)
walletMgr
.
killall
()
walletMgr
.
cleanup
()
if
walletMgr
.
launch
()
is
False
:
errorExit
(
"Failed to stand up keosd."
)
accountsCount
=
total_nodes
walletName
=
"MyWallet"
Print
(
"Creating wallet %s if one doesn't already exist."
%
walletName
)
...
...
@@ -115,9 +121,9 @@ try:
# TBD: Known issue (Issue 2043) that 'get currency0000 balance' doesn't return balance.
# Uncomment when functional
#
Print("Spread funds and validate")
#
if not cluster.spreadFundsAndValidate(10):
#
errorExit("Failed to spread and validate funds.")
Print
(
"Spread funds and validate"
)
if
not
cluster
.
spreadFundsAndValidate
(
10
):
errorExit
(
"Failed to spread and validate funds."
)
Print
(
"Wait on cluster sync."
)
if
not
cluster
.
waitOnClusterSync
():
...
...
@@ -130,9 +136,9 @@ try:
# TBD: Known issue (Issue 2043) that 'get currency0000 balance' doesn't return balance.
# Uncomment when functional
#
Print("Spread funds and validate")
#
if not cluster.spreadFundsAndValidate(10):
#
errorExit("Failed to spread and validate funds.")
Print
(
"Spread funds and validate"
)
if
not
cluster
.
spreadFundsAndValidate
(
10
):
errorExit
(
"Failed to spread and validate funds."
)
Print
(
"Wait on cluster sync."
)
if
not
cluster
.
waitOnClusterSync
():
...
...
@@ -150,9 +156,9 @@ try:
# TBD: Known issue (Issue 2043) that 'get currency0000 balance' doesn't return balance.
# Uncomment when functional
#
Print("Spread funds and validate")
#
if not cluster.spreadFundsAndValidate(10):
#
errorExit("Failed to spread and validate funds.")
Print
(
"Spread funds and validate"
)
if
not
cluster
.
spreadFundsAndValidate
(
10
):
errorExit
(
"Failed to spread and validate funds."
)
Print
(
"Wait on cluster sync."
)
if
not
cluster
.
waitOnClusterSync
():
...
...
tests/testUtils.py
浏览文件 @
07734944
...
...
@@ -16,6 +16,7 @@ import sys
import
random
import
json
import
shlex
from
sys
import
stdout
from
core_symbol
import
CORE_SYMBOL
...
...
@@ -39,7 +40,7 @@ class Utils:
def
Print
(
*
args
,
**
kwargs
):
stackDepth
=
len
(
inspect
.
stack
())
-
2
s
=
' '
*
stackDepth
s
ys
.
s
tdout
.
write
(
s
)
stdout
.
write
(
s
)
print
(
*
args
,
**
kwargs
)
SyncStrategy
=
namedtuple
(
"ChainSyncStrategy"
,
"name id arg"
)
...
...
@@ -47,6 +48,7 @@ class Utils:
SyncNoneTag
=
"none"
SyncReplayTag
=
"replay"
SyncResyncTag
=
"resync"
SyncHardReplayTag
=
"hardReplay"
SigKillTag
=
"kill"
SigTermTag
=
"term"
...
...
@@ -78,6 +80,9 @@ class Utils:
chainSyncStrategy
=
Utils
.
SyncStrategy
(
Utils
.
SyncResyncTag
,
2
,
"--delete-all-blocks"
)
chainSyncStrategies
[
chainSyncStrategy
.
name
]
=
chainSyncStrategy
chainSyncStrategy
=
Utils
.
SyncStrategy
(
Utils
.
SyncHardReplayTag
,
3
,
"--hard-replay-blockchain"
)
chainSyncStrategies
[
chainSyncStrategy
.
name
]
=
chainSyncStrategy
return
chainSyncStrategies
@
staticmethod
...
...
@@ -98,14 +103,24 @@ class Utils:
timeout
=
60
endTime
=
time
.
time
()
+
timeout
while
endTime
>
time
.
time
():
ret
=
lam
()
if
ret
is
not
None
:
return
ret
sleepTime
=
3
Utils
.
Print
(
"cmd: sleep %d seconds, remaining time: %d seconds"
%
(
sleepTime
,
endTime
-
time
.
time
()))
time
.
sleep
(
sleepTime
)
needsNewLine
=
False
try
:
while
endTime
>
time
.
time
():
ret
=
lam
()
if
ret
is
not
None
:
return
ret
sleepTime
=
3
if
Utils
.
Debug
:
Utils
.
Print
(
"cmd: sleep %d seconds, remaining time: %d seconds"
%
(
sleepTime
,
endTime
-
time
.
time
()))
else
:
stdout
.
write
(
'.'
)
stdout
.
flush
()
needsNewLine
=
True
time
.
sleep
(
sleepTime
)
finally
:
if
needsNewLine
:
Utils
.
Print
()
return
None
...
...
@@ -170,16 +185,17 @@ class Node(object):
assert
trans
[
"processed"
][
"receipt"
][
"status"
]
==
"executed"
,
printTrans
(
trans
)
@
staticmethod
def
runCmdReturnJson
(
cmd
,
trace
=
False
):
def
runCmdReturnJson
(
cmd
,
trace
=
False
,
silentErrors
=
False
):
cmdArr
=
shlex
.
split
(
cmd
)
retStr
=
Utils
.
checkOutput
(
cmdArr
)
jStr
=
Node
.
filterJsonObject
(
retStr
)
if
trace
:
Utils
.
Print
(
"RAW > %s"
%
(
retStr
))
if
trace
:
Utils
.
Print
(
"JSON> %s"
%
(
jStr
))
if
not
jStr
:
msg
=
"Expected JSON response"
Utils
.
Print
(
"ERROR: "
+
msg
)
Utils
.
Print
(
"RAW > %s"
%
retStr
)
msg
=
"Received empty JSON response"
if
not
silentErrors
:
Utils
.
Print
(
"ERROR: "
+
msg
)
Utils
.
Print
(
"RAW > %s"
%
retStr
)
raise
TypeError
(
msg
)
try
:
...
...
@@ -448,7 +464,7 @@ class Node(object):
Utils
.
Print
(
"transaction parsing failed. Transaction: %s"
%
(
trans
))
raise
headBlockNum
=
self
.
get
Irreversible
BlockNum
()
headBlockNum
=
self
.
get
Head
BlockNum
()
assert
(
headBlockNum
)
try
:
headBlockNum
=
int
(
headBlockNum
)
...
...
@@ -1000,7 +1016,7 @@ class Node(object):
cmd
=
"%s %s get info"
%
(
Utils
.
EosClientPath
,
self
.
endpointArgs
)
if
Utils
.
Debug
:
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
try
:
trans
=
Node
.
runCmdReturnJson
(
cmd
)
trans
=
Node
.
runCmdReturnJson
(
cmd
,
silentErrors
=
silentErrors
)
return
trans
except
subprocess
.
CalledProcessError
as
ex
:
if
not
silentErrors
:
...
...
@@ -1077,34 +1093,44 @@ class Node(object):
return
True
# TBD: make nodeId an internal property
def
relaunch
(
self
,
nodeId
,
chainArg
):
def
relaunch
(
self
,
nodeId
,
chainArg
,
timeout
=
Utils
.
systemWaitTimeout
):
assert
(
self
.
pid
is
None
)
assert
(
self
.
killed
)
if
Utils
.
Debug
:
Utils
.
Print
(
"Launching node process, Id: %d"
%
(
nodeId
))
dataDir
=
"var/lib/node_%02d"
%
(
nodeId
)
dt
=
datetime
.
datetime
.
now
()
dateStr
=
"%d_%02d_%02d_%02d_%02d_%02d"
%
(
dt
.
year
,
dt
.
month
,
dt
.
day
,
dt
.
hour
,
dt
.
minute
,
dt
.
second
)
stdoutFile
=
"%s/stdout.%s.txt"
%
(
dataDir
,
dateStr
)
stderrFile
=
"%s/stderr.%s.txt"
%
(
dataDir
,
dateStr
)
with
open
(
stdoutFile
,
'w'
)
as
sout
,
open
(
stderrFile
,
'w'
)
as
serr
:
cmd
=
self
.
cmd
+
(
""
if
chainArg
is
None
else
(
" "
+
chainArg
))
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
popen
=
subprocess
.
Popen
(
cmd
.
split
(),
stdout
=
sout
,
stderr
=
serr
)
self
.
pid
=
popen
.
pid
running
=
True
try
:
os
.
kill
(
self
.
pid
,
0
)
#check if process with pid is running
except
OSError
as
_
:
running
=
False
def
isNodeAlive
():
"""wait for node to be responsive."""
try
:
return
True
if
self
.
checkPulse
()
else
False
except
(
TypeError
)
as
_
:
pass
return
False
if
running
:
Utils
.
Print
(
"WARNING: A process with pid (%d) is already running."
%
(
self
.
pid
))
isAlive
=
Utils
.
waitForBool
(
isNodeAlive
,
timeout
)
if
isAlive
:
Utils
.
Print
(
"Node relaunch was successfull."
)
else
:
if
Utils
.
Debug
:
Utils
.
Print
(
"Launching node process, Id: %d"
%
(
nodeId
))
dataDir
=
"var/lib/node_%02d"
%
(
nodeId
)
dt
=
datetime
.
datetime
.
now
()
dateStr
=
"%d_%02d_%02d_%02d_%02d_%02d"
%
(
dt
.
year
,
dt
.
month
,
dt
.
day
,
dt
.
hour
,
dt
.
minute
,
dt
.
second
)
stdoutFile
=
"%s/stdout.%s.txt"
%
(
dataDir
,
dateStr
)
stderrFile
=
"%s/stderr.%s.txt"
%
(
dataDir
,
dateStr
)
with
open
(
stdoutFile
,
'w'
)
as
sout
,
open
(
stderrFile
,
'w'
)
as
serr
:
cmd
=
self
.
cmd
+
(
""
if
chainArg
is
None
else
(
" "
+
chainArg
))
Utils
.
Print
(
"cmd: %s"
%
(
cmd
))
popen
=
subprocess
.
Popen
(
cmd
.
split
(),
stdout
=
sout
,
stderr
=
serr
)
self
.
pid
=
popen
.
pid
Utils
.
Print
(
"ERROR: Node relaunch Failed."
)
self
.
pid
=
None
return
False
self
.
killed
=
False
return
True
###########################################################################################
Wallet
=
namedtuple
(
"Wallet"
,
"name password host port"
)
...
...
@@ -1724,7 +1750,7 @@ class Cluster(object):
Utils
.
Print
(
"ERROR: Failed to spread funds across nodes."
)
return
False
Utils
.
Print
(
"Funds spread across all accounts. No
e
w validate funds"
)
Utils
.
Print
(
"Funds spread across all accounts. Now validate funds"
)
if
False
==
self
.
validateSpreadFunds
(
initialBalances
,
transferAmount
,
self
.
defproduceraAccount
,
self
.
accounts
):
Utils
.
Print
(
"ERROR: Failed to validate funds transfer across nodes."
)
...
...
@@ -2155,7 +2181,7 @@ class Cluster(object):
for
i
in
range
(
0
,
len
(
self
.
nodes
)):
node
=
self
.
nodes
[
i
]
if
not
node
.
relaunch
(
i
,
chainArg
):
if
no
de
.
killed
and
no
t
node
.
relaunch
(
i
,
chainArg
):
return
False
return
True
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录