From 3ca5dd537f9c0dfdabbdd553854896dcc7349a5f Mon Sep 17 00:00:00 2001 From: Michael Litvak Date: Thu, 29 Aug 2024 10:11:32 +0300 Subject: [PATCH] test/pylib: use view_build_status_v2 table in wait_for_view Change the util function wait_for_view to read the view build status from the system.view_build_status_v2 table which replaces system_distributed.view_build_status. The old table can still be used but it is less efficient because it's implemented as a virtual table which reads from the v2 table, so it's better to read directly from the v2 table. This can cause slowness in tests. The additional util function wait_for_view_v1 reads from the old table. This may be needed in upgrade tests if the v2 table is not available yet. --- test/pylib/util.py | 9 ++++++++- test/topology_custom/test_view_build_status.py | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/test/pylib/util.py b/test/pylib/util.py index e8265b6973..3e6cdc6e15 100644 --- a/test/pylib/util.py +++ b/test/pylib/util.py @@ -233,9 +233,16 @@ async def start_writes(cql: Session, keyspace: str, table: str, concurrency: int return finish -async def wait_for_view(cql: Session, name: str, node_count: int, timeout: int = 120): +async def wait_for_view_v1(cql: Session, name: str, node_count: int, timeout: int = 120): async def view_is_built(): done = await cql.run_async(f"SELECT COUNT(*) FROM system_distributed.view_build_status WHERE status = 'SUCCESS' AND view_name = '{name}' ALLOW FILTERING") return done[0][0] == node_count or None deadline = time.time() + timeout await wait_for(view_is_built, deadline) + +async def wait_for_view(cql: Session, name: str, node_count: int, timeout: int = 120): + async def view_is_built(): + done = await cql.run_async(f"SELECT COUNT(*) FROM system.view_build_status_v2 WHERE status = 'SUCCESS' AND view_name = '{name}' ALLOW FILTERING") + return done[0][0] == node_count or None + deadline = time.time() + timeout + await wait_for(view_is_built, deadline) diff --git a/test/topology_custom/test_view_build_status.py b/test/topology_custom/test_view_build_status.py index aed1190118..4b95c5980f 100644 --- a/test/topology_custom/test_view_build_status.py +++ b/test/topology_custom/test_view_build_status.py @@ -7,7 +7,7 @@ import pytest import time import asyncio import logging -from test.pylib.util import unique_name, wait_for_cql_and_get_hosts, wait_for, wait_for_view +from test.pylib.util import unique_name, wait_for_cql_and_get_hosts, wait_for, wait_for_view, wait_for_view_v1 from test.pylib.manager_client import ManagerClient from test.pylib.internal_types import ServerInfo from test.topology.util import trigger_snapshot, wait_until_topology_upgrade_finishes, enter_recovery_state, reconnect_driver, \ @@ -406,7 +406,7 @@ async def test_view_build_status_migration_to_v2_with_cleanup(request, manager: await create_table(cql) await create_mv(cql, "vt1") - await wait_for_view(cql, "vt1", 4) + await wait_for_view_v1(cql, "vt1", 4) result = await cql.run_async("SELECT * FROM system_distributed.view_build_status") assert len(result) == 4