13
13
logging .getLogger ().setLevel (logging .DEBUG )
14
14
logging .getLogger ().addHandler (logging .StreamHandler (sys .stderr ))
15
15
16
- from ydb .tests .library .common .composite_assert import CompositeAssert # noqa
17
16
from ydb .tests .library .harness .kikimr_cluster import ExternalKiKiMRCluster # noqa
18
- from ydb .tests .library .matchers .collection import is_empty # noqa
19
17
from ydb .tests .library .wardens .factories import safety_warden_factory , liveness_warden_factory # noqa
20
18
21
19
logger = logging .getLogger ('ydb.connection' )
@@ -61,6 +59,27 @@ def _unpack_resource(self, name):
61
59
os .chmod (path_to_unpack , st .st_mode | stat .S_IEXEC )
62
60
return path_to_unpack
63
61
62
+ def perform_checks (self ):
63
+ safety_violations = safety_warden_factory (self .kikimr_cluster , self .ssh_username ).list_of_safety_violations ()
64
+ liveness_violations = liveness_warden_factory (self .kikimr_cluster , self .ssh_username ).list_of_liveness_violations
65
+
66
+ count = 0
67
+ report = []
68
+
69
+ print ("SAFETY WARDEN (total: {})" .format (len (safety_violations )))
70
+ for i , violation in enumerate (safety_violations ):
71
+ print ("[{}]" .format (i ))
72
+ print (violation )
73
+ print ()
74
+
75
+ print ("LIVENESS WARDEN (total: {})" .format (len (liveness_violations )))
76
+ for i , violation in enumerate (liveness_violations ):
77
+ print ("[{}]" .format (i ))
78
+ print (violation )
79
+
80
+ print ()
81
+ return count , "\n " .join (report )
82
+
64
83
def start_nemesis (self ):
65
84
for node in self .kikimr_cluster .nodes .values ():
66
85
node .ssh_command ("sudo service nemesis restart" , raise_on_error = True )
@@ -69,18 +88,18 @@ def stop_nemesis(self):
69
88
for node in self .kikimr_cluster .nodes .values ():
70
89
node .ssh_command ("sudo service nemesis stop" , raise_on_error = False )
71
90
72
- def setup (self , is_deploy_cluster ):
91
+ def deploy_ydb (self ):
73
92
self ._stop_nemesis ()
74
93
self .kikimr_cluster .start ()
75
94
76
- if is_deploy_cluster :
77
- # cleanup nemesis logs
78
- for node in self .kikimr_cluster .nodes .values ():
79
- node .ssh_command ('sudo rm -rf /Berkanavt/nemesis/logs/*' , raise_on_error = False )
80
- node .ssh_command ('sudo pkill screen' , raise_on_error = False )
95
+ # cleanup nemesis logs
96
+ for node in self .kikimr_cluster .nodes .values ():
97
+ node .ssh_command ('sudo rm -rf /Berkanavt/nemesis/logs/*' , raise_on_error = False )
98
+ node .ssh_command ('sudo pkill screen' , raise_on_error = False )
99
+
100
+ with open (self ._unpack_resource ("tbl_profile.txt" )) as f :
101
+ self .kikimr_cluster .client .console_request (f .read ())
81
102
82
- with open (self ._unpack_resource ("tbl_profile.txt" )) as f :
83
- self .kikimr_cluster .client .console_request (f .read ())
84
103
self .kikimr_cluster .client .update_self_heal (True )
85
104
86
105
node = list (self .kikimr_cluster .nodes .values ())[0 ]
@@ -99,6 +118,20 @@ def setup(self, is_deploy_cluster):
99
118
)
100
119
)
101
120
121
+ def deploy_tools (self ):
122
+ for node in self .kikimr_cluster .nodes .values ():
123
+ node .ssh_command (["sudo" , "mkdir" , "-p" , STRESS_BINARIES_DEPLOY_PATH ], raise_on_error = False )
124
+ for artifact in self .artifacts :
125
+ node .copy_file_or_dir (
126
+ artifact ,
127
+ os .path .join (
128
+ STRESS_BINARIES_DEPLOY_PATH ,
129
+ os .path .basename (
130
+ artifact
131
+ )
132
+ )
133
+ )
134
+
102
135
103
136
def path_type (path ):
104
137
# Expand the user's home directory if ~ is present
@@ -137,9 +170,13 @@ def parse_args():
137
170
type = str ,
138
171
nargs = "+" ,
139
172
choices = [
173
+ "deploy_ydb" ,
174
+ "deploy_tools" ,
140
175
"start_nemesis" ,
141
176
"stop_nemesis" ,
142
- "start_workload_simple_queue" ,
177
+ "start_workload_simple_queue_row" ,
178
+ "start_workload_simple_queue_column" ,
179
+ "start_workload_olap_workload" ,
143
180
"stop_workload" ,
144
181
"perform_checks" ,
145
182
],
@@ -158,14 +195,26 @@ def main():
158
195
)
159
196
160
197
for action in args .actions :
161
- setup_command = False
162
- if setup_command :
163
- stability_cluster .setup (True )
164
-
165
- if action == "start_workload_simple_queue" :
198
+ if action == "deploy_ydb" :
199
+ stability_cluster .deploy_ydb ()
200
+ if action == "deploy_tools" :
201
+ stability_cluster .deploy_tools ()
202
+ if action == "start_workload_simple_queue_row" :
203
+ for node_id , node in enumerate (stability_cluster .kikimr_cluster .nodes .values ()):
204
+ node .ssh_command (
205
+ 'screen -d -m bash -c "while true; do /Berkanavt/nemesis/bin/simple_queue --database /Root/db1 --mode row; done"' ,
206
+ raise_on_error = True
207
+ )
208
+ if action == "start_workload_simple_queue_column" :
209
+ for node_id , node in enumerate (stability_cluster .kikimr_cluster .nodes .values ()):
210
+ node .ssh_command (
211
+ 'screen -d -m bash -c "while true; do /Berkanavt/nemesis/bin/simple_queue --database /Root/db1 --mode column; done"' ,
212
+ raise_on_error = True
213
+ )
214
+ if action == "start_workload_olap_workload" :
166
215
for node_id , node in enumerate (stability_cluster .kikimr_cluster .nodes .values ()):
167
216
node .ssh_command (
168
- 'screen -d -m bash -c "while true; do /Berkanavt/nemesis/bin/simple_queue --database /Root/db1 ; done"' ,
217
+ 'screen -d -m bash -c "while true; do /Berkanavt/nemesis/bin/olap_workload --database /Root/db1 --mode column ; done"' ,
169
218
raise_on_error = True
170
219
)
171
220
if action == "stop_workload" :
@@ -182,20 +231,8 @@ def main():
182
231
stability_cluster .start_nemesis ()
183
232
184
233
if action == "perform_checks" :
185
- composite_assert = CompositeAssert ()
186
- composite_assert .assert_that (
187
- safety_warden_factory (stability_cluster .kikimr_cluster , ssh_username ).list_of_safety_violations (),
188
- is_empty (),
189
- "No safety violations by Safety Warden"
190
- )
191
-
192
- composite_assert .assert_that (
193
- liveness_warden_factory (stability_cluster .kikimr_cluster , ssh_username ).list_of_liveness_violations ,
194
- is_empty (),
195
- "No liveness violations by liveness warden" ,
196
- )
197
-
198
- composite_assert .finish ()
234
+ count , report = stability_cluster .perform_checks ()
235
+ print (report )
199
236
200
237
201
238
if __name__ == "__main__" :
0 commit comments