Skip to content

Commit 19a4f60

Browse files
authored
Merge 2199fd7 into c2d2843
2 parents c2d2843 + 2199fd7 commit 19a4f60

File tree

4 files changed

+163
-0
lines changed

4 files changed

+163
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# -*- coding: utf-8 -*-
2+
import os
3+
import time
4+
5+
import pytest
6+
7+
import yatest
8+
9+
from ydb.tests.library.compatibility.fixtures import RollingUpdateFixture
10+
11+
12+
class TestRolling(RollingUpdateFixture):
13+
@pytest.fixture(autouse=True)
14+
def setup(self):
15+
output_path = yatest.common.test_output_path()
16+
self.output_f = open(os.path.join(output_path, "out.log"), "w")
17+
yield from self.setup_cluster(
18+
extra_feature_flags={"enable_column_store": True},
19+
20+
column_shard_config={
21+
"disabled_on_scheme_shard": False,
22+
},
23+
)
24+
25+
def get_command_prefix_log(self, subcmds: list[str], path: str) -> list[str]:
26+
return (
27+
[
28+
yatest.common.binary_path(os.getenv("YDB_CLI_BINARY")),
29+
"--verbose",
30+
"--endpoint",
31+
"grpc://localhost:%d" % self.cluster.nodes[1].grpc_port,
32+
"--database=/Root",
33+
"workload",
34+
"log",
35+
]
36+
+ subcmds
37+
+ ["--path", path]
38+
)
39+
40+
@pytest.mark.parametrize("store_type", ["row", "column"])
41+
def test_log(self, store_type):
42+
init_command_prefix = [
43+
yatest.common.binary_path(os.getenv("YDB_CLI_BINARY")),
44+
"--verbose",
45+
"--endpoint",
46+
"grpc://localhost:%d" % self.cluster.nodes[1].grpc_port,
47+
"--database=/Root",
48+
"workload",
49+
"kv",
50+
"init",
51+
"--min-partitions",
52+
"10",
53+
"--partition-size",
54+
"10",
55+
"--auto-partition",
56+
"0",
57+
"--init-upserts",
58+
"0",
59+
"--cols",
60+
"5",
61+
"--int-cols",
62+
"2",
63+
"--key-cols",
64+
"3",
65+
]
66+
67+
run_command_prefix = [
68+
yatest.common.binary_path(os.getenv("YDB_CLI_BINARY")),
69+
"--verbose",
70+
"--endpoint",
71+
"grpc://localhost:%d" % self.cluster.nodes[1].grpc_port,
72+
"--database=/Root",
73+
"workload",
74+
"kv",
75+
"run",
76+
"mixed",
77+
"--seconds",
78+
"10000000", # infinity
79+
"--threads",
80+
"10",
81+
"--cols",
82+
"5",
83+
"--len",
84+
"200",
85+
"--int-cols",
86+
"2",
87+
"--key-cols",
88+
"3",
89+
]
90+
91+
init_command = init_command_prefix
92+
init_command.extend(
93+
[
94+
"--path",
95+
store_type,
96+
"--store",
97+
store_type,
98+
]
99+
)
100+
run_command = run_command_prefix
101+
run_command.extend(
102+
[
103+
"--path",
104+
store_type,
105+
]
106+
)
107+
yatest.common.execute(init_command, wait=True, stdout=self.output_f, stderr=self.output_f)
108+
run = yatest.common.execute(run_command, wait=False, stdout=self.output_f, stderr=self.output_f)
109+
110+
for _ in self.roll():
111+
time.sleep(5)
112+
113+
run.kill()

ydb/tests/compatibility/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ TEST_SRCS(
1212
test_followers.py
1313
test_compatibility.py
1414
test_stress.py
15+
test_rolling.py
1516
)
1617

1718
SIZE(LARGE)

ydb/tests/library/compatibility/fixtures.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,47 @@ def setup_cluster(self, **kwargs):
109109
self.driver.wait()
110110
yield
111111
self.cluster.stop()
112+
113+
114+
class RollingUpdateFixture:
115+
@pytest.fixture(autouse=True)
116+
def base_setup(self):
117+
self.all_binary_paths = [last_stable_binary_path]
118+
119+
def setup_cluster(self, **kwargs):
120+
self.config = KikimrConfigGenerator(
121+
erasure=Erasure.MIRROR_3_DC,
122+
binary_paths=self.all_binary_paths,
123+
**kwargs,
124+
)
125+
126+
self.cluster = KiKiMR(self.config)
127+
self.cluster.start()
128+
self.endpoint = "grpc://%s:%s" % ('localhost', self.cluster.nodes[1].port)
129+
130+
self.driver = ydb.Driver(
131+
ydb.DriverConfig(
132+
database='/Root',
133+
endpoint=self.endpoint
134+
)
135+
)
136+
self.driver.wait()
137+
yield
138+
self.cluster.stop()
139+
140+
def roll(self):
141+
# from old to new
142+
for node_id, node in self.cluster.nodes.items():
143+
node.stop()
144+
node.binary_path = current_binary_path
145+
node.start()
146+
yield
147+
148+
# from new to old
149+
for node_id, node in self.cluster.nodes.items():
150+
node.stop()
151+
node.binary_path = last_stable_binary_path
152+
node.start()
153+
yield
154+
155+
yield

ydb/tests/library/harness/kikimr_runner.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ def cwd(self):
154154
def binary_path(self):
155155
return self.__binary_path
156156

157+
@binary_path.setter
158+
def binary_path(self, value):
159+
self.__binary_path = value
160+
157161
@property
158162
def command(self):
159163
return self.__make_run_command()
@@ -277,6 +281,7 @@ def pid(self):
277281

278282
def start(self):
279283
try:
284+
self.update_command(self.__make_run_command())
280285
super(KiKiMRNode, self).start()
281286
finally:
282287
logger.info("Started node %s", self)

0 commit comments

Comments
 (0)