-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdistributed-transactions-remote-test.py
executable file
·91 lines (73 loc) · 2.85 KB
/
distributed-transactions-remote-test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env python3
from testUtils import Utils
from Cluster import Cluster
from TestHelper import TestHelper
import subprocess
import tempfile
import os
###############################################################
# distributed-transactions-remote-test
# Tests remote capability of the distributed-transactions-test. Test will setup cluster and pass nodes info to distributed-transactions-test. E.g.
# distributed-transactions-remote-test.py -v --clean-run --dump-error-detail
###############################################################
Print=Utils.Print
errorExit=Utils.errorExit
args = TestHelper.parse_args({"-p","--dump-error-details","-v","--leave-running","--clean-run"})
pnodes=args.p
debug=args.v
dontKill=args.leave_running
dumpErrorDetails=args.dump_error_details
killAll=args.clean_run
Utils.Debug=debug
killEosInstances=not dontKill
topo="mesh"
delay=1
prodCount=1 # producers per producer node
total_nodes=pnodes+3
actualTest="tests/distributed-transactions-test.py"
testSuccessful=False
clusterMapJsonTemplate="""{
"keys": {
"defproduceraPrivateKey": "%s",
"defproducerbPrivateKey": "%s"
},
"nodes": [
{"port": 8888, "host": "localhost"},
{"port": 8889, "host": "localhost"},
{"port": 8890, "host": "localhost"}
]
}
"""
cluster=Cluster(walletd=True)
(fd, nodesFile) = tempfile.mkstemp()
try:
TestHelper.printSystemInfo("BEGIN")
cluster.killall(allInstances=killAll)
cluster.cleanup()
Print ("producing nodes: %s, non-producing nodes: %d, topology: %s, delay between nodes launch(seconds): %d" %
(pnodes, total_nodes-pnodes, topo, delay))
Print("Stand up cluster")
if cluster.launch(pnodes=pnodes, totalNodes=total_nodes, prodCount=prodCount, topo=topo, delay=delay) is False:
errorExit("Failed to stand up eos cluster.")
Print ("Wait for Cluster stabilization")
# wait for cluster to start producing blocks
if not cluster.waitOnClusterBlockNumSync(3):
errorExit("Cluster never stabilized")
producerKeys=Cluster.parseClusterKeys(total_nodes)
defproduceraPrvtKey=producerKeys["defproducera"]["private"]
defproducerbPrvtKey=producerKeys["defproducerb"]["private"]
clusterMapJson = clusterMapJsonTemplate % (defproduceraPrvtKey, defproducerbPrvtKey)
tfile = os.fdopen(fd, "w")
tfile.write(clusterMapJson)
tfile.close()
cmd="%s --nodes-file %s %s %s" % (actualTest, nodesFile, "-v" if debug else "", "--leave-running" if dontKill else "")
Print("Starting up distributed transactions test: %s" % (actualTest))
Print("cmd: %s\n" % (cmd))
if 0 != subprocess.call(cmd, shell=True):
errorExit("failed to run cmd.")
testSuccessful=True
Print("\nEND")
finally:
os.remove(nodesFile)
TestHelper.shutdown(cluster, None, testSuccessful, killEosInstances, False, False, killAll, dumpErrorDetails)
exit(0)