diff options
| author | xyliganSereja <[email protected]> | 2025-10-01 18:56:13 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-10-01 18:56:13 +0300 |
| commit | 301ee1c2239bfc9855bea2c4e102ca158cfd822f (patch) | |
| tree | 6d084797781b4f041fa37216899085b3c8c9878e | |
| parent | df38aca3fb40ede425fbc29d12bbda2191636800 (diff) | |
added wait_for (#26171)
Co-authored-by: Matveev Sergei <[email protected]>
| -rw-r--r-- | ydb/tests/compatibility/olap/test_rename_table.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/ydb/tests/compatibility/olap/test_rename_table.py b/ydb/tests/compatibility/olap/test_rename_table.py index 19cb55e63fd..4673dedd2b0 100644 --- a/ydb/tests/compatibility/olap/test_rename_table.py +++ b/ydb/tests/compatibility/olap/test_rename_table.py @@ -1,12 +1,24 @@ # -*- coding: utf-8 -*- import pytest import logging +from ydb.tests.library.common.wait_for import wait_for from ydb.tests.library.compatibility.fixtures import RollingUpgradeAndDowngradeFixture, RestartToAnotherVersionFixture from ydb.tests.oss.ydb_sdk_import import ydb logger = logging.getLogger(__name__) +def wait_for_undetermined_ok(action, timeout_seconds=60, step_seconds=1): + def predicate(): + try: + action() + return True + except ydb.issues.Undetermined: + return False + + return wait_for(predicate, timeout_seconds=timeout_seconds, step_seconds=step_seconds) + + class TestRenameTableRestart(RestartToAnotherVersionFixture): @pytest.fixture(autouse=True, scope="function") def setup(self): @@ -136,7 +148,7 @@ class TestRenameTableRollingUpdate(RollingUpgradeAndDowngradeFixture): data_struct_type.add_member("k", ydb.PrimitiveType.Uint64) data_struct_type.add_member("v", ydb.PrimitiveType.String) - session_pool.execute_with_retries( + wait_for_undetermined_ok(lambda: session_pool.execute_with_retries( f""" DECLARE $data AS List<Struct<k: Uint64, v: String>>; UPSERT INTO `{self.get_table_name(iteration)}` @@ -144,13 +156,18 @@ class TestRenameTableRollingUpdate(RollingUpgradeAndDowngradeFixture): FROM AS_TABLE($data); """, {"$data": (rows, ydb.ListType(data_struct_type))} - ) + )) logger.info(f"Iteration {iteration} about to rename") session_pool.execute_with_retries( f""" ALTER TABLE `{self.get_table_name(iteration)}` RENAME TO `{self.get_table_name(iteration + 1)}`; """ ) + wait_for_undetermined_ok(lambda: session_pool.execute_with_retries( + f""" + select count(*) as cnt from `{self.get_table_name(iteration + 1)}`; + """ + )) result = session_pool.execute_with_retries( f""" select count(*) as cnt from `{self.get_table_name(iteration + 1)}`; |
