Skip to content

Commit de8d3ca

Browse files
authored
Use common fixture for stress-tests (#20250)
1 parent 618f550 commit de8d3ca

File tree

22 files changed

+97
-154
lines changed

22 files changed

+97
-154
lines changed

ydb/tests/library/stress/fixtures.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
55
from ydb.tests.library.harness.param_constants import kikimr_driver_path
66

7-
from ydb.tests.library.common.types import Erasure
87
from ydb.tests.oss.ydb_sdk_import import ydb
98

109

@@ -15,7 +14,6 @@ def base_setup(self):
1514

1615
def setup_cluster(self, **kwargs):
1716
self.config = KikimrConfigGenerator(
18-
erasure=Erasure.MIRROR_3_DC,
1917
binary_paths=self.all_binary_paths,
2018
**kwargs,
2119
)

ydb/tests/stress/cdc/tests/test_workload.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
# -*- coding: utf-8 -*-
22
import os
3+
import pytest
34
import yatest
45

5-
from ydb.tests.library.harness.kikimr_runner import KiKiMR
6-
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
76
from ydb.tests.library.harness.util import LogLevels
7+
from ydb.tests.library.stress.fixtures import StressFixture
88

99

10-
class TestYdbWorkload(object):
11-
@classmethod
12-
def setup_class(cls):
13-
cls.cluster = KiKiMR(
14-
KikimrConfigGenerator(
15-
additional_log_configs={
16-
"CHANGE_EXCHANGE": LogLevels.DEBUG,
17-
},
18-
)
10+
class TestYdbWorkload(StressFixture):
11+
@pytest.fixture(autouse=True, scope="function")
12+
def setup(self):
13+
yield from self.setup_cluster(
14+
additional_log_configs={
15+
"CHANGE_EXCHANGE": LogLevels.DEBUG,
16+
},
1917
)
20-
cls.cluster.start()
21-
22-
@classmethod
23-
def teardown_class(cls):
24-
cls.cluster.stop()
2518

2619
def test(self):
2720
cmd = [

ydb/tests/stress/cdc/tests/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ DEPENDS(
1616

1717
PEERDIR(
1818
ydb/tests/library
19+
ydb/tests/library/stress
1920
ydb/tests/stress/cdc/workload
2021
)
2122

ydb/tests/stress/kv/tests/test_workload.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
import os
33

44
import pytest
5-
65
import yatest
76

8-
from ydb.tests.library.harness.kikimr_runner import KiKiMR
9-
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
10-
from ydb.tests.library.common.types import Erasure
7+
8+
from ydb.tests.library.stress.fixtures import StressFixture
119

1210

13-
class TestYdbKvWorkload(object):
14-
@classmethod
15-
def setup_class(cls):
16-
cls.cluster = KiKiMR(KikimrConfigGenerator(erasure=Erasure.MIRROR_3_DC))
17-
cls.cluster.start()
18-
cls.init_command_prefix = [
11+
class TestYdbWorkload(StressFixture):
12+
@pytest.fixture(autouse=True, scope="function")
13+
def setup(self):
14+
yield from self.setup_cluster()
15+
16+
@pytest.mark.parametrize("store_type", ["row", "column"])
17+
def test(self, store_type):
18+
init_command = [
1919
yatest.common.binary_path(os.getenv("YDB_CLI_BINARY")),
2020
"--verbose",
21-
"--endpoint", "grpc://localhost:%d" % cls.cluster.nodes[1].grpc_port,
21+
"--endpoint", "grpc://localhost:%d" % self.cluster.nodes[1].grpc_port,
2222
"--database=/Root",
2323
"workload", "kv", "init",
2424
"--min-partitions", "1",
@@ -30,10 +30,10 @@ def setup_class(cls):
3030
"--key-cols", "3",
3131
]
3232

33-
cls.run_command_prefix = [
33+
run_command = [
3434
yatest.common.binary_path(os.getenv("YDB_CLI_BINARY")),
3535
"--verbose",
36-
"--endpoint", "grpc://localhost:%d" % cls.cluster.nodes[1].grpc_port,
36+
"--endpoint", "grpc://localhost:%d" % self.cluster.nodes[1].grpc_port,
3737
"--database=/Root",
3838
"workload", "kv", "run", "mixed",
3939
"--seconds", "100",
@@ -44,18 +44,10 @@ def setup_class(cls):
4444
"--key-cols", "3"
4545
]
4646

47-
@classmethod
48-
def teardown_class(cls):
49-
cls.cluster.stop()
50-
51-
@pytest.mark.parametrize("store_type", ["row", "column"])
52-
def test(self, store_type):
53-
init_command = self.init_command_prefix
5447
init_command.extend([
5548
"--path", store_type,
5649
"--store", store_type,
5750
])
58-
run_command = self.run_command_prefix
5951
run_command.extend([
6052
"--path", store_type,
6153
])

ydb/tests/stress/kv/tests/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ DEPENDS(
2121

2222
PEERDIR(
2323
ydb/tests/library
24+
ydb/tests/library/stress
2425
)
2526

2627

ydb/tests/stress/log/tests/test_workload.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
# -*- coding: utf-8 -*-
22
import os
3-
43
import pytest
5-
64
import yatest
75

8-
from ydb.tests.library.harness.kikimr_runner import KiKiMR
9-
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
6+
from ydb.tests.library.stress.fixtures import StressFixture
107

118

12-
class TestYdbLogWorkload(object):
13-
@classmethod
14-
def setup_class(cls):
15-
cls.cluster = KiKiMR(KikimrConfigGenerator())
16-
cls.cluster.start()
9+
class TestYdbLogWorkload(StressFixture):
10+
@pytest.fixture(autouse=True, scope="function")
11+
def setup(self):
12+
yield from self.setup_cluster()
1713

18-
@classmethod
19-
def get_command_prefix(cls, subcmds: list[str], path: str) -> list[str]:
14+
def get_command_prefix(self, subcmds: list[str], path: str) -> list[str]:
2015
return [
2116
yatest.common.binary_path(os.getenv('YDB_CLI_BINARY')),
2217
'--verbose',
23-
'--endpoint', 'grpc://localhost:%d' % cls.cluster.nodes[1].grpc_port,
18+
'--endpoint', 'grpc://localhost:%d' % self.cluster.nodes[1].grpc_port,
2419
'--database=/Root',
2520
'workload', 'log'
2621
] + subcmds + [
@@ -36,10 +31,6 @@ def get_insert_command_params(cls) -> list[str]:
3631
'--len', '200',
3732
]
3833

39-
@classmethod
40-
def teardown_class(cls):
41-
cls.cluster.stop()
42-
4334
@pytest.mark.parametrize('store_type', ['row', 'column'])
4435
def test(self, store_type):
4536
upload_commands = [

ydb/tests/stress/log/tests/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ DEPENDS(
1515

1616
PEERDIR(
1717
ydb/tests/library
18+
ydb/tests/library/stress
1819
)
1920

2021

ydb/tests/stress/mixedpy/test_mixed.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
# -*- coding: utf-8 -*-
22
import os
33
import sys
4-
54
import pytest
6-
75
import yatest
86

9-
from ydb.tests.library.harness.kikimr_runner import KiKiMR
10-
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
117
from ydb.tests.olap.lib.utils import get_external_param
128

9+
from ydb.tests.library.stress.fixtures import StressFixture
1310

14-
class TestYdbMixedWorkload(object):
15-
@classmethod
16-
def setup_class(cls):
17-
cls.cluster = KiKiMR(KikimrConfigGenerator())
18-
cls.cluster.start()
11+
12+
class TestYdbWorkload(StressFixture):
13+
@pytest.fixture(autouse=True, scope="function")
14+
def setup(self):
15+
yield from self.setup_cluster()
1916

2017
def get_command_prefix(self, subcmds: list[str]) -> list[str]:
2118
return [
@@ -26,10 +23,6 @@ def get_command_prefix(self, subcmds: list[str]) -> list[str]:
2623
'workload', 'mixed'
2724
] + subcmds
2825

29-
@classmethod
30-
def teardown_class(cls):
31-
cls.cluster.stop()
32-
3326
@classmethod
3427
def get_cols_count_command_params(cls) -> list[str]:
3528
return [

ydb/tests/stress/mixedpy/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ DEPENDS(
2323

2424
PEERDIR(
2525
ydb/tests/library
26+
ydb/tests/library/stress
2627
ydb/tests/olap/lib
2728
)
2829

ydb/tests/stress/node_broker/tests/test_workload.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
# -*- coding: utf-8 -*-
22
import os
33
import yatest
4+
import pytest
45

5-
from ydb.tests.library.harness.kikimr_runner import KiKiMR
6-
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
76
from ydb.tests.library.common.types import Erasure
87
from ydb.tests.library.harness.util import LogLevels
98

109

11-
class TestYdbWorkload(object):
12-
@classmethod
13-
def setup_class(cls):
14-
cls.cluster = KiKiMR(
15-
KikimrConfigGenerator(
16-
erasure=Erasure.MIRROR_3_DC,
17-
additional_log_configs={
18-
"NODE_BROKER": LogLevels.TRACE,
19-
"NAMESERVICE": LogLevels.TRACE,
20-
},
21-
)
22-
)
23-
cls.cluster.start()
10+
from ydb.tests.library.stress.fixtures import StressFixture
11+
2412

25-
@classmethod
26-
def teardown_class(cls):
27-
cls.cluster.stop()
13+
class TestYdbWorkload(StressFixture):
14+
@pytest.fixture(autouse=True, scope="function")
15+
def setup(self):
16+
yield from self.setup_cluster(
17+
erasure=Erasure.MIRROR_3_DC,
18+
additional_log_configs={
19+
"NODE_BROKER": LogLevels.TRACE,
20+
"NAMESERVICE": LogLevels.TRACE,
21+
},
22+
)
2823

2924
def test(self):
3025
cmd = [

0 commit comments

Comments
 (0)