Skip to content

Commit 18b8bd5

Browse files
committed
temp
1 parent e130c57 commit 18b8bd5

File tree

5 files changed

+64
-10
lines changed

5 files changed

+64
-10
lines changed

tests/slo/slo_runner.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
docker compose -f playground/configs/compose.yaml down -v
22
docker compose -f playground/configs/compose.yaml up -d --wait
33

4-
../../.venv/bin/python ./src topic-create grpc://localhost:2135 /Root/testdb --path /Root/testdb/slo_topic
4+
EXECUTOR="../../.venv/bin/python ./src"
55

6-
../../.venv/bin/python ./src topic-run grpc://localhost:2135 /Root/testdb --path /Root/testdb/slo_topic --prom-pgw "" --read-threads 0 --write-rps 1 --time 120
76

8-
# ../../.venv/bin/python ./src topic-run grpc://localhost:2135 /Root/testdb --path /Root/testdb/slo_topic --prom-pgw "" --read-threads 0 --time 5
9-
# ../../.venv/bin/python ./src topic-run grpc://localhost:2135 /Root/testdb --path /Root/testdb/slo_topic --prom-pgw "" --write-threads 0 --read-rps 1 --time 200
7+
# $EXECUTOR topic-create grpc://localhost:2135 /Root/testdb --path /Root/testdb/slo_topic
8+
# $EXECUTOR topic-run grpc://localhost:2135 /Root/testdb --path /Root/testdb/slo_topic --prom-pgw "" --read-threads 0 --write-rps 1 --time 120
9+
10+
$EXECUTOR topic-create grpc://localhost:2135 /Root/testdb --path /Root/testdb/slo_topic
11+
$EXECUTOR topic-run grpc://localhost:2135 /Root/testdb --path /Root/testdb/slo_topic --prom-pgw "" --read-threads 0 --write-rps 5 --time 60
12+
$EXECUTOR topic-run grpc://localhost:2135 /Root/testdb --path /Root/testdb/slo_topic --prom-pgw "" --write-threads 0 --read-rps 1 --time 60
13+
14+
# $EXECUTOR table-create grpc://localhost:2135 /Root/testdb
15+
# $EXECUTOR table-run grpc://localhost:2135 /Root/testdb --prom-pgw "" --read-rps 10 --write-threads 0 --read-threads 5 --time 600 --session-pool-size 1
16+
# $EXECUTOR table-cleanup grpc://localhost:2135 /Root/testdb

tests/slo/src/core/metrics.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,24 @@ def create_metrics(push_gateway) -> BaseMetrics:
4545

4646

4747
class DummyMetrics(BaseMetrics):
48+
def __init__(self):
49+
self._metrics = dict()
50+
4851
def start(self, labels):
52+
for label in labels:
53+
if label not in self._metrics:
54+
self._metrics[label] = {'success': 0, 'failure': 0}
4955
return 0
5056

5157
def stop(self, labels, start_time, attempts=1, error=None):
52-
pass
58+
for label in labels:
59+
if error:
60+
self._metrics[label]['failure'] += 1
61+
else:
62+
self._metrics[label]['success'] += 1
5363

5464
def reset(self):
55-
pass
65+
logger.info(f"Collected metrics: {self._metrics}")
5666

5767

5868
class Metrics(BaseMetrics):

tests/slo/src/jobs/table_jobs.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def transaction(session):
6565

6666
try:
6767
params.pool.retry_operation_sync(transaction, retry_settings=params.retry_settings)
68+
logger.info(f"Successfully executed query with params: {params.params}")
6869
except ydb.Error as err:
6970
error = err
7071
logger.exception("[labels: %s] Cannot retry error:", params.labels)
@@ -190,7 +191,7 @@ def _run_table_reads(self, query, limiter):
190191
max_session_acquire_timeout=self.args.read_timeout / 1000,
191192
)
192193

193-
with ydb.SessionPool(self.driver) as pool:
194+
with ydb.SessionPool(self.driver, size=self.args.session_pool_size) as pool:
194195
while time.time() - start_time < self.args.time:
195196
params = {"$object_id": randint(1, self.max_id)}
196197

@@ -225,7 +226,7 @@ def _run_table_writes(self, query, limiter):
225226

226227
row_generator = RowGenerator(self.max_id)
227228

228-
with ydb.SessionPool(self.driver) as pool:
229+
with ydb.SessionPool(self.driver, size=self.args.session_pool_size) as pool:
229230
while time.time() - start_time < self.args.time:
230231
row = row_generator.get()
231232
params = {
@@ -259,7 +260,7 @@ def _run_query_reads(self, query, limiter):
259260
max_session_acquire_timeout=self.args.read_timeout / 1000,
260261
)
261262

262-
with ydb.QuerySessionPool(self.driver) as pool:
263+
with ydb.QuerySessionPool(self.driver, size=self.args.session_pool_size) as pool:
263264
while time.time() - start_time < self.args.time:
264265
params = {"$object_id": (randint(1, self.max_id), ydb.PrimitiveType.Uint64)}
265266

@@ -295,7 +296,7 @@ def _run_query_writes(self, query, limiter):
295296

296297
row_generator = RowGenerator(self.max_id)
297298

298-
with ydb.QuerySessionPool(self.driver) as pool:
299+
with ydb.QuerySessionPool(self.driver, size=self.args.session_pool_size) as pool:
299300
while time.time() - start_time < self.args.time:
300301
row = row_generator.get()
301302
params = {

tests/slo/src/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def make_table_run_parser(subparsers):
3838
table_run_parser = subparsers.add_parser("table-run", help="Run table SLO workload")
3939
add_common_options(table_run_parser)
4040

41+
table_run_parser.add_argument("--session-pool-size", default=100, type=int, help="Session pool size")
4142
table_run_parser.add_argument("--read-rps", default=100, type=int, help="Read request rps")
4243
table_run_parser.add_argument(
4344
"--read-timeout", default=10000, type=int, help="Read requests execution timeout [ms]"

tests/table/table_test.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,38 @@ def select(session: ydb.Session):
6161

6262
pool = ydb.SessionPool(driver=driver_sync)
6363
pool.retry_operation_sync(select)
64+
65+
def test_async_read_table(self, driver_sync, database):
66+
table_path = database + "/test_table_to_read"
67+
68+
session: ydb.Session = ydb.retry_operation_sync(lambda: driver_sync.table_client.session().create())
69+
70+
try:
71+
session.drop_table(table_path)
72+
except ydb.issues.SchemeError:
73+
pass
74+
75+
description = (
76+
ydb.TableDescription()
77+
.with_primary_keys("key1")
78+
.with_columns(
79+
ydb.Column("key1", ydb.PrimitiveType.Uint64),
80+
ydb.Column("value", ydb.OptionalType(ydb.PrimitiveType.Utf8)),
81+
)
82+
)
83+
84+
session.create_table(table_path, description)
85+
86+
session.transaction().execute(
87+
"""INSERT INTO `test_table_to_read` (`key1`, `value`) VALUES (1, "hello_world"), (2, "2")""",
88+
commit_tx=True,
89+
)
90+
91+
iter = session.async_read_table(table_path)
92+
rows_cnt = 0
93+
for fut in iter:
94+
# item = fut
95+
item = fut.result(timeout=60)
96+
rows_cnt += len(item.rows)
97+
98+
assert rows_cnt == 2

0 commit comments

Comments
 (0)