Skip to content

Commit 2be2ee9

Browse files
authored
Add commands into stability/library (#12823)
1 parent bc46b2c commit 2be2ee9

File tree

1 file changed

+68
-31
lines changed

1 file changed

+68
-31
lines changed

ydb/tests/stability/library/__main__.py

Lines changed: 68 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
logging.getLogger().setLevel(logging.DEBUG)
1414
logging.getLogger().addHandler(logging.StreamHandler(sys.stderr))
1515

16-
from ydb.tests.library.common.composite_assert import CompositeAssert # noqa
1716
from ydb.tests.library.harness.kikimr_cluster import ExternalKiKiMRCluster # noqa
18-
from ydb.tests.library.matchers.collection import is_empty # noqa
1917
from ydb.tests.library.wardens.factories import safety_warden_factory, liveness_warden_factory # noqa
2018

2119
logger = logging.getLogger('ydb.connection')
@@ -61,6 +59,27 @@ def _unpack_resource(self, name):
6159
os.chmod(path_to_unpack, st.st_mode | stat.S_IEXEC)
6260
return path_to_unpack
6361

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+
6483
def start_nemesis(self):
6584
for node in self.kikimr_cluster.nodes.values():
6685
node.ssh_command("sudo service nemesis restart", raise_on_error=True)
@@ -69,18 +88,18 @@ def stop_nemesis(self):
6988
for node in self.kikimr_cluster.nodes.values():
7089
node.ssh_command("sudo service nemesis stop", raise_on_error=False)
7190

72-
def setup(self, is_deploy_cluster):
91+
def deploy_ydb(self):
7392
self._stop_nemesis()
7493
self.kikimr_cluster.start()
7594

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())
81102

82-
with open(self._unpack_resource("tbl_profile.txt")) as f:
83-
self.kikimr_cluster.client.console_request(f.read())
84103
self.kikimr_cluster.client.update_self_heal(True)
85104

86105
node = list(self.kikimr_cluster.nodes.values())[0]
@@ -99,6 +118,20 @@ def setup(self, is_deploy_cluster):
99118
)
100119
)
101120

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+
102135

103136
def path_type(path):
104137
# Expand the user's home directory if ~ is present
@@ -137,9 +170,13 @@ def parse_args():
137170
type=str,
138171
nargs="+",
139172
choices=[
173+
"deploy_ydb",
174+
"deploy_tools",
140175
"start_nemesis",
141176
"stop_nemesis",
142-
"start_workload_simple_queue",
177+
"start_workload_simple_queue_row",
178+
"start_workload_simple_queue_column",
179+
"start_workload_olap_workload",
143180
"stop_workload",
144181
"perform_checks",
145182
],
@@ -158,14 +195,26 @@ def main():
158195
)
159196

160197
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":
166215
for node_id, node in enumerate(stability_cluster.kikimr_cluster.nodes.values()):
167216
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"',
169218
raise_on_error=True
170219
)
171220
if action == "stop_workload":
@@ -182,20 +231,8 @@ def main():
182231
stability_cluster.start_nemesis()
183232

184233
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)
199236

200237

201238
if __name__ == "__main__":

0 commit comments

Comments
 (0)