22import inspect
33import pytest
44import time
5+ import sys
6+ import copy
7+ from threading import Thread
8+
59from ydb .tests .olap .lib .results_processor import ResultsProcessor
610from ydb .tests .olap .scenario .helpers .scenario_tests_helper import TestContext , ScenarioTestHelper
711from ydb .tests .olap .lib .ydb_cluster import YdbCluster
8- from ydb .tests .olap .lib .utils import external_param_is_true
912from ydb .tests .olap .lib .utils import get_external_param
1013from ydb .tests .olap .lib .allure_utils import allure_test_description
1114from 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
119154def pytest_generate_tests (metafunc ):
0 commit comments