Skip to content

Commit 65f6586

Browse files
authored
Fix multitest (#14910)
1 parent db54481 commit 65f6586

File tree

7 files changed

+62
-25
lines changed

7 files changed

+62
-25
lines changed

.github/config/muted_ya.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ ydb/tests/olap/oom overlapping_portions.py.TestOverlappingPortions.test
119119
ydb/tests/olap/scenario sole chunk chunk
120120
ydb/tests/olap/scenario test_alter_compression.py.TestAlterCompression.test[alter_compression]
121121
ydb/tests/olap/scenario test_alter_tiering.py.TestAlterTiering.test[many_tables]
122-
ydb/tests/olap/scenario test_insert.py.TestInsert.test[read_data_during_bulk_upsert]
123122
ydb/tests/olap/scenario test_read_update_write_load.py.TestReadUpdateWriteLoad.test[read_update_write_load]
124123
ydb/tests/olap/ttl_tiering [data_migration_when_alter_ttl.py] chunk chunk
125124
ydb/tests/olap/ttl_tiering [ttl_delete_s3.py] chunk chunk

ydb/tests/olap/scenario/conftest.py

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
import inspect
33
import pytest
44
import time
5+
import sys
6+
import copy
7+
from threading import Thread
8+
59
from ydb.tests.olap.lib.results_processor import ResultsProcessor
610
from ydb.tests.olap.scenario.helpers.scenario_tests_helper import TestContext, ScenarioTestHelper
711
from ydb.tests.olap.lib.ydb_cluster import YdbCluster
8-
from ydb.tests.olap.lib.utils import external_param_is_true
912
from ydb.tests.olap.lib.utils import get_external_param
1013
from ydb.tests.olap.lib.allure_utils import allure_test_description
1114
from ydb.tests.library.harness.kikimr_runner import KiKiMR
@@ -71,19 +74,38 @@ def setup_class(cls):
7174
ydb_database = get_external_param('ydb-db', "").lstrip('/')
7275
cls._ydb_instance = YdbClusterInstance(ydb_endpoint, ydb_database, cls._get_cluster_config())
7376
YdbCluster.reset(cls._ydb_instance.endpoint(), cls._ydb_instance.database(), cls._ydb_instance.mon_port(), cls._ydb_instance.dyn_nodes_count())
74-
if not external_param_is_true('reuse-tables'):
75-
ScenarioTestHelper(None).remove_path(cls.get_suite_name())
7677

7778
@classmethod
7879
def teardown_class(cls):
79-
if not external_param_is_true('keep-tables'):
80-
ScenarioTestHelper(None).remove_path(cls.get_suite_name())
8180
cls._ydb_instance.stop()
8281

82+
def test_multi(self, ctx: TestContext):
83+
if self.__class__.__name__ != 'TestInsert':
84+
return
85+
self.def_inserts_count = 50
86+
num_threads = int(get_external_param("num_threads", "10"))
87+
threads = []
88+
exit_codes = [None] * num_threads
89+
for p in range(num_threads):
90+
threads.append(Thread(target=self._test_suffix, args=(copy.deepcopy(ctx), str(p), exit_codes, p)))
91+
for t in threads:
92+
t.start()
93+
for t in threads:
94+
t.join()
95+
assert exit_codes == [0] * num_threads, exit_codes
96+
8397
def test(self, ctx: TestContext):
84-
test_path = ctx.test + get_external_param("table_suffix", "")
85-
ScenarioTestHelper(None).remove_path(test_path, ctx.suite)
98+
self.def_inserts_count = 200
99+
exit_codes = [None]
100+
self._test_suffix(ctx, get_external_param("table_suffix", ""), exit_codes, 0)
101+
102+
def _test_suffix(self, ctx: TestContext, table_suffix: str, exit_codes, num: int):
86103
start_time = time.time()
104+
ctx.test += table_suffix
105+
test_path = ctx.test
106+
print('test_suffix, num {}, table path {} start_time {}'.format(num, test_path, start_time), file=sys.stderr)
107+
ScenarioTestHelper(None).remove_path(test_path, ctx.suite)
108+
print('Path {} removed'.format(test_path), file=sys.stderr)
87109
try:
88110
ctx.executable(self, ctx)
89111
ResultsProcessor.upload_results(
@@ -95,9 +117,11 @@ def test(self, ctx: TestContext):
95117
is_successful=True,
96118
)
97119
except pytest.skip.Exception:
120+
print('Caught skip exception, num {}'.format(num), file=sys.stderr)
98121
allure_test_description(ctx.suite, ctx.test, start_time=start_time, end_time=time.time())
99122
raise
100-
except BaseException:
123+
except BaseException as e:
124+
print('Caught base exception, num {} message {}'.format(num, str(e)), file=sys.stderr)
101125
ResultsProcessor.upload_results(
102126
kind='Scenario',
103127
suite=ctx.suite,
@@ -109,11 +133,22 @@ def test(self, ctx: TestContext):
109133
allure_test_description(ctx.suite, ctx.test, start_time=start_time, end_time=time.time())
110134
raise
111135
allure_test_description(ctx.suite, ctx.test, start_time=start_time, end_time=time.time())
112-
ScenarioTestHelper(None).remove_path(test_path, ctx.suite)
136+
ScenarioTestHelper(None).remove_path(ctx.test, ctx.suite)
137+
print('Path {} removed'.format(ctx.test), file=sys.stderr)
138+
exit_codes[num] = 0
113139

114140
@classmethod
115141
def _get_cluster_config(cls):
116-
return KikimrConfigGenerator(extra_feature_flags=["enable_column_store"])
142+
return KikimrConfigGenerator(
143+
extra_feature_flags={
144+
"enable_column_store": True,
145+
"enable_external_data_sources": True,
146+
"enable_tiering_in_column_shard": True,
147+
},
148+
query_service_config=dict(
149+
available_external_data_sources=["ObjectStorage"]
150+
)
151+
)
117152

118153

119154
def pytest_generate_tests(metafunc):

ydb/tests/olap/scenario/helpers/scenario_tests_helper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from abc import abstractmethod, ABC
1111
from typing import Set, List, Dict, Any, Callable, Optional
1212
from time import sleep
13-
from ydb.tests.olap.lib.utils import get_external_param
1413

1514

1615
class TestContext:
@@ -319,7 +318,7 @@ def _add_not_empty(p: str, dir: str):
319318
result = os.path.join('/', YdbCluster.ydb_database, YdbCluster.tables_path)
320319
if self.test_context is not None:
321320
result = _add_not_empty(result, self.test_context.suite)
322-
result = _add_not_empty(result, self.test_context.test) + get_external_param("table_suffix", "")
321+
result = _add_not_empty(result, self.test_context.test)
323322
result = _add_not_empty(result, path)
324323
return result
325324

@@ -358,6 +357,7 @@ def _run_with_expected_status(
358357
sleep(3)
359358
if fail_on_error:
360359
pytest.fail(f'Retries exceeded with unexpected status: must be in {repr(expected_status)}, but get {repr(error or status)}')
360+
return 1
361361

362362
def _bulk_upsert_impl(
363363
self, tablename: str, data_generator: ScenarioTestHelper.IDataGenerator, expected_status: ydb.StatusCode | Set[ydb.StatusCode]
@@ -485,7 +485,7 @@ def execute_query(
485485

486486
allure.attach(yql, 'request', allure.attachment_type.TEXT)
487487
with ydb.QuerySessionPool(YdbCluster.get_ydb_driver()) as pool:
488-
self._run_with_expected_status(lambda: pool.execute_with_retries(yql, None, ydb.RetrySettings(max_retries=retries)), expected_status, fail_on_error=fail_on_error)
488+
return self._run_with_expected_status(lambda: pool.execute_with_retries(yql, None, ydb.RetrySettings(max_retries=retries)), expected_status, fail_on_error=fail_on_error)
489489

490490
def drop_if_exist(self, names: List[str], operation) -> None:
491491
"""Erase entities in the tested database, if it exists.

ydb/tests/olap/scenario/multitest.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

ydb/tests/olap/scenario/test.mk

Lines changed: 0 additions & 6 deletions
This file was deleted.

ydb/tests/olap/scenario/test_alter_tiering.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ def _get_cluster_config(cls):
113113
'TX_TIERING_BLOBS_TIER': LogLevels.TRACE,
114114
'TX_COLUMNSHARD_ACTUALIZATION': LogLevels.TRACE,
115115
},
116+
query_service_config=dict(
117+
available_external_data_sources=["ObjectStorage"]
118+
),
116119
)
117120

118121
def _setup_tiering_test(self, ctx):

ydb/tests/olap/scenario/test_insert.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,23 @@ def _loop_insert(self, ctx: TestContext, rows_count: int, table: str, ignore_rea
3838
for i in range(rows_count):
3939
for c in range(10):
4040
try:
41-
sth.execute_query(
41+
result = sth.execute_query(
4242
yql=f'$cnt = SELECT CAST(COUNT(*) AS INT64) from `{log}`; INSERT INTO `{cnt}` (key, c) values({i}, $cnt)', retries=20, fail_on_error=False
4343
)
44+
if result == 1:
45+
if c >= 9:
46+
raise Exception('Insert failed table {}'.format(table))
47+
else:
48+
time.sleep(1)
49+
continue
50+
4451
break
4552
except Exception:
4653
if ignore_read_errors:
4754
pass
4855
else:
49-
raise
56+
if c >= 9:
57+
raise
5058
time.sleep(1)
5159

5260
def scenario_read_data_during_bulk_upsert(self, ctx: TestContext):
@@ -55,7 +63,7 @@ def scenario_read_data_during_bulk_upsert(self, ctx: TestContext):
5563
log_table_name: str = "log"
5664
batches_count = int(get_external_param("batches_count", "10"))
5765
rows_count = int(get_external_param("rows_count", "1000"))
58-
inserts_count = int(get_external_param("inserts_count", "200"))
66+
inserts_count = int(get_external_param("inserts_count", str(self.def_inserts_count)))
5967
tables_count = int(get_external_param("tables_count", "1"))
6068
ignore_read_errors = external_param_is_true("ignore_read_errors")
6169
for table in range(tables_count):

0 commit comments

Comments
 (0)