Skip to content

Commit 78d1439

Browse files
authored
Add simple stability test for olap queries (#7543)
1 parent 0ddb5fb commit 78d1439

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

ydb/tools/cfg/static.py

+7
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ def mbus_enabled(self):
274274
@property
275275
def table_service_config(self):
276276
return self.__cluster_details.get_service("table_service_config")
277+
278+
@property
279+
def column_shard_config(self):
280+
return self.__cluster_details.get_service("column_shard_config")
277281

278282
@property
279283
def hive_config(self):
@@ -386,6 +390,9 @@ def get_normalized_config(self):
386390
if self.table_service_config:
387391
normalized_config["table_service_config"] = self.table_service_config
388392

393+
if self.column_shard_config:
394+
normalized_config["column_shard_config"] = self.column_shard_config
395+
389396
if self.__cluster_details.blob_storage_config is not None:
390397
normalized_config["blob_storage_config"] = self.__cluster_details.blob_storage_config
391398
else:

ydb/tools/olap_workload/__main__.py

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# -*- coding: utf-8 -*-
2+
import argparse
3+
import ydb
4+
import time
5+
import os
6+
7+
ydb.interceptor.monkey_patch_event_handler()
8+
9+
10+
def timestamp():
11+
return int(1000 * time.time())
12+
13+
14+
def table_name_with_timestamp():
15+
return os.path.join("column_table_" + str(timestamp()))
16+
17+
18+
class Workload(object):
19+
def __init__(self, endpoint, database, duration):
20+
self.database = database
21+
self.driver = ydb.Driver(ydb.DriverConfig(endpoint, database))
22+
self.pool = ydb.SessionPool(self.driver, size=200)
23+
self.duration = duration
24+
25+
def __enter__(self):
26+
return self
27+
28+
def __exit__(self, exc_type, exc_val, exc_tb):
29+
self.pool.stop()
30+
self.driver.stop()
31+
32+
def create_table(self, table_name):
33+
with self.pool.checkout() as s:
34+
try:
35+
s.execute_scheme(
36+
"""
37+
CREATE TABLE %s (
38+
id Int64 NOT NULL,
39+
i64Val Int64,
40+
PRIMARY KEY(id)
41+
)
42+
PARTITION BY HASH(id)
43+
WITH (
44+
STORE = COLUMN
45+
)
46+
"""
47+
% table_name
48+
)
49+
50+
print("Table %s created" % table_name)
51+
except ydb.SchemeError as e:
52+
print(e)
53+
54+
def drop_table(self, table_name):
55+
with self.pool.checkout() as s:
56+
try:
57+
s.drop_table(self.database + "/" + table_name)
58+
59+
print("Table %s dropped" % table_name)
60+
except ydb.SchemeError as e:
61+
print(e)
62+
63+
def run(self):
64+
started_at = time.time()
65+
66+
while time.time() - started_at < self.duration:
67+
table_name = table_name_with_timestamp()
68+
self.create_table(table_name)
69+
70+
time.sleep(5)
71+
72+
self.drop_table(table_name)
73+
74+
75+
if __name__ == '__main__':
76+
parser = argparse.ArgumentParser(
77+
description="olap stability workload", formatter_class=argparse.RawDescriptionHelpFormatter
78+
)
79+
parser.add_argument('--endpoint', default='localhost:2135', help="An endpoint to be used")
80+
parser.add_argument('--database', default=None, required=True, help='A database to connect')
81+
parser.add_argument('--duration', default=10**9, type=lambda x: int(x), help='A duration of workload in seconds.')
82+
args = parser.parse_args()
83+
with Workload(args.endpoint, args.database, args.duration) as workload:
84+
workload.run()

ydb/tools/olap_workload/ya.make

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
PY3_PROGRAM(olap_workload)
2+
3+
PY_SRCS(
4+
__main__.py
5+
)
6+
7+
PEERDIR(
8+
ydb/public/sdk/python
9+
library/python/monlib
10+
)
11+
12+
END()

ydb/tools/ya.make

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ RECURSE(
44
query_replay
55
query_replay_yt
66
simple_queue
7+
olap_workload
78
tsserver
89
tstool
910
ydbd_slice

0 commit comments

Comments
 (0)