Skip to content

Commit 4f53f25

Browse files
authored
Introduce compatibility test (between last stable and main) (#9828)
1 parent a2aca67 commit 4f53f25

File tree

7 files changed

+151
-0
lines changed

7 files changed

+151
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# -*- coding: utf-8 -*-
2+
from ydb.tests.library.common import yatest_common
3+
from ydb.tests.library.harness.kikimr_cluster import KiKiMR
4+
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
5+
from ydb.tests.library.harness.param_constants import kikimr_driver_path
6+
from ydb.tests.library.common.types import Erasure
7+
from ydb.tests.oss.ydb_sdk_import import ydb
8+
9+
10+
class TestCompatibility(object):
11+
@classmethod
12+
def setup_class(cls):
13+
last_stable_path = yatest_common.binary_path("ydb/tests/library/compatibility/ydbd-last-stable")
14+
binary_paths = [kikimr_driver_path(), last_stable_path]
15+
cls.cluster = KiKiMR(KikimrConfigGenerator(erasure=Erasure.MIRROR_3_DC, binary_paths=binary_paths))
16+
cls.cluster.start()
17+
cls.endpoint = "%s:%s" % (
18+
cls.cluster.nodes[1].host, cls.cluster.nodes[1].port
19+
)
20+
cls.driver = ydb.Driver(
21+
ydb.DriverConfig(
22+
database='/Root',
23+
endpoint=cls.endpoint
24+
)
25+
)
26+
cls.driver.wait()
27+
28+
@classmethod
29+
def teardown_class(cls):
30+
if hasattr(cls, 'driver'):
31+
cls.driver.stop()
32+
33+
if hasattr(cls, 'cluster'):
34+
cls.cluster.stop(kill=True) # TODO fix
35+
36+
def test_simple(self):
37+
session = ydb.retry_operation_sync(lambda: self.driver.table_client.session().create())
38+
39+
with ydb.SessionPool(self.driver, size=1) as pool:
40+
with pool.checkout() as session:
41+
session.execute_scheme(
42+
"create table `sample_table` (id Uint64, value Uint64, payload Utf8, PRIMARY KEY(id)) WITH (AUTO_PARTITIONING_BY_SIZE = ENABLED, AUTO_PARTITIONING_PARTITION_SIZE_MB = 1);"
43+
)
44+
id_ = 0
45+
46+
upsert_count = 200
47+
iteration_count = 1
48+
for i in range(iteration_count):
49+
rows = []
50+
for j in range(upsert_count):
51+
row = {}
52+
row["id"] = id_
53+
row["value"] = 1
54+
row["payload"] = "DEADBEEF" * 1024 * 16 # 128 kb
55+
rows.append(row)
56+
id_ += 1
57+
58+
column_types = ydb.BulkUpsertColumns()
59+
column_types.add_column("id", ydb.PrimitiveType.Uint64)
60+
column_types.add_column("value", ydb.PrimitiveType.Uint64)
61+
column_types.add_column("payload", ydb.PrimitiveType.Utf8)
62+
self.driver.table_client.bulk_upsert(
63+
"Root/sample_table", rows, column_types
64+
)
65+
66+
query = "SELECT SUM(value) from sample_table"
67+
result_sets = session.transaction().execute(
68+
query, commit_tx=True
69+
)
70+
for row in result_sets[0].rows:
71+
print(" ".join([str(x) for x in list(row.values())]))
72+
73+
assert len(result_sets) == 1
74+
assert len(result_sets[0].rows) == 1
75+
result = list(result_sets[0].rows[0].values())
76+
assert len(result) == 1
77+
assert result[0] == upsert_count * iteration_count
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
PY3TEST()
2+
ENV(YDB_DRIVER_BINARY="ydb/apps/ydbd/ydbd")
3+
4+
TEST_SRCS(
5+
test_compatibility.py
6+
)
7+
8+
TIMEOUT(3600)
9+
SIZE(LARGE)
10+
TAG(ya:fat)
11+
12+
DEPENDS(
13+
ydb/apps/ydbd
14+
ydb/tests/library/compatibility
15+
)
16+
17+
PEERDIR(
18+
ydb/tests/library
19+
)
20+
21+
END()

ydb/tests/functional/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RECURSE(
77
canonical
88
clickbench
99
cms
10+
compatibility
1011
dynumber
1112
encryption
1213
hive
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import os
2+
import stat
3+
import sys
4+
5+
import boto3
6+
from botocore import UNSIGNED
7+
from botocore.client import Config
8+
9+
AWS_ENDPOINT = "https://storage.yandexcloud.net"
10+
AWS_BUCKET = "ydb-builds"
11+
12+
13+
def main():
14+
s3_client = boto3.client(
15+
service_name="s3",
16+
endpoint_url=AWS_ENDPOINT,
17+
config=Config(signature_version=UNSIGNED)
18+
)
19+
20+
s3_bucket = AWS_BUCKET
21+
remote_src = sys.argv[1]
22+
local_dst = sys.argv[2]
23+
s3_client.download_file(s3_bucket, remote_src, local_dst)
24+
25+
# chmod +x
26+
st = os.stat(local_dst)
27+
os.chmod(local_dst, st.st_mode | stat.S_IEXEC)
28+
29+
30+
if __name__ == "__main__":
31+
main()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PY3_PROGRAM()
2+
PEERDIR(
3+
contrib/python/boto3
4+
contrib/python/botocore
5+
)
6+
7+
PY_SRCS(
8+
__main__.py
9+
)
10+
END()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
UNION()
2+
3+
RUN_PROGRAM(
4+
ydb/tests/library/compatibility/downloader stable-24-3/relwithdebinfo/ydbd ydbd-last-stable
5+
OUT_NOAUTO ydbd-last-stable
6+
)
7+
8+
END()
9+
10+
RECURSE(downloader)

ydb/tests/library/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,5 @@ PEERDIR(
115115

116116
END()
117117

118+
RECURSE(compatibility)
118119
RECURSE_FOR_TESTS(ut)

0 commit comments

Comments
 (0)