Skip to content

Commit a9761dc

Browse files
authored
overlapping portions test has been added (#16381)
1 parent 38eb729 commit a9761dc

File tree

4 files changed

+135
-0
lines changed

4 files changed

+135
-0
lines changed

ydb/tests/library/harness/kikimr_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ def __init__(
163163
separate_node_configs=False,
164164
default_clusteradmin=None,
165165
enable_resource_pools=None,
166+
grouped_memory_limiter_config=None,
166167
):
167168
if extra_feature_flags is None:
168169
extra_feature_flags = []
@@ -354,6 +355,9 @@ def __init__(
354355
if column_shard_config:
355356
self.yaml_config["column_shard_config"] = column_shard_config
356357

358+
if grouped_memory_limiter_config:
359+
self.yaml_config["grouped_memory_limiter_config"] = grouped_memory_limiter_config
360+
357361
self.__build()
358362

359363
if self.grpc_ssl_enable:
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import datetime
2+
import logging
3+
import os
4+
import pytest
5+
import random
6+
import yatest.common
7+
import ydb
8+
9+
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
10+
from ydb.tests.library.harness.kikimr_runner import KiKiMR
11+
from ydb.tests.library.test_meta import link_test_case
12+
from ydb.tests.olap.common.ydb_client import YdbClient
13+
14+
logger = logging.getLogger(__name__)
15+
16+
17+
class TestOverlappingPortions(object):
18+
test_name = "overlapping_portions"
19+
20+
@classmethod
21+
def setup_class(cls):
22+
ydb_path = yatest.common.build_path(os.environ.get("YDB_DRIVER_BINARY"))
23+
logger.info(yatest.common.execute([ydb_path, "-V"], wait=True).stdout.decode("utf-8"))
24+
config = KikimrConfigGenerator(
25+
column_shard_config={"compaction_enabled": False},
26+
grouped_memory_limiter_config={
27+
"enabled": True,
28+
"memory_limit": 100 * 1024 * 1024,
29+
"hard_memory_limit": 100 * 1024 * 1024,
30+
},
31+
)
32+
cls.cluster = KiKiMR(config)
33+
cls.cluster.start()
34+
node = cls.cluster.nodes[1]
35+
cls.ydb_client = YdbClient(database=f"/{config.domain_name}", endpoint=f"grpc://{node.host}:{node.port}")
36+
cls.ydb_client.wait_connection()
37+
38+
def write_data(
39+
self,
40+
table: str,
41+
timestamp_from_ms: int,
42+
rows: int,
43+
value: int = 1,
44+
):
45+
column_types = ydb.BulkUpsertColumns()
46+
column_types.add_column("ts", ydb.PrimitiveType.Timestamp)
47+
column_types.add_column("s", ydb.PrimitiveType.String)
48+
column_types.add_column("val", ydb.PrimitiveType.Uint64)
49+
50+
chunk_size = 100
51+
while rows:
52+
current_chunk_size = min(chunk_size, rows)
53+
data = [
54+
{
55+
"ts": timestamp_from_ms + i,
56+
"s": random.randbytes(1024 * 10),
57+
"val": value,
58+
}
59+
for i in range(current_chunk_size)
60+
]
61+
self.ydb_client.bulk_upsert(
62+
table,
63+
column_types,
64+
data,
65+
)
66+
timestamp_from_ms += current_chunk_size
67+
rows -= current_chunk_size
68+
assert rows >= 0
69+
70+
def write_and_check(self, table_path, count):
71+
ts_start = int(datetime.datetime.now().timestamp() * 1000000)
72+
for value in range(count):
73+
self.write_data(table_path, ts_start, 100, value)
74+
75+
self.ydb_client.query(
76+
f"""
77+
select * from `{table_path}`
78+
"""
79+
)
80+
81+
@link_test_case("#15512")
82+
def test(self):
83+
test_dir = f"{self.ydb_client.database}/{self.test_name}"
84+
table_path = f"{test_dir}/table"
85+
86+
self.ydb_client.query(
87+
f"""
88+
CREATE TABLE `{table_path}` (
89+
ts Timestamp NOT NULL,
90+
s String,
91+
val Uint64,
92+
PRIMARY KEY(ts),
93+
)
94+
WITH (
95+
STORE = COLUMN,
96+
AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 1
97+
)
98+
"""
99+
)
100+
101+
self.write_and_check(table_path, 1)
102+
103+
with pytest.raises(ydb.issues.GenericError, match=r'.*cannot allocate memory.*'):
104+
self.write_and_check(table_path, 100)

ydb/tests/olap/oom/ya.make

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
PY3TEST()
2+
ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd")
3+
4+
FORK_TEST_FILES()
5+
6+
TEST_SRCS(
7+
overlapping_portions.py
8+
)
9+
10+
SIZE(MEDIUM)
11+
12+
PEERDIR(
13+
ydb/tests/library
14+
ydb/tests/library/test_meta
15+
ydb/public/sdk/python
16+
ydb/public/sdk/python/enable_v3_new_behavior
17+
library/recipes/common
18+
ydb/tests/olap/common
19+
)
20+
21+
DEPENDS(
22+
ydb/apps/ydbd
23+
)
24+
25+
END()
26+

ydb/tests/olap/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ RECURSE(
3232
high_load
3333
lib
3434
load
35+
oom
3536
s3_import
3637
scenario
3738
ttl_tiering

0 commit comments

Comments
 (0)