Skip to content

Conversation

LebedevOleg1
Copy link
Collaborator

Changelog entry

Create test of full cycle local backup restore
...

Changelog category

  • Not for changelog

Description for reviewers

Create test of full cycle local backup restore
...

Copy link

github-actions bot commented Oct 8, 2025

2025-10-08 15:04:23 UTC Pre-commit check linux-x86_64-release-asan for ee9d171 has started.
2025-10-08 15:04:35 UTC Artifacts will be uploaded here
2025-10-08 15:07:25 UTC ya make is running...
🟢 2025-10-08 15:07:31 UTC Tests successful.

Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
0 0 0 0 0 0

🟢 2025-10-08 15:07:34 UTC Build successful.

Copy link

github-actions bot commented Oct 8, 2025

2025-10-08 15:04:26 UTC Pre-commit check linux-x86_64-relwithdebinfo for ee9d171 has started.
2025-10-08 15:04:37 UTC Artifacts will be uploaded here
2025-10-08 15:07:14 UTC ya make is running...
🟢 2025-10-08 15:07:20 UTC Tests successful.

Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
0 0 0 0 0 0

🟢 2025-10-08 15:07:23 UTC Build successful.

Copy link

github-actions bot commented Oct 8, 2025

🟢 2025-10-08 15:05:24 UTC The validation of the Pull Request description is successful.

Copy link
Member

@Enjection Enjection left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавь в родительский ya.make что бы система подхватила тесты (ybd/tests/functional/ya.make)

@Enjection
Copy link
Member

Enjection commented Oct 9, 2025

Тесты не проходят локально, но есть возможность, что это на моей стороне что-то:

$ ya make -ttt -k --test-disable-timeout --build relwithdebinfo

...

[fail] basic_user_scenarios.py::TestFullCycleLocalBackupRestore::test_full_cycle_local_backup_restore [default-linux-x86_64-relwithdebinfo] (25.38s)
ydb/tests/functional/backup_collection/basic_user_scenarios.py:251: in test_full_cycle_local_backup_restore
    assert backup_res2.exit_code == 0, "BACKUP (2) failed"
E   AssertionError: BACKUP (2) failed
E   assert 1 == 0
E    +  where 1 = <yatest.common.process._Execution object at 0x7f2f1af2ca60>.exit_code
Log: /home/innokentii/ydbwork2/ydb/ydb/tests/functional/backup_collection/test-results/py3test/basic_user_scenarios/chunk0/testing_out_stuff/basic_user_scenarios.py.TestFullCycleLocalBackupRestore.test_full_cycle_local_backup_restore.log
Logsdir: /home/innokentii/ydbwork2/ydb/ydb/tests/functional/backup_collection/test-results/py3test/basic_user_scenarios/chunk0/testing_out_stuff

...

------ FAIL: 1 - FAIL ydb/tests/functional/backup_collection

Total 3 suites:
        2 - GOOD
        1 - FAIL
Total 4 tests:
        3 - GOOD
        1 - FAIL
Failed

Copy link
Member

@Enjection Enjection left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так же возможно стоит проверять некоторые минимальные инварианты в скимшарде, что бэкап коллекция существует или таблицы в ней и т.п.

Comment on lines +35 to +57

def parse_yql_table(text):
if not text:
return []

lines = text.splitlines()
rows = []
border_re = re.compile(r'^[\s┌┬┐└┴┘├┼┤─]+$')
for ln in lines:
ln = ln.rstrip("\r\n")
if not ln:
continue
if border_re.match(ln):
continue
if '│' not in ln:
continue
parts = [p.strip() for p in ln.split('│')]
if parts and parts[0] == '':
parts = parts[1:]
if parts and parts[-1] == '':
parts = parts[:-1]
rows.append(parts)
return rows
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Точно ли нам нужен ручной парсер? Не стоит ли воспользоваться SDK?

Comment on lines +213 to +217
create_res = yatest.common.execute(
[backup_bin(), "--endpoint", "grpc://localhost:%d" % self.cluster.nodes[1].grpc_port,
"--database", "/Root", "yql", "--script", create_collection_sql],
check_exit_code=False,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Возможно стоит вынести для читаемости

def _execute_yql(self, script):
    cmd = [
        backup_bin(),
        "--endpoint",
        f"grpc://localhost:{self.cluster.nodes[1].grpc_port}",
        "--database",
        self.root_dir,
        "yql",
        "--script",
        script,
    ]
    return yatest.common.execute(cmd, check_exit_code=False)

@Enjection
Copy link
Member

Стоит основную функцию сделать чуть более "высокоуровневой". Что-то вроде:

def test_full_cycle_local_backup_restore(self):
    # Setup
    collection_src, t1, t2 = self._setup_test_collections()
    
    # Create and backup
    self._create_initial_backup(collection_src, t1, t2)
    snapshot1 = self._capture_snapshot(t1)
    
    # Modify and backup again
    self._modify_and_backup(collection_src)
    snapshot2 = self._capture_snapshot(t1)
    
    # Export backups
    export_dir = self._export_backups(collection_src)
    
    # Restore and verify
    self._verify_restore(export_dir, snapshot1, snapshot2)

Comment on lines +203 to +212
create_collection_sql = (
f"CREATE BACKUP COLLECTION `{collection_src}`\n"
f" ( TABLE `{full_t1}`\n"
f" , TABLE `{full_t2}`\n"
f" )\n"
"WITH\n"
" ( STORAGE = 'cluster'\n"
" , INCREMENTAL_BACKUP_ENABLED = 'false'\n"
" );\n"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше так

query = f"""
CREATE BACKUP COLLECTION `{collection_src}`
    ( TABLE `{full_t1}
    , TABLE `{full_t2}
    )
WITH
    ...
"""

full_t1 = f"/Root/{t1}"
full_t2 = f"/Root/{t2}"

session = self.driver.table_client.session().create()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with self.driver.table_client.session().create() as session:
create_table_with_data(session, t1)
# ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не уверен, что в тестах это прям актуально

Copy link
Member

@Enjection Enjection left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И ещё немного коментов

@LebedevOleg1
Copy link
Collaborator Author

Тесты не проходят локально, но есть возможность, что это на моей стороне что-то:

$ ya make -ttt -k --test-disable-timeout --build relwithdebinfo

...

[fail] basic_user_scenarios.py::TestFullCycleLocalBackupRestore::test_full_cycle_local_backup_restore [default-linux-x86_64-relwithdebinfo] (25.38s)
ydb/tests/functional/backup_collection/basic_user_scenarios.py:251: in test_full_cycle_local_backup_restore
    assert backup_res2.exit_code == 0, "BACKUP (2) failed"
E   AssertionError: BACKUP (2) failed
E   assert 1 == 0
E    +  where 1 = <yatest.common.process._Execution object at 0x7f2f1af2ca60>.exit_code
Log: /home/innokentii/ydbwork2/ydb/ydb/tests/functional/backup_collection/test-results/py3test/basic_user_scenarios/chunk0/testing_out_stuff/basic_user_scenarios.py.TestFullCycleLocalBackupRestore.test_full_cycle_local_backup_restore.log
Logsdir: /home/innokentii/ydbwork2/ydb/ydb/tests/functional/backup_collection/test-results/py3test/basic_user_scenarios/chunk0/testing_out_stuff

...

------ FAIL: 1 - FAIL ydb/tests/functional/backup_collection

Total 3 suites:
        2 - GOOD
        1 - FAIL
Total 4 tests:
        3 - GOOD
        1 - FAIL
Failed

у меня тоже с оптимизированной сборкой падает...
без:
lebedev0leg@mr-nvme-testing-11:~/ydbwork/ydb/ydb/tests/functional/backup_collection$ ya make -ttt -k --test-disable-timeout
Info: Timeout for test Test [project=ydb/tests/functional/backup_collection, name=flake8] is turned off
Info: Timeout for test Test [project=ydb/tests/functional/backup_collection, name=import_test] is turned off
Info: Timeout for test Test [project=ydb/tests/functional/backup_collection, name=py3test] is turned off

Total 3 suites:
3 - GOOD
Total 4 tests:
4 - GOOD
Ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants