2
2
import inspect
3
3
import pytest
4
4
import time
5
+ import sys
6
+ import copy
7
+ from threading import Thread
8
+
5
9
from ydb .tests .olap .lib .results_processor import ResultsProcessor
6
10
from ydb .tests .olap .scenario .helpers .scenario_tests_helper import TestContext , ScenarioTestHelper
7
11
from ydb .tests .olap .lib .ydb_cluster import YdbCluster
8
- from ydb .tests .olap .lib .utils import external_param_is_true
9
12
from ydb .tests .olap .lib .utils import get_external_param
10
13
from ydb .tests .olap .lib .allure_utils import allure_test_description
11
14
from ydb .tests .library .harness .kikimr_runner import KiKiMR
@@ -71,19 +74,38 @@ def setup_class(cls):
71
74
ydb_database = get_external_param ('ydb-db' , "" ).lstrip ('/' )
72
75
cls ._ydb_instance = YdbClusterInstance (ydb_endpoint , ydb_database , cls ._get_cluster_config ())
73
76
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 ())
76
77
77
78
@classmethod
78
79
def teardown_class (cls ):
79
- if not external_param_is_true ('keep-tables' ):
80
- ScenarioTestHelper (None ).remove_path (cls .get_suite_name ())
81
80
cls ._ydb_instance .stop ()
82
81
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
+
83
97
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 ):
86
103
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 )
87
109
try :
88
110
ctx .executable (self , ctx )
89
111
ResultsProcessor .upload_results (
@@ -95,9 +117,11 @@ def test(self, ctx: TestContext):
95
117
is_successful = True ,
96
118
)
97
119
except pytest .skip .Exception :
120
+ print ('Caught skip exception, num {}' .format (num ), file = sys .stderr )
98
121
allure_test_description (ctx .suite , ctx .test , start_time = start_time , end_time = time .time ())
99
122
raise
100
- except BaseException :
123
+ except BaseException as e :
124
+ print ('Caught base exception, num {} message {}' .format (num , str (e )), file = sys .stderr )
101
125
ResultsProcessor .upload_results (
102
126
kind = 'Scenario' ,
103
127
suite = ctx .suite ,
@@ -109,11 +133,22 @@ def test(self, ctx: TestContext):
109
133
allure_test_description (ctx .suite , ctx .test , start_time = start_time , end_time = time .time ())
110
134
raise
111
135
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
113
139
114
140
@classmethod
115
141
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
+ )
117
152
118
153
119
154
def pytest_generate_tests (metafunc ):
0 commit comments