From 590f0329ae594da28941b8f7e02ce6c19ebe6c4d Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 2 Apr 2024 16:25:26 +0300 Subject: [PATCH] test: Test how tablets are copied between nodes This patches the previously introduced test by introducing the 'action' test paramter and tweaking the final checking assertions around tablet replicas read from system.tablets Signed-off-by: Pavel Emelyanov --- .../topology_custom/test_tablets_migration.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/topology_custom/test_tablets_migration.py b/test/topology_custom/test_tablets_migration.py index 4ed9a9a133..b809ae2c8f 100644 --- a/test/topology_custom/test_tablets_migration.py +++ b/test/topology_custom/test_tablets_migration.py @@ -15,8 +15,9 @@ import asyncio logger = logging.getLogger(__name__) +@pytest.mark.parametrize("action", ['move', 'add_replica']) @pytest.mark.asyncio -async def test_tablet_transition_sanity(manager: ManagerClient): +async def test_tablet_transition_sanity(manager: ManagerClient, action): logger.info("Bootstrapping cluster") cfg = {'enable_user_defined_functions': False, 'experimental_features': ['tablets', 'consistent-topology-changes']} host_ids = [] @@ -50,15 +51,24 @@ async def test_tablet_transition_sanity(manager: ManagerClient): else: assert False, "Cannot find tablet on none of the servers" - logger.info(f"Move tablet {old_replica[0]} -> {new_replica[0]}") - await manager.api.move_tablet(servers[0].ip_addr, "test", "test", old_replica[0], old_replica[1], new_replica[0], new_replica[1], 0) + if action == 'move': + logger.info(f"Move tablet {old_replica[0]} -> {new_replica[0]}") + await manager.api.move_tablet(servers[0].ip_addr, "test", "test", old_replica[0], old_replica[1], new_replica[0], new_replica[1], 0) + if action == 'add_replica': + logger.info(f"Adding replica to tablet, host {new_replica[0]}") + await manager.api.add_tablet_replica(servers[0].ip_addr, "test", "test", new_replica[0], new_replica[1], 0) replicas = await get_all_tablet_replicas(manager, servers[0], 'test', 'test') logger.info(f"Tablet is now on [{replicas}]") assert len(replicas) == 1 replicas = [ r[0] for r in replicas[0].replicas ] - assert len(replicas) == 1 - assert new_replica[0] in replicas + if action == 'move': + assert len(replicas) == 1 + assert new_replica[0] in replicas + if action == 'add_replica': + assert len(replicas) == 2 + assert old_replica[0] in replicas + assert new_replica[0] in replicas @pytest.mark.parametrize("fail_replica", ["source", "destination"])