Skip to content

Commit a487c8d

Browse files
authored
Rolling update fixture (#18430)
1 parent b2e4183 commit a487c8d

File tree

4 files changed

+150
-0
lines changed

4 files changed

+150
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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={
19+
"enable_column_store": True,
20+
},
21+
22+
column_shard_config={
23+
"disabled_on_scheme_shard": False,
24+
},
25+
)
26+
27+
@pytest.mark.parametrize("store_type", ["row", "column"])
28+
def test_kv(self, store_type):
29+
init_command_prefix = [
30+
yatest.common.binary_path(os.getenv("YDB_CLI_BINARY")),
31+
"--verbose",
32+
"--endpoint",
33+
"grpc://localhost:%d" % self.cluster.nodes[1].grpc_port,
34+
"--database=/Root",
35+
"workload",
36+
"kv",
37+
"init",
38+
"--min-partitions",
39+
"10",
40+
"--partition-size",
41+
"10",
42+
"--auto-partition",
43+
"0",
44+
"--init-upserts",
45+
"0",
46+
"--cols",
47+
"5",
48+
"--int-cols",
49+
"2",
50+
"--key-cols",
51+
"3",
52+
]
53+
54+
run_command_prefix = [
55+
yatest.common.binary_path(os.getenv("YDB_CLI_BINARY")),
56+
"--verbose",
57+
"--endpoint",
58+
"grpc://localhost:%d" % self.cluster.nodes[1].grpc_port,
59+
"--database=/Root",
60+
"workload",
61+
"kv",
62+
"run",
63+
"mixed",
64+
"--seconds",
65+
"10000000", # infinity
66+
"--threads",
67+
"10",
68+
"--cols",
69+
"5",
70+
"--len",
71+
"200",
72+
"--int-cols",
73+
"2",
74+
"--key-cols",
75+
"3",
76+
]
77+
78+
init_command = init_command_prefix
79+
init_command.extend(
80+
[
81+
"--path",
82+
store_type,
83+
"--store",
84+
store_type,
85+
]
86+
)
87+
run_command = run_command_prefix
88+
run_command.extend(
89+
[
90+
"--path",
91+
store_type,
92+
]
93+
)
94+
yatest.common.execute(init_command, wait=True, stdout=self.output_f, stderr=self.output_f)
95+
run = yatest.common.execute(run_command, wait=False, stdout=self.output_f, stderr=self.output_f)
96+
97+
for _ in self.roll():
98+
time.sleep(5)
99+
100+
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)