forked from h2oai/h2o-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_exec_result_race.py
81 lines (68 loc) · 2.51 KB
/
test_exec_result_race.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
import unittest
import random, sys, time, os
sys.path.extend(['.','..','py'])
import h2o, h2o_cmd, h2o_hosts, h2o_browse as h2b, h2o_import as h2i, h2o_exec as h2e
initList = [
'Result.hex = 0',
'Result.hex = 1',
'Result.hex = 2',
'Result.hex = 3',
'Result.hex = 4',
'Result.hex = 5',
'Result.hex = 6',
'Result.hex = 7',
'Result.hex = 8',
'Result.hex = 9',
'Result.hex = 10',
]
exprList = [
'Result.hex = Result.hex + 1',
]
class Basic(unittest.TestCase):
def tearDown(self):
h2o.check_sandbox_for_errors()
@classmethod
def setUpClass(cls):
# random.seed(SEED)
SEED = random.randint(0, sys.maxint)
# if you have to force to redo a test
# SEED =
random.seed(SEED)
print "\nUsing random seed:", SEED
localhost = h2o.decide_if_localhost()
if (localhost):
h2o.build_cloud(1)
else:
h2o_hosts.build_cloud_with_hosts()
@classmethod
def tearDownClass(cls):
# wait while I inspect things
# time.sleep(1500)
h2o.tear_down_cloud()
def test_exec_result_race(self):
### h2b.browseTheCloud()
lenNodes = len(h2o.nodes)
# zero the list of Results using node[0]
# FIX! is the zerolist not eing seen correctl? is it not initializing to non-zero?
for execExpr in initList:
h2e.exec_expr(h2o.nodes[0], execExpr, resultKey="Result.hex", timeoutSecs=4)
### print "\nexecResult:", execResult
trial = 0
while (trial < 200):
for exprExpr in exprList:
# for the first 100 trials: do each expression at node 0,
# for the second 100 trials: do each expression at a random node, to facilate key movement
# FIX! there's some problem with the initList not taking if rotated amongst nodes?
if (trial < 100):
nodeX = 0
else:
nodeX = random.randint(0,lenNodes-1)
resultKey = "Result.hex"
execResultInspect, min_value = h2e.exec_expr(h2o.nodes[nodeX], execExpr,
resultKey=resultKey, timeoutSecs=4)
print min_value, execExpr
h2o.verboseprint("min_value: ", min_value, "trial:", trial)
### h2b.browseJsonHistoryAsUrlLastMatch("Inspect")
trial += 1
if __name__ == '__main__':
h2o.unit_main()