12
12
from lib .bank_client import MtmClient
13
13
from lib .failure_injector import *
14
14
15
+ TEST_WARMING_TIME = 5
15
16
TEST_DURATION = 10
16
- TEST_RECOVERY_TIME = 20
17
+ TEST_RECOVERY_TIME = 30
18
+ TEST_SETUP_TIME = 20
17
19
18
20
class TestHelper (object ):
19
21
@@ -39,6 +41,11 @@ def assertNoCommits(self, aggs):
39
41
raise AssertionError ('There are commits during aggregation interval' )
40
42
41
43
def performFailure (self , failure ):
44
+
45
+ time .sleep (TEST_WARMING_TIME )
46
+
47
+ print ('Simulate failure at ' ,datetime .datetime .utcnow ())
48
+
42
49
failure .start ()
43
50
44
51
self .client .clean_aggregates ()
@@ -47,6 +54,8 @@ def performFailure(self, failure):
47
54
48
55
failure .stop ()
49
56
57
+ print ('Eliminate failure at ' ,datetime .datetime .utcnow ())
58
+
50
59
self .client .clean_aggregates ()
51
60
time .sleep (TEST_RECOVERY_TIME )
52
61
aggs = self .client .get_aggregates ()
@@ -60,11 +69,12 @@ class RecoveryTest(unittest.TestCase, TestHelper):
60
69
def setUpClass (self ):
61
70
subprocess .check_call (['docker-compose' ,'up' ,
62
71
'--force-recreate' ,
72
+ '--build' ,
63
73
'-d' ])
64
74
65
75
# XXX: add normal wait here
66
- time .sleep (20 )
67
- print ( 'started' )
76
+ time .sleep (TEST_SETUP_TIME )
77
+
68
78
self .client = MtmClient ([
69
79
"dbname=regression user=postgres host=127.0.0.1 port=15432" ,
70
80
"dbname=regression user=postgres host=127.0.0.1 port=15433" ,
@@ -81,6 +91,11 @@ def tearDownClass(self):
81
91
82
92
def setUp (self ):
83
93
warnings .simplefilter ("ignore" , ResourceWarning )
94
+ time .sleep (20 )
95
+ print ('Start new test at ' ,datetime .datetime .utcnow ())
96
+
97
+ def tearDown (self ):
98
+ print ('Finish test at ' ,datetime .datetime .utcnow ())
84
99
85
100
def test_normal_operations (self ):
86
101
print ('### test_normal_operations ###' )
@@ -122,8 +137,6 @@ def test_edge_partition(self):
122
137
def test_node_restart (self ):
123
138
print ('### test_node_restart ###' )
124
139
125
- time .sleep (3 )
126
-
127
140
aggs_failure , aggs = self .performFailure (RestartNode ('node3' ))
128
141
129
142
self .assertCommits (aggs_failure [:2 ])
0 commit comments