diff options
| author | Олег <[email protected]> | 2025-06-19 01:22:57 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-18 22:22:57 +0000 |
| commit | 43a188f09370f4e521770ff01766679bbbf293a1 (patch) | |
| tree | 62b628b75afc444402d2c03c677c233e84411450 | |
| parent | f46cd163c94b63bc7d7a4b707ae751e77501d8d6 (diff) | |
Fix workloads working with empty path (#19857)
| -rw-r--r-- | ydb/library/workload/benchmark_base/workload.cpp | 10 | ||||
| -rw-r--r-- | ydb/library/workload/query/query.cpp | 5 | ||||
| -rw-r--r-- | ydb/tests/functional/tpc/medium/test_external.py | 8 | ||||
| -rw-r--r-- | ydb/tests/olap/lib/allure_utils.py | 4 | ||||
| -rw-r--r-- | ydb/tests/olap/lib/results_processor.py | 2 | ||||
| -rw-r--r-- | ydb/tests/olap/lib/ydb_cluster.py | 8 | ||||
| -rw-r--r-- | ydb/tests/olap/load/lib/clickbench.py | 4 | ||||
| -rw-r--r-- | ydb/tests/olap/load/lib/conftest.py | 4 | ||||
| -rw-r--r-- | ydb/tests/olap/load/lib/external.py | 2 | ||||
| -rw-r--r-- | ydb/tests/olap/load/lib/import_csv.py | 6 | ||||
| -rw-r--r-- | ydb/tests/olap/load/lib/tpcds.py | 2 | ||||
| -rw-r--r-- | ydb/tests/olap/load/lib/tpch.py | 2 | ||||
| -rw-r--r-- | ydb/tests/olap/load/lib/upload.py | 2 | ||||
| -rw-r--r-- | ydb/tests/olap/s3_import/large/test_large_import.py | 14 | ||||
| -rw-r--r-- | ydb/tests/olap/scenario/helpers/scenario_tests_helper.py | 18 |
15 files changed, 53 insertions, 38 deletions
diff --git a/ydb/library/workload/benchmark_base/workload.cpp b/ydb/library/workload/benchmark_base/workload.cpp index 3049b0ebdbe..12112dd5481 100644 --- a/ydb/library/workload/benchmark_base/workload.cpp +++ b/ydb/library/workload/benchmark_base/workload.cpp @@ -238,10 +238,14 @@ void TWorkloadBaseParams::Validate(const ECommandType /*commandType*/, int /*wor TString TWorkloadBaseParams::GetFullTableName(const char* table) const { TStringBuilder result; - if (!Path.StartsWith('/')) { - result << DbPath << "/"; + if (Path.StartsWith('/')) { + result << Path; + } else { + result << DbPath; + if (Path) { + result << "/" << Path; + } } - result << Path; if (TStringBuf(table)){ result << "/" << table; } diff --git a/ydb/library/workload/query/query.cpp b/ydb/library/workload/query/query.cpp index 9eac5b33ad6..1883f06271a 100644 --- a/ydb/library/workload/query/query.cpp +++ b/ydb/library/workload/query/query.cpp @@ -184,7 +184,10 @@ TQueryInfoList TQueryGenerator::GetInitialData() { } TVector<std::string> TQueryGenerator::GetCleanPaths() const { - return { Params.GetPath().c_str() }; + if (Params.GetPath()) { + return { Params.GetPath().c_str() }; + } + return {}; } } // namespace NQuery diff --git a/ydb/tests/functional/tpc/medium/test_external.py b/ydb/tests/functional/tpc/medium/test_external.py index 8221c4b9db9..0eab19acc44 100644 --- a/ydb/tests/functional/tpc/medium/test_external.py +++ b/ydb/tests/functional/tpc/medium/test_external.py @@ -1,5 +1,6 @@ from ydb.tests.olap.load.lib.external import ExternalSuiteBase, pytest_generate_tests # noqa from ydb.tests.functional.tpc.lib.conftest import FunctionalTestBase +from ydb.tests.olap.lib.ydb_cluster import YdbCluster class TestExternalE1(ExternalSuiteBase, FunctionalTestBase): @@ -8,15 +9,16 @@ class TestExternalE1(ExternalSuiteBase, FunctionalTestBase): @classmethod def setup_class(cls) -> None: + YdbCluster._tables_path = '' cls.setup_cluster() cls.run_cli([ - 'workload', 'query', '-p', f'olap_yatests/{cls.external_folder}', 'init', '--suite-path', cls.get_external_path() + 'workload', 'query', '-p', f'{cls.external_folder}', 'init', '--suite-path', cls.get_external_path() ]) cls.run_cli([ - 'workload', 'query', '-p', f'olap_yatests/{cls.external_folder}', 'import', '--suite-path', cls.get_external_path() + 'workload', 'query', '-p', f'{cls.external_folder}', 'import', '--suite-path', cls.get_external_path() ]) super().setup_class() @classmethod def teardown_class(cls) -> None: - cls.run_cli(['workload', 'query', '-p', f'olap_yatests/{cls.external_folder}', 'clean']) + cls.run_cli(['workload', 'query', '-p', f'{cls.external_folder}', 'clean']) diff --git a/ydb/tests/olap/lib/allure_utils.py b/ydb/tests/olap/lib/allure_utils.py index 071b7dc316b..766c9c5a16c 100644 --- a/ydb/tests/olap/lib/allure_utils.py +++ b/ydb/tests/olap/lib/allure_utils.py @@ -398,10 +398,10 @@ def allure_test_description( db = test_info['database'] test_info.update( { - 'table_path': YdbCluster.tables_path, + 'table_path': YdbCluster.get_tables_path(), 'db_admin': ( f"<a target='_blank' href='{service_url}/monitoring/tenant?" - f"schema=/{db}/{YdbCluster.tables_path}&tenantPage=query" + f"schema=/{db}/{YdbCluster.get_tables_path()}&tenantPage=query" f"&diagnosticsTab=nodes&name=/{db}'>{service_url}</a>" ), 'time': ( diff --git a/ydb/tests/olap/lib/results_processor.py b/ydb/tests/olap/lib/results_processor.py index 26493ab4591..72ddef59131 100644 --- a/ydb/tests/olap/lib/results_processor.py +++ b/ydb/tests/olap/lib/results_processor.py @@ -76,7 +76,7 @@ class ResultsProcessor: @staticmethod def get_cluster_id(): - run_id = get_external_param('run-id', YdbCluster.tables_path) + run_id = get_external_param('run-id', YdbCluster.get_tables_path()) return os.path.join(YdbCluster.ydb_endpoint, YdbCluster.ydb_database, run_id) @classmethod diff --git a/ydb/tests/olap/lib/ydb_cluster.py b/ydb/tests/olap/lib/ydb_cluster.py index 6e08a949a1e..d9996023152 100644 --- a/ydb/tests/olap/lib/ydb_cluster.py +++ b/ydb/tests/olap/lib/ydb_cluster.py @@ -65,11 +65,17 @@ class YdbCluster: ydb_endpoint = get_external_param('ydb-endpoint', 'grpc://ydb-olap-testing-vla-0002.search.yandex.net:2135') ydb_database = get_external_param('ydb-db', 'olap-testing/kikimr/testing/acceptance-2').lstrip('/') ydb_mon_port = 8765 - tables_path = get_external_param('tables-path', 'olap_yatests') + _tables_path = get_external_param('tables-path', 'olap_yatests').rstrip('/') _monitoring_urls: list[YdbCluster.MonitoringUrl] = None _dyn_nodes_count: Optional[int] = None @classmethod + def get_tables_path(cls, subpath: str = '') -> str: + if cls._tables_path and subpath: + return f'{cls._tables_path}/{subpath}' + return subpath if subpath else cls._tables_path + + @classmethod def get_monitoring_urls(cls) -> list[YdbCluster.MonitoringUrl]: def _process_url(url: str) -> YdbCluster.MonitoringUrl: spl = url.split('::', 2) diff --git a/ydb/tests/olap/load/lib/clickbench.py b/ydb/tests/olap/load/lib/clickbench.py index ce6ed0abfa8..b273aadfcbf 100644 --- a/ydb/tests/olap/load/lib/clickbench.py +++ b/ydb/tests/olap/load/lib/clickbench.py @@ -12,7 +12,7 @@ QUERY_NAMES = [f'Query{query_num:02d}' for query_num in range(0, 43)] class TestClickbench(LoadSuiteBase): workload_type: WorkloadType = WorkloadType.Clickbench - path = get_external_param('table-path-clickbench', f'{YdbCluster.tables_path}/clickbench/hits') + path = get_external_param('table-path-clickbench', YdbCluster.get_tables_path('clickbench/hits')) @classmethod def do_setup_class(cls): @@ -58,7 +58,7 @@ class ClickbenchParallelBase(LoadSuiteParallel): return QUERY_NAMES def get_path() -> str: - return get_external_param('table-path-clickbench', f'{YdbCluster.tables_path}/clickbench/hits') + return get_external_param('table-path-clickbench', YdbCluster.get_tables_path('clickbench/hits')) @classmethod def do_setup_class(cls): diff --git a/ydb/tests/olap/load/lib/conftest.py b/ydb/tests/olap/load/lib/conftest.py index 91de8f317f7..6506d2f8f7d 100644 --- a/ydb/tests/olap/load/lib/conftest.py +++ b/ydb/tests/olap/load/lib/conftest.py @@ -84,9 +84,9 @@ class LoadSuiteBase: def check_tables_size(cls, folder: Optional[str], tables: dict[str, int]): wait_error = YdbCluster.wait_ydb_alive( int(os.getenv('WAIT_CLUSTER_ALIVE_TIMEOUT', 20 * 60)), ( - f'{YdbCluster.tables_path}/{folder}' + YdbCluster.get_tables_path(folder) if folder is not None - else [f'{YdbCluster.tables_path}/{t}' for t in tables.keys()] + else [YdbCluster.get_tables_path(t) for t in tables.keys()] )) if wait_error is not None: pytest.fail(f'Cluster is dead: {wait_error}') diff --git a/ydb/tests/olap/load/lib/external.py b/ydb/tests/olap/load/lib/external.py index fc968fc62b1..d251d709cd9 100644 --- a/ydb/tests/olap/load/lib/external.py +++ b/ydb/tests/olap/load/lib/external.py @@ -35,7 +35,7 @@ class ExternalSuiteBase(LoadSuiteBase): cls.check_tables_size(folder=cls.external_folder, tables={}) def test(self, query_name: str): - self.run_workload_test(f'{YdbCluster.tables_path}/{self.external_folder}', query_name=query_name) + self.run_workload_test(YdbCluster.get_tables_path(self.external_folder), query_name=query_name) def pytest_generate_tests(metafunc): diff --git a/ydb/tests/olap/load/lib/import_csv.py b/ydb/tests/olap/load/lib/import_csv.py index 4655bc291bc..ca4cecaec3f 100644 --- a/ydb/tests/olap/load/lib/import_csv.py +++ b/ydb/tests/olap/load/lib/import_csv.py @@ -16,7 +16,7 @@ class ImportFileCsvBase(UploadSuiteBase): def init(self): # Create tables - yatest.common.execute(YdbCliHelper.get_cli_command() + ['workload', 'query', '-p', YdbCluster.tables_path, 'init', '--suite-path', self.get_external_path(), '--clear']) + yatest.common.execute(YdbCliHelper.get_cli_command() + ['workload', 'query', '-p', YdbCluster.get_tables_path(), 'init', '--suite-path', self.get_external_path(), '--clear']) import_dir = os.path.join(self.get_external_path(), "import") table_names = sorted([name for name in os.listdir(import_dir) if os.path.isdir(os.path.join(import_dir, name))]) @@ -26,7 +26,7 @@ class ImportFileCsvBase(UploadSuiteBase): logging.info(f'Importing table: {self.table_name}') def import_data(self): - self.table_path = f'{YdbCluster.tables_path}/{self.table_name}' + self.table_path = YdbCluster.get_tables_path(self.table_name) logging.info(f'Table path: {self.table_path}') import_dir = os.path.join(self.get_external_path(), 'import', self.table_name) csv_files = [f for f in os.listdir(import_dir) if os.path.isfile(os.path.join(import_dir, f)) and f.endswith('.csv')] @@ -63,7 +63,7 @@ class ImportFileCsvBase(UploadSuiteBase): @classmethod def teardown_class(cls) -> None: - yatest.common.execute(YdbCliHelper.get_cli_command() + ['workload', 'query', '-p', YdbCluster.tables_path, 'clean']) + yatest.common.execute(YdbCliHelper.get_cli_command() + ['workload', 'query', '-p', YdbCluster.get_tables_path(), 'clean']) super().teardown_class() diff --git a/ydb/tests/olap/load/lib/tpcds.py b/ydb/tests/olap/load/lib/tpcds.py index 916527a7fa6..4af46a1f059 100644 --- a/ydb/tests/olap/load/lib/tpcds.py +++ b/ydb/tests/olap/load/lib/tpcds.py @@ -29,7 +29,7 @@ class TpcdsSuiteBase(LoadSuiteBase): @classmethod def _get_path(cls, full: bool = True) -> str: if full: - tpcds_path = get_external_param('table-path-tpcds', f'{YdbCluster.tables_path}/tpcds') + tpcds_path = get_external_param('table-path-tpcds', YdbCluster.get_tables_path('tpcds')) else: tpcds_path = 'tpcds' return get_external_param(f'table-path-{cls.suite()}', f'{tpcds_path}/s{cls.scale}') diff --git a/ydb/tests/olap/load/lib/tpch.py b/ydb/tests/olap/load/lib/tpch.py index 82aa733257c..dea72a95ae2 100644 --- a/ydb/tests/olap/load/lib/tpch.py +++ b/ydb/tests/olap/load/lib/tpch.py @@ -31,7 +31,7 @@ class TpchSuiteBase(LoadSuiteBase): @classmethod def _get_path(cls, full: bool = True) -> str: if full: - tpch_path = get_external_param('table-path-tpch', f'{YdbCluster.tables_path}/tpch') + tpch_path = get_external_param('table-path-tpch', YdbCluster.get_tables_path('tpch')) else: tpch_path = 'tpch' return get_external_param(f'table-path-{cls.suite()}', f'{tpch_path}/s{cls.scale}') diff --git a/ydb/tests/olap/load/lib/upload.py b/ydb/tests/olap/load/lib/upload.py index a169efcafcb..81934b4804c 100644 --- a/ydb/tests/olap/load/lib/upload.py +++ b/ydb/tests/olap/load/lib/upload.py @@ -51,7 +51,7 @@ class UploadSuiteBase(LoadSuiteBase): class UploadTpchBase(UploadSuiteBase): @classmethod def __get_path(cls): - return f'{YdbCluster.tables_path}/upload/tpch/s{cls.scale}' + return YdbCluster.get_tables_path(f'upload/tpch/s{cls.scale}') def init(self): yatest.common.execute(YdbCliHelper.get_cli_command() + ['workload', 'tpch', '-p', self.__get_path(), 'init', '--store=column']) diff --git a/ydb/tests/olap/s3_import/large/test_large_import.py b/ydb/tests/olap/s3_import/large/test_large_import.py index 3284e401950..10d7be11044 100644 --- a/ydb/tests/olap/s3_import/large/test_large_import.py +++ b/ydb/tests/olap/s3_import/large/test_large_import.py @@ -102,11 +102,11 @@ class TestLargeS3Import: cls.s3_url = "https://storage.yandexcloud.net" cls.s3_sink_bucket = "olap-exp-private" - cls.external_source_path = f"{YdbCluster.tables_path}/tpc_h_s3_parquet_import" - cls.external_sink_path = f"{YdbCluster.tables_path}/tpc_h_s3_parquet_export" - cls.external_table_path = f"{YdbCluster.tables_path}/s{cls.scale}/tpc_h_lineitem_s3_parquet_import" - cls.external_sink_table_path = f"{YdbCluster.tables_path}/s{cls.scale}/tpc_h_lineitem_s3_parquet_export" - cls.olap_table_path = f"{YdbCluster.tables_path}/s{cls.scale}/tpc_h_lineitem_olap" + cls.external_source_path = YdbCluster.get_tables_path("tpc_h_s3_parquet_import") + cls.external_sink_path = YdbCluster.get_tables_path("tpc_h_s3_parquet_export") + cls.external_table_path = YdbCluster.get_tables_path(f"s{cls.scale}/tpc_h_lineitem_s3_parquet_import") + cls.external_sink_table_path = YdbCluster.get_tables_path(f"s{cls.scale}/tpc_h_lineitem_s3_parquet_export") + cls.olap_table_path = YdbCluster.get_tables_path(f"s{cls.scale}/tpc_h_lineitem_olap") cls.table_size = { "1": 6001215, "10": 59986052, @@ -122,7 +122,7 @@ class TestLargeS3Import: f"external sink table: {cls.external_sink_table_path}") logger.info(f"target claster info, endpoint: {YdbCluster.ydb_endpoint}, " f"database: {YdbCluster.ydb_database}, " - f"tables path: {YdbCluster.tables_path}, " + f"tables path: {YdbCluster.get_tables_path()}, " f"has key {'YES' if os.getenv('OLAP_YDB_OAUTH', None) else 'NO'}") logger.info(f"results info, send-results: {ResultsProcessor.send_results}, " f"endpoints: {get_external_param('results-endpoint', '-')}, " @@ -152,7 +152,7 @@ class TestLargeS3Import: self.query(f"DROP TABLE IF EXISTS `{self.olap_table_path}`;") def setup_datasource(self): - logger.info(f"setupping datasource by path `{YdbCluster.tables_path}/`...") + logger.info(f"setupping datasource by path `{YdbCluster.get_tables_path()}/`...") self.query(f""" CREATE OR REPLACE EXTERNAL DATA SOURCE `{self.external_source_path}` WITH ( SOURCE_TYPE="ObjectStorage", diff --git a/ydb/tests/olap/scenario/helpers/scenario_tests_helper.py b/ydb/tests/olap/scenario/helpers/scenario_tests_helper.py index 30d3300202f..1212e48d008 100644 --- a/ydb/tests/olap/scenario/helpers/scenario_tests_helper.py +++ b/ydb/tests/olap/scenario/helpers/scenario_tests_helper.py @@ -313,17 +313,17 @@ class ScenarioTestHelper: Full path. """ - def _add_not_empty(p: str, dir: str): - if dir is None or dir == '': - return p - return os.path.join(p, dir) + def _add_not_empty(p: list[str], dir: str): + if dir: + p.append(dir) - result = os.path.join('/', YdbCluster.ydb_database, YdbCluster.tables_path) + result = [f'/{YdbCluster.ydb_database}'] + _add_not_empty(result, YdbCluster.get_tables_path()) if self.test_context is not None: - result = _add_not_empty(result, self.test_context.suite) - result = _add_not_empty(result, self.test_context.test) - result = _add_not_empty(result, path) - return result + _add_not_empty(result, self.test_context.suite) + _add_not_empty(result, self.test_context.test) + _add_not_empty(result, path) + return '/'.join(result) @staticmethod def _run_with_expected_status( |
